Update Api/recaptcha2.js
Browse files- Api/recaptcha2.js +34 -32
Api/recaptcha2.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
/**
|
| 2 |
-
* API_RECAPTCHA2 -
|
| 3 |
*/
|
|
|
|
|
|
|
| 4 |
async function recaptchaV2({ domain, siteKey, action = "submit", isInvisible = false, proxy }, page) {
|
| 5 |
if (!domain) throw new Error("Missing domain parameter");
|
| 6 |
if (!siteKey) throw new Error("Missing siteKey parameter");
|
|
@@ -13,7 +15,7 @@ async function recaptchaV2({ domain, siteKey, action = "submit", isInvisible = f
|
|
| 13 |
const cl = setTimeout(() => {
|
| 14 |
if (!isResolved) {
|
| 15 |
isResolved = true;
|
| 16 |
-
reject(new Error("Timeout Error:
|
| 17 |
}
|
| 18 |
}, timeout);
|
| 19 |
|
|
@@ -23,53 +25,51 @@ async function recaptchaV2({ domain, siteKey, action = "submit", isInvisible = f
|
|
| 23 |
<html lang="en">
|
| 24 |
<head>
|
| 25 |
<meta charset="UTF-8">
|
| 26 |
-
<title>reCAPTCHA
|
| 27 |
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
| 28 |
<style>
|
| 29 |
-
body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #
|
| 30 |
-
.box {
|
| 31 |
</style>
|
| 32 |
</head>
|
| 33 |
<body>
|
| 34 |
<div class="box">
|
| 35 |
-
<div class="g-recaptcha" data-sitekey="${siteKey}"
|
| 36 |
<textarea id="g-recaptcha-response" name="g-recaptcha-response" style="display:none"></textarea>
|
| 37 |
</div>
|
| 38 |
</body>
|
| 39 |
</html>
|
| 40 |
`;
|
| 41 |
|
| 42 |
-
|
| 43 |
-
page.
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
if ([domain, domain + "/"].includes(url) && req.resourceType() === "document") {
|
| 47 |
-
await req.respond({ status: 200, contentType: "text/html", body: htmlContent });
|
| 48 |
-
} else if (["image", "font", "media"].includes(req.resourceType())) {
|
| 49 |
-
await req.abort();
|
| 50 |
-
} else {
|
| 51 |
-
await req.continue();
|
| 52 |
-
}
|
| 53 |
-
});
|
| 54 |
-
|
| 55 |
-
console.log(`[SOLVER] Loading target...`);
|
| 56 |
await page.goto(domain, { waitUntil: "networkidle2", timeout });
|
| 57 |
|
| 58 |
-
//
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
}
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
// --- POLLING TOKEN ---
|
| 74 |
const tokenValue = await page.waitForFunction(() => {
|
| 75 |
const input = document.querySelector('#g-recaptcha-response');
|
|
@@ -84,6 +84,8 @@ async function recaptchaV2({ domain, siteKey, action = "submit", isInvisible = f
|
|
| 84 |
if (!isResolved) {
|
| 85 |
isResolved = true;
|
| 86 |
clearTimeout(cl);
|
|
|
|
|
|
|
| 87 |
reject(new Error(`Bypass failed: ${error.message}`));
|
| 88 |
}
|
| 89 |
}
|
|
|
|
| 1 |
/**
|
| 2 |
+
* API_RECAPTCHA2 - Debug Mode (No Abort + Auto Screenshot)
|
| 3 |
*/
|
| 4 |
+
const fs = require('fs');
|
| 5 |
+
|
| 6 |
async function recaptchaV2({ domain, siteKey, action = "submit", isInvisible = false, proxy }, page) {
|
| 7 |
if (!domain) throw new Error("Missing domain parameter");
|
| 8 |
if (!siteKey) throw new Error("Missing siteKey parameter");
|
|
|
|
| 15 |
const cl = setTimeout(() => {
|
| 16 |
if (!isResolved) {
|
| 17 |
isResolved = true;
|
| 18 |
+
reject(new Error("Timeout Error: Check debug_captcha.png in your Space files"));
|
| 19 |
}
|
| 20 |
}, timeout);
|
| 21 |
|
|
|
|
| 25 |
<html lang="en">
|
| 26 |
<head>
|
| 27 |
<meta charset="UTF-8">
|
| 28 |
+
<title>reCAPTCHA Debugger</title>
|
| 29 |
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
| 30 |
<style>
|
| 31 |
+
body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #ffffff; margin: 0; }
|
| 32 |
+
.box { border: 1px solid #ccc; padding: 20px; border-radius: 8px; }
|
| 33 |
</style>
|
| 34 |
</head>
|
| 35 |
<body>
|
| 36 |
<div class="box">
|
| 37 |
+
<div class="g-recaptcha" data-sitekey="${siteKey}"></div>
|
| 38 |
<textarea id="g-recaptcha-response" name="g-recaptcha-response" style="display:none"></textarea>
|
| 39 |
</div>
|
| 40 |
</body>
|
| 41 |
</html>
|
| 42 |
`;
|
| 43 |
|
| 44 |
+
// Matikan REQ ABORT agar semua aset (gambar/css) dimuat
|
| 45 |
+
await page.setRequestInterception(false);
|
| 46 |
+
|
| 47 |
+
console.log(`[SOLVER] Navigating to target...`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
await page.goto(domain, { waitUntil: "networkidle2", timeout });
|
| 49 |
|
| 50 |
+
// Suntikkan HTML (menggunakan evaluate karena interception dimatikan)
|
| 51 |
+
await page.evaluate((html) => {
|
| 52 |
+
document.documentElement.innerHTML = html;
|
| 53 |
+
}, htmlContent);
|
| 54 |
+
|
| 55 |
+
await new Promise(r => setTimeout(r, 5000));
|
| 56 |
|
| 57 |
+
// --- TRIGGER CLICK ---
|
| 58 |
+
console.log("[SOLVER] Clicking checkbox...");
|
| 59 |
+
const frames = await page.frames();
|
| 60 |
+
const anchorFrame = frames.find(f => f.url().includes('api2/anchor'));
|
| 61 |
+
if (anchorFrame) {
|
| 62 |
+
await anchorFrame.click('#recaptcha-anchor');
|
| 63 |
}
|
| 64 |
|
| 65 |
+
// Tunggu proses ekstensi (15 detik)
|
| 66 |
+
await new Promise(r => setTimeout(r, 15000));
|
| 67 |
+
|
| 68 |
+
// --- AMBIL SCREENSHOT UNTUK DEBUG ---
|
| 69 |
+
console.log("[SOLVER] Taking debug screenshot...");
|
| 70 |
+
await page.screenshot({ path: 'debug_captcha.png', fullPage: true });
|
| 71 |
+
console.log("[SOLVER] Screenshot saved as debug_captcha.png");
|
| 72 |
+
|
| 73 |
// --- POLLING TOKEN ---
|
| 74 |
const tokenValue = await page.waitForFunction(() => {
|
| 75 |
const input = document.querySelector('#g-recaptcha-response');
|
|
|
|
| 84 |
if (!isResolved) {
|
| 85 |
isResolved = true;
|
| 86 |
clearTimeout(cl);
|
| 87 |
+
// Ambil screenshot saat error juga
|
| 88 |
+
await page.screenshot({ path: 'debug_error.png' });
|
| 89 |
reject(new Error(`Bypass failed: ${error.message}`));
|
| 90 |
}
|
| 91 |
}
|