Pastebin
Retrouvez, créez et partagez vos snippets en temps réel.
Rechercher un Pastebin
Aucun paste trouvé.
Créer un paste
Pastebin
Blog
dsgdfg
// ==UserScript== // @name Auto Captcha Solver (Universal Detection) // @namespace http://tampermonkey.net/ // @version 2.1 // @description Advanced solver that addresses Apollo/State mismatch by deep-syncing tokens with internal reCAPTCHA callbacks // @author You // @match *://*/* // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant unsafeWindow // @connect 2captcha.com // @connect api.capsolver.com // @run-at document-end // ==/UserScript== (function() { 'use strict'; const CONFIG = { service: GM_getValue('captcha_service', 'none'), apiKey2Captcha: GM_getValue('api_key_2captcha', ''), apiKeyCapSolver: GM_getValue('api_key_capsolver', ''), autoSolve: GM_getValue('auto_solve', true), pollInterval: 5000, maxAttempts: 30 }; const API = { '2captcha': { submit: 'https://2captcha.com/in.php', result: 'https://2captcha.com/res.php' }, 'capsolver': { endpoint: 'https://api.capsolver.com/createTask' } }; // ==================== SETTINGS UI ==================== function createSettingsButton() { if (document.getElementById('captcha-settings-btn')) return; const btn = document.createElement('button'); btn.id = 'captcha-settings-btn'; btn.textContent = '⚙️ Captcha'; btn.style.cssText = `position: fixed; bottom: 20px; right: 20px; z-index: 999999; padding: 10px 15px; background: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 14px; box-shadow: 0 2px 5px rgba(0,0,0,0.3);`; btn.onclick = showSettingsModal; document.body.appendChild(btn); } function showSettingsModal() { const modal = document.createElement('div'); modal.style.cssText = `position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1000000; display: flex; justify-content: center; align-items: center;`; modal.innerHTML = ` <div style="background: white; padding: 30px; border-radius: 10px; max-width: 500px; width: 90%; color: #333; font-family: sans-serif;"> <h2 style="margin-top: 0;">Captcha Solver Settings</h2> <select id="captcha-service" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;"> <option value="none">Disabled</option> <option value="2captcha">2Captcha</option> <option value="capsolver">CapSolver</option> </select> <input type="text" id="api-2captcha" placeholder="2Captcha Key" style="width: 100%; padding: 8px; margin-top: 10px; border: 1px solid #ddd; border-radius: 4px;"> <input type="text" id="api-capsolver" placeholder="CapSolver Key" style="width: 100%; padding: 8px; margin-top: 10px; border: 1px solid #ddd; border-radius: 4px;"> <label style="display: block; margin-top: 10px;"><input type="checkbox" id="auto-solve"> Auto-solve</label> <div style="margin-top: 20px; display: flex; gap: 10px;"> <button id="save-settings" style="flex: 1; padding: 10px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer;">Save</button> <button id="close-settings" style="flex: 1; padding: 10px; background: #f44336; color: white; border: none; border-radius: 4px; cursor: pointer;">Cancel</button> </div> </div>`; document.body.appendChild(modal); document.getElementById('captcha-service').value = CONFIG.service; document.getElementById('api-2captcha').value = CONFIG.apiKey2Captcha; document.getElementById('api-capsolver').value = CONFIG.apiKeyCapSolver; document.getElementById('auto-solve').checked = CONFIG.autoSolve; document.getElementById('save-settings').onclick = () => { GM_setValue('captcha_service', document.getElementById('captcha-service').value); GM_setValue('api_key_2captcha', document.getElementById('api-2captcha').value.trim()); GM_setValue('api_key_capsolver', document.getElementById('api-capsolver').value.trim()); GM_setValue('auto_solve', document.getElementById('auto_solve').checked); location.reload(); }; document.getElementById('close-settings').onclick = () => modal.remove(); } // ==================== DETECTION ==================== function detectCaptchas() { const captchas = []; document.querySelectorAll('iframe[src*="recaptcha"]').forEach(iframe => { const match = iframe.getAttribute('src').match(/[?&]k=([^&]+)/); if (match && match[1]) { const sitekey = match[1]; let container = iframe.closest('[data-recaptcha-action]') || iframe.closest('#recaptcha-target') || iframe.parentElement; if (!container.hasAttribute('data-solver-processed')) { captchas.push({ type: 'recaptcha_v2', sitekey, element: container }); } } }); return captchas; } // ==================== SOLVING ==================== async function solve2Captcha(sitekey) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: API['2captcha'].submit, data: `key=${CONFIG.apiKey2Captcha}&method=userrecaptcha&googlekey=${sitekey}&pageurl=${window.location.href}&json=1`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: (res) => { const data = JSON.parse(res.responseText); if (data.status === 1) poll2Captcha(data.request, resolve, reject); else reject(new Error(data.request)); } }); }); } function poll2Captcha(id, resolve, reject, count = 0) { if (count >= CONFIG.maxAttempts) return reject(new Error('Timeout')); setTimeout(() => { GM_xmlhttpRequest({ method: 'GET', url: `${API['2captcha'].result}?key=${CONFIG.apiKey2Captcha}&action=get&id=${id}&json=1`, onload: (res) => { const data = JSON.parse(res.responseText); if (data.status === 1) resolve(data.request); else if (data.request === 'CAPCHA_NOT_READY') poll2Captcha(id, resolve, reject, count + 1); else reject(new Error(data.request)); } }); }, CONFIG.pollInterval); } async function solveCapSolver(sitekey) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: API['capsolver'].endpoint, headers: { 'Content-Type': 'application/json' }, data: JSON.stringify({ clientKey: CONFIG.apiKeyCapSolver, task: { type: 'ReCaptchaV2TaskProxyless', websiteURL: window.location.href, websiteKey: sitekey }}), onload: (res) => { const data = JSON.parse(res.responseText); if (data.errorId === 0) pollCapSolver(data.taskId, resolve, reject); else reject(new Error(data.errorDescription)); } }); }); } function pollCapSolver(id, resolve, reject, count = 0) { if (count >= CONFIG.maxAttempts) return reject(new Error('Timeout')); setTimeout(() => { GM_xmlhttpRequest({ method: 'POST', url: 'https://api.capsolver.com/getTaskResult', headers: { 'Content-Type': 'application/json' }, data: JSON.stringify({ clientKey: CONFIG.apiKeyCapSolver, taskId: id }), onload: (res) => { const data = JSON.parse(res.responseText); if (data.status === 'ready') resolve(data.solution.gRecaptchaResponse); else if (data.status === 'processing') pollCapSolver(id, resolve, reject, count + 1); else reject(new Error(data.errorDescription)); } }); }, CONFIG.pollInterval); } // ==================== INJECTION (STATE SYNC) ==================== function triggerSiteCallback(token) { const win = unsafeWindow || window; console.log('⚡ Starting Deep State Sync for token...'); // 1. Fill Textareas for safety document.querySelectorAll('[name="g-recaptcha-response"], #g-recaptcha-response').forEach(el => { el.value = token; el.dispatchEvent(new Event('input', { bubbles: true })); el.dispatchEvent(new Event('change', { bubbles: true })); }); // 2. Mock Global Object if (win.grecaptcha) { win.grecaptcha.getResponse = () => token; } // 3. ARCHITECTURE SYNC: Finding hidden state update functions let callbackTriggered = false; if (win.___grecaptcha_cfg && win.___grecaptcha_cfg.clients) { const clients = win.___grecaptcha_cfg.clients; console.log(`Searching through ${Object.keys(clients).length} reCAPTCHA clients...`); Object.keys(clients).forEach(clientId => { const client = clients[clientId]; // Recursively look for a callback in the client object function findAndExecute(obj, depth = 0) { if (depth > 5 || !obj) return; for (const key in obj) { const target = obj[key]; if (target && typeof target === 'object' && target.callback) { const cb = target.callback; console.log(`🔥 Client[${clientId}]: Found callback in property "${key}"`); try { if (typeof cb === 'function') { cb(token); callbackTriggered = true; } else if (typeof win[cb] === 'function') { win[cb](token); callbackTriggered = true; } } catch (e) { console.error('Callback error:', e); } } else if (typeof target === 'object') { findAndExecute(target, depth + 1); } } } findAndExecute(client); }); } // 4. Fallback for Qwik/Apollo named functions const actionElements = document.querySelectorAll('[data-recaptcha-action]'); actionElements.forEach(el => { const action = el.getAttribute('data-recaptcha-action'); if (action && typeof win[action] === 'function') { console.log('🚀 Executing named action fallback:', action); try { win[action](token); callbackTriggered = true; } catch (e) { console.error(e); } } }); // 5. Final Step: If we triggered a callback, wait a bit then click the button // This ensures the internal JS state has the token BEFORE the click happens if (callbackTriggered) { console.log('✅ Internal state likely updated. Waiting for framework to settle...'); setTimeout(() => { const submitBtn = document.querySelector('button[type="submit"]') || Array.from(document.querySelectorAll('button')).find(b => b.textContent.toLowerCase().includes('join') || b.textContent.toLowerCase().includes('verify') ); if (submitBtn) { console.log('🎯 Final Click on:', submitBtn.textContent.trim()); submitBtn.click(); } }, 1000); } else { console.warn('⚠️ No internal state callback found. Apollo mutation might still fail.'); } } async function solveCaptcha(captcha) { if (CONFIG.service === 'none' || !CONFIG.autoSolve) return; captcha.element.setAttribute('data-solver-processed', 'true'); showIndicator(captcha.sitekey); try { let token; if (CONFIG.service === '2captcha') token = await solve2Captcha(captcha.sitekey); else if (CONFIG.service === 'capsolver') token = await solveCapSolver(captcha.sitekey); if (token) { console.log('✅ Captcha solved! Syncing with application state...'); triggerSiteCallback(token); } } catch (e) { console.error('❌ Solver Error:', e.message); captcha.element.removeAttribute('data-solver-processed'); } finally { hideIndicator(); } } function showIndicator(key) { const div = document.createElement('div'); div.id = 'captcha-solving'; div.innerHTML = `<div style="text-align:center;"><b>Solving Captcha...</b><br><small>${key.substring(0,12)}...</small></div>`; div.style.cssText = `position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 12px 24px; border-radius: 8px; z-index: 9999999; box-shadow: 0 4px 12px rgba(0,0,0,0.4); font-family: sans-serif;`; document.body.appendChild(div); } function hideIndicator() { const el = document.getElementById('captcha-solving'); if (el) el.remove(); } function run() { createSettingsButton(); detectCaptchas().forEach(solveCaptcha); } const observer = new MutationObserver(() => run()); observer.observe(document.body, { childList: true, subtree: true }); run(); })();
Créé il y a 3 semaines.