XORE21 commited on
Commit
44803e0
·
verified ·
1 Parent(s): 3173341

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +76 -26
index.js CHANGED
@@ -12,7 +12,7 @@ let activeBrowsers = 0;
12
 
13
  async function createBrowser(proxy = null) {
14
  const options = {
15
- headless: false,
16
  turnstile: true,
17
  args: [
18
  '--no-sandbox',
@@ -43,8 +43,31 @@ async function createBrowser(proxy = null) {
43
  return { browser, page };
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  async function handleCloudflare(page, url) {
47
  return new Promise(async (resolve, reject) => {
 
48
  const timeout = setTimeout(() => reject(new Error("Timeout Cloudflare Bypass")), 120000);
49
 
50
  try {
@@ -54,6 +77,7 @@ async function handleCloudflare(page, url) {
54
  let finalCookieValue = "";
55
  let hasForcedNavigated = false;
56
 
 
57
  page.on('response', async resp => {
58
  try {
59
  const headers = resp.headers();
@@ -75,6 +99,7 @@ async function handleCloudflare(page, url) {
75
  await page.bringToFront();
76
  await page.goto(url, { waitUntil: "domcontentloaded", timeout: 60000 });
77
 
 
78
  const loop = setInterval(async () => {
79
  try {
80
  const title = await page.title();
@@ -82,6 +107,7 @@ async function handleCloudflare(page, url) {
82
  const currentTime = Date.now();
83
  const cookies = await page.cookies();
84
 
 
85
  const cfCookie = cookies.find(c => c.name === 'cf_clearance');
86
  if (cfCookie) {
87
  if (cookieFoundTime === 0) console.log(`[Cloudflare] Cookie found in storage.`);
@@ -89,9 +115,41 @@ async function handleCloudflare(page, url) {
89
  finalCookieValue = cfCookie.value;
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  const isChallengePage = title.includes("Just a moment") ||
93
  content.includes("challenge-platform") ||
94
- title.includes("Cloudflare");
 
95
 
96
  if (!isChallengePage && title.trim().length > 0) {
97
  clearInterval(loop);
@@ -100,6 +158,7 @@ async function handleCloudflare(page, url) {
100
  console.log(`[Cloudflare] Success! Page Title: ${title}`);
101
  resolve({
102
  status: "success",
 
103
  userAgent: ua,
104
  cookies_full: cookies,
105
  cookie: finalCookieValue,
@@ -108,24 +167,23 @@ async function handleCloudflare(page, url) {
108
  return;
109
  }
110
 
 
111
  if (cookieFoundTime > 0 && (currentTime - cookieFoundTime) > 8000 && !hasForcedNavigated) {
112
  console.log("[Cloudflare] Cookie found but stuck. Performing FORCE NAVIGATION...");
113
  hasForcedNavigated = true;
114
- await page.goto(url, {
115
- waitUntil: "domcontentloaded",
116
- timeout: 30000,
117
- referer: url
118
- }).catch(()=>{});
119
  return;
120
  }
121
 
122
- if (hasForcedNavigated && (currentTime - cookieFoundTime) > 25000) {
 
123
  clearInterval(loop);
124
  clearTimeout(timeout);
125
- console.log("[Cloudflare] Giving up waiting for title change. Returning valid cookie.");
126
  const ua = await page.evaluate(() => navigator.userAgent);
127
  resolve({
128
- status: "success",
 
129
  userAgent: ua,
130
  cookies_full: cookies,
131
  cookie: finalCookieValue,
@@ -134,6 +192,7 @@ async function handleCloudflare(page, url) {
134
  return;
135
  }
136
 
 
137
  const frames = page.frames();
138
  const challengeFrame = frames.find(f => f.url().includes("challenges.cloudflare.com") || f.url().includes("turnstile"));
139
 
@@ -141,31 +200,21 @@ async function handleCloudflare(page, url) {
141
  try {
142
  const checkbox = await challengeFrame.$("input[type='checkbox']");
143
  if (checkbox) {
144
- const boundingBox = await checkbox.boundingBox();
145
- if (boundingBox) {
146
- console.log("[Cloudflare] Target found. Moving mouse physically...");
147
-
148
- const x = boundingBox.x + boundingBox.width / 2 + (Math.random() - 0.5) * 5;
149
- const y = boundingBox.y + boundingBox.height / 2 + (Math.random() - 0.5) * 5;
150
-
151
  await page.mouse.move(x, y, { steps: 5 });
152
- await page.waitForTimeout(100 + Math.random() * 200);
153
  await page.mouse.down();
154
  await page.waitForTimeout(50 + Math.random() * 50);
155
  await page.mouse.up();
156
-
157
- console.log("[Cloudflare] Mouse Clicked at", x, y);
158
-
159
- await page.mouse.move(x + 100, y + 100, { steps: 10 });
160
  }
161
  } else {
162
- await challengeFrame.click('body', { delay: 50 }).catch(()=>{});
163
  }
164
  } catch(e) {}
165
  } else {
166
- try {
167
- await page.mouse.move(Math.floor(Math.random() * 500), Math.floor(Math.random() * 500));
168
- } catch (err) {}
169
  }
170
 
171
  } catch (e) {}
@@ -178,6 +227,7 @@ async function handleCloudflare(page, url) {
178
  });
179
  }
180
 
 
181
  async function handleTurnstile(page, url, siteKey) {
182
  return new Promise(async (resolve, reject) => {
183
  const timeout = setTimeout(() => reject(new Error("Timeout Turnstile")), 60000);
 
12
 
13
  async function createBrowser(proxy = null) {
14
  const options = {
15
+ headless: false, // WAJIB FALSE
16
  turnstile: true,
17
  args: [
18
  '--no-sandbox',
 
43
  return { browser, page };
44
  }
45
 
46
+ // FUNGSI BARU: VALIDASI INTERNAL
47
+ // Mengecek apakah cookie yang didapat benar-benar bisa menembus server
48
+ async function verifySession(page, url) {
49
+ return await page.evaluate(async (targetUrl) => {
50
+ try {
51
+ // Lakukan request GET ringan ke URL target
52
+ const res = await fetch(targetUrl, {
53
+ method: "GET",
54
+ credentials: "include" // Sertakan cookie yang ada di browser
55
+ });
56
+ return {
57
+ status: res.status,
58
+ url: res.url,
59
+ // Cek apakah masih dialihkan ke halaman challenge
60
+ is_challenge: res.url.includes("challenge") || res.status === 403 || res.status === 503
61
+ };
62
+ } catch (e) {
63
+ return { status: 0, is_challenge: true, error: e.message };
64
+ }
65
+ }, url);
66
+ }
67
+
68
  async function handleCloudflare(page, url) {
69
  return new Promise(async (resolve, reject) => {
70
+ // Timeout 120 Detik
71
  const timeout = setTimeout(() => reject(new Error("Timeout Cloudflare Bypass")), 120000);
72
 
73
  try {
 
77
  let finalCookieValue = "";
78
  let hasForcedNavigated = false;
79
 
80
+ // 1. LISTENER (Sniffer Cookie)
81
  page.on('response', async resp => {
82
  try {
83
  const headers = resp.headers();
 
99
  await page.bringToFront();
100
  await page.goto(url, { waitUntil: "domcontentloaded", timeout: 60000 });
101
 
102
+ // LOOP CHECKER
103
  const loop = setInterval(async () => {
104
  try {
105
  const title = await page.title();
 
107
  const currentTime = Date.now();
108
  const cookies = await page.cookies();
109
 
110
+ // Update Status Cookie
111
  const cfCookie = cookies.find(c => c.name === 'cf_clearance');
112
  if (cfCookie) {
113
  if (cookieFoundTime === 0) console.log(`[Cloudflare] Cookie found in storage.`);
 
115
  finalCookieValue = cfCookie.value;
116
  }
117
 
118
+ // ==========================================
119
+ // LOGIKA SUKSES BARU (VALIDASI REQUEST)
120
+ // ==========================================
121
+
122
+ // Jika kita punya cookie, coba validasi langsung ke server (Bypass Title Check)
123
+ if (finalCookieValue) {
124
+ const verification = await verifySession(page, url);
125
+
126
+ // Jika server merespon 200 OK dan bukan challenge url
127
+ if (verification.status === 200 && !verification.is_challenge) {
128
+ clearInterval(loop);
129
+ clearTimeout(timeout);
130
+
131
+ const ua = await page.evaluate(() => navigator.userAgent);
132
+ console.log(`[Cloudflare] ✅ VERIFIED SUCCESS! (Internal Fetch: 200 OK)`);
133
+ console.log(`[Cloudflare] Title might be stuck, but access is confirmed.`);
134
+
135
+ resolve({
136
+ status: "success",
137
+ verified: true, // Flag baru
138
+ userAgent: ua,
139
+ cookies_full: cookies,
140
+ cookie: finalCookieValue,
141
+ title: title, // Title mungkin masih "Attention Required", tapi itu tidak masalah
142
+ html_preview: "Content verified via internal fetch"
143
+ });
144
+ return;
145
+ }
146
+ }
147
+
148
+ // Fallback: Cek Title (Cara Lama)
149
  const isChallengePage = title.includes("Just a moment") ||
150
  content.includes("challenge-platform") ||
151
+ title.includes("Cloudflare") ||
152
+ title.includes("Attention Required");
153
 
154
  if (!isChallengePage && title.trim().length > 0) {
155
  clearInterval(loop);
 
158
  console.log(`[Cloudflare] Success! Page Title: ${title}`);
159
  resolve({
160
  status: "success",
161
+ verified: true,
162
  userAgent: ua,
163
  cookies_full: cookies,
164
  cookie: finalCookieValue,
 
167
  return;
168
  }
169
 
170
+ // 3. FORCE NAVIGATION (Anti-Loop)
171
  if (cookieFoundTime > 0 && (currentTime - cookieFoundTime) > 8000 && !hasForcedNavigated) {
172
  console.log("[Cloudflare] Cookie found but stuck. Performing FORCE NAVIGATION...");
173
  hasForcedNavigated = true;
174
+ await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000, referer: url }).catch(()=>{});
 
 
 
 
175
  return;
176
  }
177
 
178
+ // Timeout Giving Up
179
+ if (hasForcedNavigated && (currentTime - cookieFoundTime) > 30000) {
180
  clearInterval(loop);
181
  clearTimeout(timeout);
182
+ console.log("[Cloudflare] Giving up wait. Returning what we have.");
183
  const ua = await page.evaluate(() => navigator.userAgent);
184
  resolve({
185
+ status: "success", // Tetap return success karena cookie ada
186
+ verified: false,
187
  userAgent: ua,
188
  cookies_full: cookies,
189
  cookie: finalCookieValue,
 
192
  return;
193
  }
194
 
195
+ // 4. BIOMETRIC CLICKER (Tetap dipertahankan untuk Satoshi)
196
  const frames = page.frames();
197
  const challengeFrame = frames.find(f => f.url().includes("challenges.cloudflare.com") || f.url().includes("turnstile"));
198
 
 
200
  try {
201
  const checkbox = await challengeFrame.$("input[type='checkbox']");
202
  if (checkbox) {
203
+ const box = await checkbox.boundingBox();
204
+ if (box) {
205
+ const x = box.x + box.width / 2 + (Math.random() - 0.5) * 5;
206
+ const y = box.y + box.height / 2 + (Math.random() - 0.5) * 5;
 
 
 
207
  await page.mouse.move(x, y, { steps: 5 });
 
208
  await page.mouse.down();
209
  await page.waitForTimeout(50 + Math.random() * 50);
210
  await page.mouse.up();
 
 
 
 
211
  }
212
  } else {
213
+ await challengeFrame.click('body').catch(()=>{});
214
  }
215
  } catch(e) {}
216
  } else {
217
+ try { await page.mouse.move(Math.random()*500, Math.random()*500); } catch (err) {}
 
 
218
  }
219
 
220
  } catch (e) {}
 
227
  });
228
  }
229
 
230
+ // ... handleTurnstile TETAP SAMA ...
231
  async function handleTurnstile(page, url, siteKey) {
232
  return new Promise(async (resolve, reject) => {
233
  const timeout = setTimeout(() => reject(new Error("Timeout Turnstile")), 60000);