NAME commited on
Commit
4f05ffd
·
1 Parent(s): 654a02b

Pesan singkat tentang perubahan

Browse files
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:20-bullseye
2
+
3
+ # Install ALL dependencies untuk OpenCV + Chrome
4
+ RUN apt update && apt install -y \
5
+ wget gnupg ca-certificates xvfb \
6
+ fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
7
+ libatk1.0-0 libxss1 libnss3 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
8
+ python3 make g++ pkg-config cmake \
9
+ libcairo2-dev libjpeg-dev libpng-dev libgif-dev librsvg2-dev \
10
+ libopencv-dev \
11
+ && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
12
+ && apt install -y ./google-chrome-stable_current_amd64.deb \
13
+ && rm google-chrome-stable_current_amd64.deb \
14
+ && apt clean
15
+
16
+ WORKDIR /app
17
+
18
+ RUN mkdir -p /app/endpoints && \
19
+ mkdir -p /app/cache
20
+
21
+ COPY package*.json ./
22
+
23
+ # Install OpenCV dengan build from source
24
+ RUN npm install
25
+
26
+ COPY . .
27
+
28
+ EXPOSE 7860
29
+
30
+ CMD rm -f /tmp/.X99-lock && \
31
+ Xvfb :99 -screen 0 1024x768x24 & \
32
+ export DISPLAY=:99 && \
33
+ npm start
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Limit
3
- emoji: 📊
4
- colorFrom: red
5
- colorTo: gray
6
  sdk: docker
7
- pinned: false
 
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Khususan Indra
3
+ emoji: 🤣
4
+ colorFrom: blue
5
+ colorTo: yellow
6
  sdk: docker
7
+ sdk_version: 6.0.0
8
+ license: apache-2.0
9
+ short_description: antibot ai
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
api_test.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import httpx
3
+
4
+ async def main():
5
+ async with httpx.AsyncClient(timeout=30.0) as client:
6
+ resp1 = await client.post(
7
+ "http://localhost:8080/cloudflare",
8
+ json={
9
+ "domain": "https://olamovies.watch/generate",
10
+ "mode": "iuam",
11
+ },
12
+ )
13
+ print(resp1.json())
14
+
15
+ resp2 = await client.post(
16
+ "http://localhost:8080/cloudflare",
17
+ json={
18
+ "domain": "https://lksfy.com/",
19
+ "siteKey": "0x4AAAAAAA49NnPZwQijgRoi",
20
+ "mode": "turnstile",
21
+ },
22
+ )
23
+ print(resp2.json())
24
+
25
+ if __name__ == "__main__":
26
+ asyncio.run(main())
cache/cache.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "{\"domain\":\"https://v2links.org\",\"mode\":\"iuam\"}": {
3
+ "timestamp": 1758616160392,
4
+ "value": {
5
+ "cf_clearance": "qqs5f4MpFMgA0v78Qmh_HYDWoKhbwqlQ57bTW5KeIr8-1758616161-1.2.1.1-D5PdpmheHl.26ssIRKQBsXzPtPPkSXntEZ_H9FUJVt7MMTS_BEE8iH.E48MDzKtFBLwZqRYxE_1GLo1gj3ChXrwatOGEJcmGRUwavy2qvGgUPizn7qufd.sW0ULfhaRO7Gz_H_eO1TU3iEqCzltEUDNk0SviKRFkF8ozbvJ91MW_qmO.qrjQorbu_jxcgJv5BHs6rTNOitWtVDAmYMDukASq0viHXIUAIvTM.LIfQ88",
6
+ "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36",
7
+ "elapsed_time": 5.028
8
+ }
9
+ }
10
+ }
endpoints/antibot.js ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { extractTextFromImage, uploadImageToHosting } = require('./imageProcessor');
4
+
5
+ // Map angka kata -> digit
6
+ const NUMBER_WORDS = {
7
+ 'nol': '0', 'satu': '1', 'dua': '2', 'tiga': '3', 'empat': '4', 'lima': '5',
8
+ 'enam': '6', 'tujuh': '7', 'delapan': '8', 'sembilan': '9', 'sepuluh': '10',
9
+ 'sebelas': '11', 'belas': '', 'puluh': '', 'ratus': '', 'ribu': ''
10
+ };
11
+
12
+ // Simple leet replacements
13
+ const LEET_MAP = {
14
+ '4': 'a', '@': 'a', '8': 'b', '3': 'e', '6': 'g', '1': 'i', '!': 'i', '0': 'o',
15
+ '5': 's', '$': 's', '7': 't', '+': 't', '2': 'z'
16
+ };
17
+
18
+ function safeString(s) {
19
+ return (s || '').toString();
20
+ }
21
+
22
+ async function extractTextFromBuffer(imageBuffer) {
23
+ try {
24
+ if (!imageBuffer) throw new Error('No image buffer provided');
25
+ if (!Buffer.isBuffer(imageBuffer)) throw new Error('extractTextFromBuffer expects a Buffer');
26
+
27
+ console.log('🖼️ DEBUG extractTextFromBuffer: Received buffer, size:', imageBuffer.length, 'bytes');
28
+
29
+ const result = await extractTextFromImage(imageBuffer);
30
+ console.log('✅ DEBUG extractTextFromBuffer: Hasil ekstraksi:', result);
31
+ return result;
32
+ } catch (error) {
33
+ console.error('❌ DEBUG extractTextFromBuffer Error:', error.message);
34
+ return { status: false, response: 'Gagal memproses gambar' };
35
+ }
36
+ }
37
+
38
+ function removeAccents(str) {
39
+ return safeString(str).normalize('NFD').replace(/[\u0300-\u036f]/g, '');
40
+ }
41
+
42
+ function applyLeetMap(str) {
43
+ let out = '';
44
+ for (const ch of str) {
45
+ out += (LEET_MAP[ch] !== undefined) ? LEET_MAP[ch] : ch;
46
+ }
47
+ return out;
48
+ }
49
+
50
+ function wordsToNumbers(str) {
51
+ // Very simple conversion for single-word numbers in Indonesian (e.g., "tujuh" -> "7")
52
+ const tokens = str.split(/\s+/);
53
+ return tokens.map(t => {
54
+ const low = t.toLowerCase();
55
+ return NUMBER_WORDS[low] !== undefined ? NUMBER_WORDS[low] : t;
56
+ }).join(' ');
57
+ }
58
+
59
+ function normalizeText(text) {
60
+ const original = safeString(text);
61
+ let normalized = removeAccents(original);
62
+ normalized = normalized.toLowerCase();
63
+ normalized = applyLeetMap(normalized);
64
+ // keep letters, numbers and spaces only
65
+ normalized = normalized.replace(/[^a-z0-9\s]/g, ' ').replace(/\s+/g, ' ').trim();
66
+ // map simple number words
67
+ normalized = wordsToNumbers(normalized);
68
+ console.log(`🔤 DEBUG normalizeText: "${original}" -> "${normalized}"`);
69
+ return normalized;
70
+ }
71
+
72
+ // Levenshtein distance for fuzzy matching
73
+ function levenshtein(a = '', b = '') {
74
+ const alen = a.length, blen = b.length;
75
+ if (alen === 0) return blen;
76
+ if (blen === 0) return alen;
77
+ const matrix = Array.from({ length: alen + 1 }, () => new Array(blen + 1));
78
+ for (let i = 0; i <= alen; i++) matrix[i][0] = i;
79
+ for (let j = 0; j <= blen; j++) matrix[0][j] = j;
80
+ for (let i = 1; i <= alen; i++) {
81
+ for (let j = 1; j <= blen; j++) {
82
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
83
+ matrix[i][j] = Math.min(
84
+ matrix[i - 1][j] + 1,
85
+ matrix[i][j - 1] + 1,
86
+ matrix[i - 1][j - 1] + cost
87
+ );
88
+ }
89
+ }
90
+ return matrix[alen][blen];
91
+ }
92
+
93
+ function similarity(a, b) {
94
+ a = safeString(a);
95
+ b = safeString(b);
96
+ if (a === b) return 1;
97
+ const dist = levenshtein(a, b);
98
+ const maxLen = Math.max(a.length, b.length);
99
+ return maxLen === 0 ? 1 : 1 - (dist / maxLen);
100
+ }
101
+
102
+ function tryEvaluateMathExpression(s) {
103
+ // allow simple expressions like "3+4", " 7 - 2 ", "2 * (3+1)"
104
+ try {
105
+ const cleaned = s.replace(/[^0-9+\-*/().\s]/g, '');
106
+ if (!/[0-9]/.test(cleaned)) return null;
107
+ // eslint-disable-next-line no-new-func
108
+ const val = Function(`"use strict"; return (${cleaned});`)();
109
+ if (typeof val === 'number' && isFinite(val)) return String(val);
110
+ return null;
111
+ } catch {
112
+ return null;
113
+ }
114
+ }
115
+
116
+ // compare OCR value with expected soal (question) with multiple heuristics
117
+ function isValueMatch(value, soal, options = {}) {
118
+ const { fuzzyThreshold = 0.75 } = options;
119
+ console.log('🔍 DEBUG isValueMatch: Value="%s", Soal="%s"', value, soal);
120
+ if (!value && !soal) return false;
121
+
122
+ const vNorm = normalizeText(safeString(value));
123
+ const sNorm = normalizeText(safeString(soal));
124
+
125
+ // exact match
126
+ if (vNorm === sNorm) {
127
+ console.log('✅ DEBUG exact match');
128
+ return true;
129
+ }
130
+
131
+ // try math evaluation for both sides
132
+ const vMath = tryEvaluateMathExpression(vNorm);
133
+ const sMath = tryEvaluateMathExpression(sNorm);
134
+ if (vMath !== null && sMath !== null && vMath === sMath) {
135
+ console.log('✅ DEBUG math match:', vMath);
136
+ return true;
137
+ }
138
+ if (vMath !== null && sMath === null && vMath === sNorm) {
139
+ console.log('✅ DEBUG math->soal match:', vMath);
140
+ return true;
141
+ }
142
+ if (sMath !== null && vMath === null && sMath === vNorm) {
143
+ console.log('✅ DEBUG soal->math match:', sMath);
144
+ return true;
145
+ }
146
+
147
+ // numeric comparison if either is numeric
148
+ const vNum = parseFloat(vNorm);
149
+ const sNum = parseFloat(sNorm);
150
+ if (!isNaN(vNum) && !isNaN(sNum) && Math.abs(vNum - sNum) < 1e-9) {
151
+ console.log('✅ DEBUG numeric equal');
152
+ return true;
153
+ }
154
+
155
+ // fuzzy text similarity
156
+ const sim = similarity(vNorm, sNorm);
157
+ console.log('📊 DEBUG Similarity:', sim);
158
+ if (sim >= fuzzyThreshold) {
159
+ console.log('✅ DEBUG fuzzy match (threshold=', fuzzyThreshold, ')');
160
+ return true;
161
+ }
162
+
163
+ // partial match: one contains the other with decent length
164
+ if (vNorm && sNorm) {
165
+ if (vNorm.includes(sNorm) || sNorm.includes(vNorm)) {
166
+ const longer = Math.max(vNorm.length, sNorm.length);
167
+ if (longer >= 3) {
168
+ console.log('✅ DEBUG partial contains match');
169
+ return true;
170
+ }
171
+ }
172
+ }
173
+
174
+ console.log('❌ DEBUG: No match found');
175
+ return false;
176
+ }
177
+
178
+ function mapAnswer(soalArray, jawaban, botIndex) {
179
+ console.log(`🤖 DEBUG mapAnswer: Bot ${botIndex}, Jawaban: "${jawaban}"`);
180
+ // jawaban can be object or string; normalize to string for now
181
+ if (jawaban && typeof jawaban === 'object' && jawaban.response) {
182
+ return jawaban.response;
183
+ }
184
+ return jawaban;
185
+ }
186
+
187
+ // --- Integrated helper from userscript: countPairs ---
188
+ function countPairs(s1 = '', s2 = '') {
189
+ s1 = safeString(s1).toLowerCase().replace(/[^a-z]/g, '');
190
+ s2 = safeString(s2).toLowerCase().replace(/[^a-z]/g, '');
191
+ const n1 = s1.length, n2 = s2.length;
192
+ const freq1 = Array(26).fill(0);
193
+ const freq2 = Array(26).fill(0);
194
+ for (let i = 0; i < n1; i++) freq1[s1.charCodeAt(i) - 97] = (freq1[s1.charCodeAt(i) - 97] || 0) + 1;
195
+ for (let i = 0; i < n2; i++) freq2[s2.charCodeAt(i) - 97] = (freq2[s2.charCodeAt(i) - 97] || 0) + 1;
196
+ let count = 0;
197
+ for (let i = 0; i < 26; i++) count += Math.min(freq1[i], freq2[i]);
198
+ return count;
199
+ }
200
+
201
+ // Export utilities
202
+ module.exports = {
203
+ extractTextFromBuffer,
204
+ mapAnswer,
205
+ normalizeText,
206
+ isValueMatch,
207
+ levenshtein,
208
+ similarity,
209
+ NUMBER_WORDS,
210
+ LEET_MAP,
211
+ countPairs
212
+ };
endpoints/cloudflare.js ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function cloudflare(data, page) {
2
+ return new Promise(async (resolve, reject) => {
3
+ if (!data.domain) return reject(new Error("Missing domain parameter"))
4
+
5
+ const startTime = Date.now()
6
+ let isResolved = false
7
+ let userAgent = null
8
+
9
+ const cl = setTimeout(() => {
10
+ if (!isResolved) {
11
+ isResolved = true
12
+ const elapsedTime = (Date.now() - startTime) / 1000
13
+ resolve({
14
+ cf_clearance: null,
15
+ user_agent: userAgent,
16
+ elapsed_time: elapsedTime,
17
+ })
18
+ }
19
+ }, 20000)
20
+
21
+ try {
22
+ if (data.proxy?.username && data.proxy?.password) {
23
+ await page.authenticate({
24
+ username: data.proxy.username,
25
+ password: data.proxy.password,
26
+ })
27
+ }
28
+
29
+ page.removeAllListeners("request")
30
+ page.removeAllListeners("response")
31
+ await page.setRequestInterception(true)
32
+
33
+ page.on("request", async (req) => {
34
+ try {
35
+ await req.continue()
36
+ } catch (_) {}
37
+ })
38
+
39
+ page.on("response", async (res) => {
40
+ try {
41
+ const url = res.url()
42
+ if (url.includes("/cdn-cgi/challenge-platform/")) {
43
+ const headers = res.headers()
44
+ if (headers["set-cookie"]) {
45
+ const match = headers["set-cookie"].match(/cf_clearance=([^;]+)/)
46
+ if (match) {
47
+ const cf_clearance = match[1]
48
+ const userAgent = (await res.request().headers())["user-agent"]
49
+ const elapsedTime = (Date.now() - startTime) / 1000
50
+
51
+ if (!isResolved) {
52
+ isResolved = true
53
+ clearTimeout(cl)
54
+
55
+ resolve({
56
+ cf_clearance,
57
+ user_agent: userAgent,
58
+ elapsed_time: elapsedTime,
59
+ })
60
+ }
61
+ }
62
+ }
63
+ }
64
+ } catch (_) {}
65
+ })
66
+
67
+ await page.goto(data.domain, { waitUntil: "domcontentloaded" })
68
+ userAgent = await page.evaluate(() => navigator.userAgent)
69
+ } catch (err) {
70
+ if (!isResolved) {
71
+ isResolved = true
72
+ clearTimeout(cl)
73
+ reject(err)
74
+ }
75
+ }
76
+ })
77
+ }
78
+
79
+ module.exports = cloudflare
endpoints/imageProcessor ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const fs = require('fs');
2
+ const https = require('https');
3
+
4
+ async function extractTextFromImage(imageBuffer) {
5
+ console.log('[DEBUG] extractTextFromImage: Starting image text extraction');
6
+ console.log('[DEBUG] Image buffer size:', imageBuffer.length, 'bytes');
7
+
8
+ return new Promise((resolve, reject) => {
9
+ const base64Image = imageBuffer.toString('base64');
10
+ console.log('[DEBUG] Base64 image length:', base64Image.length);
11
+
12
+ const requestData = JSON.stringify({
13
+ "contents": [
14
+ {
15
+ "parts": [
16
+ {
17
+ "inline_data": {
18
+ "mime_type": "image/png",
19
+ "data": base64Image
20
+ }
21
+ },
22
+ {
23
+ "text": "Berikan text yang ada di gambar ini saja, tidak ada informasi lain cukup yang ada di gambar saja, jangan ada text lain kalo bukan dari gambar nya."
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ });
29
+
30
+ console.log('[DEBUG] Request data prepared, length:', requestData.length);
31
+
32
+ const options = {
33
+ hostname: 'generativelanguage.googleapis.com',
34
+ path: '/v1beta/models/gemini-2.5-flash-lite:generateContent',
35
+ method: 'POST',
36
+ headers: {
37
+ 'x-goog-api-key': 'AIzaSyB3-2egs0udKCDX_F7I58uVRAwv7OUX1G8',
38
+ 'Content-Type': 'application/json',
39
+ 'Content-Length': Buffer.byteLength(requestData)
40
+ }
41
+ };
42
+
43
+ console.log('[DEBUG] Making request to Gemini API...');
44
+
45
+ const req = https.request(options, (res) => {
46
+ console.log('[DEBUG] API Response status:', res.statusCode);
47
+ console.log('[DEBUG] API Response headers:', res.headers);
48
+
49
+ let data = '';
50
+
51
+ res.on('data', (chunk) => {
52
+ data += chunk;
53
+ });
54
+
55
+ res.on('end', () => {
56
+ console.log('[DEBUG] Received all response data');
57
+ console.log('[DEBUG] Response data length:', data.length);
58
+
59
+ try {
60
+ const response = JSON.parse(data);
61
+ console.log('[DEBUG] Response parsed successfully');
62
+
63
+ if (response.candidates && response.candidates[0] && response.candidates[0].content) {
64
+ const text = response.candidates[0].content.parts[0].text;
65
+ console.log('[DEBUG] ✅ Text extracted:', text);
66
+ resolve({ status: true, response: text });
67
+ } else {
68
+ console.log('[DEBUG] ❌ No text found in response');
69
+ console.log('[DEBUG] Response structure:', JSON.stringify(response, null, 2));
70
+
71
+ if (response.error) {
72
+ console.log('[DEBUG] API Error:', response.error);
73
+ }
74
+
75
+ resolve({ status: false, response: 'Tidak ada teks yang ditemukan' });
76
+ }
77
+ } catch (error) {
78
+ console.error('[DEBUG] ❌ JSON parse error:', error);
79
+ console.log('[DEBUG] Raw response data:', data);
80
+ reject(error);
81
+ }
82
+ });
83
+ });
84
+
85
+ req.on('error', (error) => {
86
+ console.error('[DEBUG] ❌ Request error:', error);
87
+ reject(error);
88
+ });
89
+
90
+ req.on('timeout', () => {
91
+ console.error('[DEBUG] ❌ Request timeout');
92
+ req.destroy();
93
+ reject(new Error('Request timeout'));
94
+ });
95
+
96
+ req.setTimeout(30000); // 30 second timeout
97
+
98
+ console.log('[DEBUG] Sending request...');
99
+ req.write(requestData);
100
+ req.end();
101
+ console.log('[DEBUG] Request sent');
102
+ });
103
+ }
104
+
105
+ module.exports = { extractTextFromImage };
endpoints/turnstile.js ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function turnstile({ domain, proxy, siteKey }, page) {
2
+ if (!domain) throw new Error("Missing domain parameter");
3
+ if (!siteKey) throw new Error("Missing siteKey parameter");
4
+
5
+ const timeout = global.timeOut || 60000;
6
+ let isResolved = false;
7
+
8
+ const cl = setTimeout(async () => {
9
+ if (!isResolved) {
10
+ throw new Error("Timeout Error");
11
+ }
12
+ }, timeout);
13
+
14
+ try {
15
+ if (proxy?.username && proxy?.password) {
16
+ await page.authenticate({
17
+ username: proxy.username,
18
+ password: proxy.password,
19
+ });
20
+ }
21
+
22
+ const htmlContent = `
23
+ <!DOCTYPE html>
24
+ <html lang="en">
25
+ <body>
26
+ <div class="turnstile"></div>
27
+ <script src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback" defer></script>
28
+ <script>
29
+ window.onloadTurnstileCallback = function () {
30
+ turnstile.render('.turnstile', {
31
+ sitekey: '${siteKey}',
32
+ callback: function (token) {
33
+ var c = document.createElement('input');
34
+ c.type = 'hidden';
35
+ c.name = 'cf-response';
36
+ c.value = token;
37
+ document.body.appendChild(c);
38
+ },
39
+ });
40
+ };
41
+ </script>
42
+ </body>
43
+ </html>
44
+ `;
45
+
46
+ await page.setRequestInterception(true);
47
+ page.removeAllListeners("request");
48
+ page.on("request", async (request) => {
49
+ if ([domain, domain + "/"].includes(request.url()) && request.resourceType() === "document") {
50
+ await request.respond({
51
+ status: 200,
52
+ contentType: "text/html",
53
+ body: htmlContent,
54
+ });
55
+ } else {
56
+ await request.continue();
57
+ }
58
+ });
59
+
60
+ await page.goto(domain, { waitUntil: "domcontentloaded" });
61
+
62
+ await page.waitForSelector('[name="cf-response"]', { timeout });
63
+
64
+ const token = await page.evaluate(() => {
65
+ try {
66
+ return document.querySelector('[name="cf-response"]').value;
67
+ } catch {
68
+ return null;
69
+ }
70
+ });
71
+
72
+ isResolved = true;
73
+ clearTimeout(cl);
74
+
75
+ if (!token || token.length < 10) throw new Error("Failed to get token");
76
+ return token;
77
+
78
+ } catch (e) {
79
+ clearTimeout(cl);
80
+ throw e;
81
+ }
82
+ }
83
+
84
+ module.exports = turnstile;
index.js ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const { connect } = require("puppeteer-real-browser");
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const app = express();
7
+ const port = process.env.PORT || 7860;
8
+ const authToken = process.env.authToken || null;
9
+ const domain = process.env.DOMAIN || `https://forgets-Me12.hf.space`;
10
+
11
+ global.browserLimit = Number(process.env.browserLimit) || 100;
12
+ global.timeOut = Number(process.env.timeOut) || 60000;
13
+
14
+ const CACHE_DIR = path.join(__dirname, "cache");
15
+ const CACHE_FILE = path.join(CACHE_DIR, "cache.json");
16
+ const CACHE_TTL = 5 * 60 * 1000;
17
+
18
+ function loadCache() {
19
+ if (!fs.existsSync(CACHE_FILE)) return {};
20
+ try {
21
+ return JSON.parse(fs.readFileSync(CACHE_FILE, 'utf-8'));
22
+ } catch {
23
+ return {};
24
+ }
25
+ }
26
+
27
+ function saveCache(cache) {
28
+ if (!fs.existsSync(CACHE_DIR)) {
29
+ fs.mkdirSync(CACHE_DIR, { recursive: true });
30
+ }
31
+ fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2), 'utf-8');
32
+ }
33
+
34
+ function readCache(key) {
35
+ const cache = loadCache();
36
+ const entry = cache[key];
37
+ if (entry && Date.now() - entry.timestamp < CACHE_TTL) {
38
+ return entry.value;
39
+ }
40
+ return null;
41
+ }
42
+
43
+ function writeCache(key, value) {
44
+ const cache = loadCache();
45
+ cache[key] = { timestamp: Date.now(), value };
46
+ saveCache(cache);
47
+ }
48
+
49
+ app.use(express.json({ limit: "50mb" }));
50
+ app.use(express.urlencoded({ extended: true, limit: "50mb" }));
51
+
52
+ app.get("/", (req, res) => {
53
+ res.json({
54
+ message: "Server is running!",
55
+ domain: domain,
56
+ endpoints: {
57
+ cloudflare: `${domain}/cloudflare`,
58
+ antibot: `${domain}/antibot`
59
+ },
60
+ status: {
61
+ browserLimit: global.browserLimit,
62
+ timeOut: global.timeOut,
63
+ authRequired: authToken !== null
64
+ }
65
+ });
66
+ });
67
+
68
+ if (process.env.NODE_ENV !== 'development') {
69
+ let server = app.listen(port, () => {
70
+ console.log(`Server running on port ${port}`);
71
+ console.log(`Domain: ${domain}`);
72
+ console.log(`Auth required: ${authToken !== null}`);
73
+ });
74
+ try {
75
+ server.timeout = global.timeOut;
76
+ } catch {}
77
+ }
78
+
79
+ async function createBrowser(proxyServer = null) {
80
+ const connectOptions = {
81
+ headless: false,
82
+ turnstile: true,
83
+ connectOption: { defaultViewport: null },
84
+ disableXvfb: false,
85
+ };
86
+ if (proxyServer) connectOptions.args = [`--proxy-server=${proxyServer}`];
87
+
88
+ const { browser } = await connect(connectOptions);
89
+ const [page] = await browser.pages();
90
+
91
+ await page.goto('about:blank');
92
+ await page.setRequestInterception(true);
93
+ page.on('request', (req) => {
94
+ const type = req.resourceType();
95
+ if (["image", "stylesheet", "font", "media"].includes(type)) req.abort();
96
+ else req.continue();
97
+ });
98
+
99
+ return { browser, page };
100
+ }
101
+
102
+ const turnstile = require('./endpoints/turnstile');
103
+ const cloudflare = require('./endpoints/cloudflare');
104
+ const antibot = require('./endpoints/antibot');
105
+
106
+ app.post('/cloudflare', async (req, res) => {
107
+ const data = req.body;
108
+ if (!data || typeof data.mode !== 'string')
109
+ return res.status(400).json({ message: 'Bad Request: missing or invalid mode' });
110
+
111
+ if (global.browserLimit <= 0)
112
+ return res.status(429).json({ message: 'Too Many Requests' });
113
+
114
+ let cacheKey, cached;
115
+ if (data.mode === "iuam") {
116
+ cacheKey = JSON.stringify(data);
117
+ cached = readCache(cacheKey);
118
+ if (cached) return res.status(200).json({ ...cached, cached: true });
119
+ }
120
+
121
+ global.browserLimit--;
122
+ let result, browser;
123
+
124
+ try {
125
+ const proxyServer = data.proxy ? `${data.proxy.hostname}:${data.proxy.port}` : null;
126
+ const ctx = await createBrowser(proxyServer);
127
+ browser = ctx.browser;
128
+ const page = ctx.page;
129
+
130
+ await page.goto('about:blank');
131
+
132
+ switch (data.mode) {
133
+ case "turnstile":
134
+ result = await turnstile(data, page).then(t => ({ token: t }));
135
+ break;
136
+
137
+ case "iuam":
138
+ result = await cloudflare(data, page).then(r => ({ ...r }));
139
+ writeCache(cacheKey, result);
140
+ break;
141
+
142
+ case "antibot":
143
+ result = await antibot(data);
144
+ break;
145
+
146
+ default:
147
+ result = { code: 400, message: 'Invalid mode' };
148
+ }
149
+ } catch (err) {
150
+ result = { code: 500, message: err.message };
151
+ } finally {
152
+ if (browser) try { await browser.close(); } catch {}
153
+ global.browserLimit++;
154
+ }
155
+
156
+ res.status(result.code ?? 200).json(result);
157
+ });
158
+
159
+ app.post("/antibot", async (req, res) => {
160
+ const data = req.body;
161
+
162
+ if (!data || !data.main || !Array.isArray(data.bots))
163
+ return res.status(400).json({ message: "Invalid body" });
164
+
165
+ try {
166
+ const result = await antibot(data);
167
+ res.json(result);
168
+ } catch (err) {
169
+ res.status(500).json({ message: err.message });
170
+ }
171
+ });
172
+
173
+ app.use((req, res) => {
174
+ res.status(404).json({ message: 'Not Found' });
175
+ });
176
+
177
+ if (process.env.NODE_ENV === 'development') {
178
+ module.exports = app;
179
+ }
package.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "cf-bypass",
3
+ "version": "1.0",
4
+ "description": "get the cf_clearance cookie from any website",
5
+ "scripts": {
6
+ "start": "node index.js",
7
+ "dev": "nodemon index.js"
8
+ },
9
+ "dependencies": {
10
+ "express": "^5.1.0",
11
+ "canvas": "^2.11.2",
12
+ "sharp": "^0.32.0",
13
+ "puppeteer-real-browser": "^1.4.0",
14
+ "axios": "^1.9.0",
15
+ "child_process": "*",
16
+ "tesseract.js": "^5.0.3",
17
+ "jimp": "^0.22.10"
18
+ },
19
+ "devDependencies": {
20
+ "nodemon": "^3.1.10"
21
+ }
22
+ }