fourmovie commited on
Commit
613f200
·
1 Parent(s): 14c6bc6
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:20-slim
2
+
3
+ RUN apt update && apt install -y \
4
+ wget gnupg ca-certificates xvfb \
5
+ fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
6
+ libatk1.0-0 libxss1 libnss3 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
7
+ && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
8
+ && apt install -y ./google-chrome-stable_current_amd64.deb \
9
+ && rm google-chrome-stable_current_amd64.deb
10
+
11
+ WORKDIR /app
12
+
13
+ RUN mkdir -p /app/endpoints && \
14
+ mkdir -p /app/cache
15
+
16
+ COPY package*.json ./
17
+ RUN npm install
18
+
19
+ COPY . .
20
+
21
+ EXPOSE 7860
22
+
23
+ CMD rm -f /tmp/.X99-lock && \
24
+ Xvfb :99 -screen 0 1024x768x24 & \
25
+ export DISPLAY=:99 && \
26
+ npm start
README.md CHANGED
@@ -3,9 +3,8 @@ title: Captcha
3
  emoji: 🐨
4
  colorFrom: green
5
  colorTo: red
6
- sdk: gradio
7
  sdk_version: 5.49.1
8
- app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
  short_description: bypass solver
 
3
  emoji: 🐨
4
  colorFrom: green
5
  colorTo: red
6
+ sdk: docker
7
  sdk_version: 5.49.1
 
8
  pinned: false
9
  license: apache-2.0
10
  short_description: bypass solver
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/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/recaptchav3.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function recaptchav3({ domain, siteKey, proxy, action = 'homepage' }, 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
+ <head>
26
+ <script src="https://www.google.com/recaptcha/api.js?render=${siteKey}"></script>
27
+ </head>
28
+ <body>
29
+ <input type="hidden" id="recaptchav3Token" name="recaptchav3">
30
+ <script>
31
+ grecaptcha.ready(function() {
32
+ grecaptcha.execute("${siteKey}", {action: "${action}"}).then(function(token) {
33
+ document.getElementById("recaptchav3Token").value = token;
34
+ });
35
+ });
36
+ </script>
37
+ </body>
38
+ </html>
39
+ `;
40
+
41
+ await page.setRequestInterception(true);
42
+ page.removeAllListeners("request");
43
+ page.on("request", async (request) => {
44
+ if ([domain, domain + "/"].includes(request.url()) && request.resourceType() === "document") {
45
+ await request.respond({
46
+ status: 200,
47
+ contentType: "text/html",
48
+ body: htmlContent,
49
+ });
50
+ } else {
51
+ await request.continue();
52
+ }
53
+ });
54
+
55
+ await page.goto(domain, { waitUntil: "domcontentloaded" });
56
+
57
+ await page.waitForFunction(() => {
58
+ const tokenInput = document.getElementById("recaptchav3Token");
59
+ return tokenInput && tokenInput.value.length > 10;
60
+ }, { timeout });
61
+
62
+ const token = await page.evaluate(() => {
63
+ try {
64
+ return document.getElementById("recaptchav3Token").value;
65
+ } catch {
66
+ return null;
67
+ }
68
+ });
69
+
70
+ isResolved = true;
71
+ clearTimeout(cl);
72
+
73
+ if (!token || token.length < 10) throw new Error("Failed to get token");
74
+ return token;
75
+
76
+ } catch (e) {
77
+ clearTimeout(cl);
78
+ throw e;
79
+ }
80
+ }
81
+
82
+ module.exports = recaptchav3;
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,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express')
2
+ const { connect } = require("puppeteer-real-browser")
3
+ const fs = require("fs")
4
+ const path = require("path")
5
+ const os = require('os')
6
+
7
+ const app = express()
8
+ const port = process.env.PORT || 7860
9
+ const authToken = process.env.authToken || null
10
+ const DOMAIN = 'https://rezaharis-captcha.hf.space'
11
+
12
+ global.browserLimit = Number(process.env.browserLimit) || 20
13
+ global.timeOut = Number(process.env.timeOut) || 60000
14
+
15
+ let hitCount = 0
16
+ const startTime = Date.now()
17
+
18
+ const CACHE_DIR = path.join(__dirname, "cache")
19
+ const CACHE_FILE = path.join(CACHE_DIR, "cache.json")
20
+ const CACHE_TTL = 5 * 60 * 1000
21
+
22
+ function loadCache() {
23
+ if (!fs.existsSync(CACHE_FILE)) return {}
24
+ try {
25
+ return JSON.parse(fs.readFileSync(CACHE_FILE, "utf-8"))
26
+ } catch {
27
+ return {}
28
+ }
29
+ }
30
+
31
+ function saveCache(cache) {
32
+ if (!fs.existsSync(CACHE_DIR)) {
33
+ fs.mkdirSync(CACHE_DIR, { recursive: true })
34
+ }
35
+ fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2), "utf-8")
36
+ }
37
+
38
+ function readCache(key) {
39
+ const cache = loadCache()
40
+ const entry = cache[key]
41
+ if (entry && Date.now() - entry.timestamp < CACHE_TTL) {
42
+ return entry.value
43
+ }
44
+ return null
45
+ }
46
+
47
+ function writeCache(key, value) {
48
+ const cache = loadCache()
49
+ cache[key] = { timestamp: Date.now(), value }
50
+ saveCache(cache)
51
+ }
52
+
53
+ function getRuntimeInfo() {
54
+ const mem = process.memoryUsage()
55
+ const totalMem = os.totalmem()
56
+ const usedMem = totalMem - os.freemem()
57
+
58
+ return {
59
+ os: os.type(),
60
+ platform: os.platform(),
61
+ architecture: os.arch(),
62
+ cpuCount: os.cpus().length,
63
+ uptime: `${process.uptime().toFixed(2)} seconds`,
64
+ memoryUsage: `${Math.round(usedMem / 1024 / 1024)} MB used of ${Math.round(totalMem / 1024 / 1024)} MB`
65
+ }
66
+ }
67
+
68
+ app.use(express.json())
69
+ app.use(express.urlencoded({ extended: true }))
70
+
71
+ app.get('/', (req, res) => {
72
+ hitCount++
73
+ res.json({
74
+ author: "fourstore",
75
+ hit: hitCount,
76
+ message: "Gunakan: curl -X POST https://rezaharis-cf.hf.space/cloudflare -H 'Content-Type: application/json' -d '{\"mode\":\"turnstile\",\"sitekey\":\"xxx\",\"url\":\"https://example.com\"}'",
77
+ runtime: getRuntimeInfo()
78
+ })
79
+ })
80
+
81
+ if (process.env.NODE_ENV !== 'development') {
82
+ let server = app.listen(port, () => {
83
+ console.log(`Server running on port ${port}`)
84
+ console.log(`Domain: ${DOMAIN}`)
85
+ })
86
+ try {
87
+ server.timeout = global.timeOut
88
+ } catch {}
89
+ }
90
+
91
+ async function createBrowser(proxyServer = null) {
92
+ const connectOptions = {
93
+ headless: false,
94
+ turnstile: true,
95
+ connectOption: { defaultViewport: null },
96
+ disableXvfb: false,
97
+ }
98
+
99
+ if (proxyServer) {
100
+ connectOptions.args = [`--proxy-server=${proxyServer}`]
101
+ }
102
+
103
+ const { browser } = await connect(connectOptions)
104
+
105
+ const pages = await browser.pages()
106
+ const page = pages[0]
107
+
108
+ await page.goto('about:blank')
109
+
110
+ await page.setRequestInterception(true)
111
+ page.on('request', (req) => {
112
+ const type = req.resourceType()
113
+ if (["image", "stylesheet", "font", "media"].includes(type)) {
114
+ req.abort()
115
+ } else {
116
+ req.continue()
117
+ }
118
+ })
119
+
120
+ return { browser, page }
121
+ }
122
+
123
+ const turnstile = require('./endpoints/turnstile')
124
+ const cloudflare = require('./endpoints/cloudflare')
125
+ const recaptchav3 = require('./endpoints/recaptchav3')
126
+
127
+ app.post('/cloudflare', async (req, res) => {
128
+ hitCount++
129
+ const data = req.body
130
+
131
+ if (!data || !data.mode) {
132
+ return res.status(400).json({
133
+ author: "fourstore",
134
+ hit: hitCount,
135
+ message: "Parameter 'mode' diperlukan",
136
+ runtime: getRuntimeInfo(),
137
+ status: "failed"
138
+ })
139
+ }
140
+
141
+ if (!data.sitekey || !data.url) {
142
+ return res.status(400).json({
143
+ author: "fourstore",
144
+ hit: hitCount,
145
+ message: "Parameter 'sitekey' dan 'url' diperlukan",
146
+ runtime: getRuntimeInfo(),
147
+ status: "failed"
148
+ })
149
+ }
150
+
151
+ if (authToken && data.authToken !== authToken) {
152
+ return res.status(401).json({
153
+ author: "fourstore",
154
+ hit: hitCount,
155
+ message: "Unauthorized",
156
+ runtime: getRuntimeInfo(),
157
+ status: "failed"
158
+ })
159
+ }
160
+
161
+ if (global.browserLimit <= 0) {
162
+ return res.status(429).json({
163
+ author: "fourstore",
164
+ hit: hitCount,
165
+ message: "Too Many Requests",
166
+ runtime: getRuntimeInfo(),
167
+ status: "failed"
168
+ })
169
+ }
170
+
171
+ let cacheKey, cached
172
+ if (data.mode === "iuam") {
173
+ cacheKey = JSON.stringify(data)
174
+ cached = readCache(cacheKey)
175
+ if (cached) {
176
+ return res.status(200).json({
177
+ author: "fourstore",
178
+ hit: hitCount,
179
+ ...cached,
180
+ cached: true,
181
+ runtime: getRuntimeInfo(),
182
+ status: "success"
183
+ })
184
+ }
185
+ }
186
+
187
+ global.browserLimit--
188
+ let result
189
+ let browser, page
190
+
191
+ try {
192
+ const proxyServer = data.proxy ? `${data.proxy.hostname}:${data.proxy.port}` : null
193
+ const ctx = await createBrowser(proxyServer)
194
+ browser = ctx.browser
195
+ page = ctx.page
196
+
197
+ await page.goto('about:blank')
198
+
199
+ switch (data.mode) {
200
+ case "turnstile":
201
+ result = await turnstile(data, page)
202
+ .then(token => ({
203
+ token,
204
+ status: "success"
205
+ }))
206
+ .catch(err => ({
207
+ code: 500,
208
+ message: err.message,
209
+ status: "failed"
210
+ }))
211
+ break
212
+
213
+ case "iuam":
214
+ result = await cloudflare(data, page)
215
+ .then(r => ({
216
+ ...r,
217
+ status: "success"
218
+ }))
219
+ .catch(err => ({
220
+ code: 500,
221
+ message: err.message,
222
+ status: "failed"
223
+ }))
224
+
225
+ if (!result.code || result.code === 200) {
226
+ writeCache(cacheKey, result)
227
+ }
228
+ break
229
+
230
+ case "recaptchav3":
231
+ result = await recaptchav3(data, page)
232
+ .then(token => ({
233
+ token,
234
+ status: "success"
235
+ }))
236
+ .catch(err => ({
237
+ code: 500,
238
+ message: err.message,
239
+ status: "failed"
240
+ }))
241
+ break
242
+
243
+ default:
244
+ result = {
245
+ code: 400,
246
+ message: 'Invalid mode',
247
+ status: "failed"
248
+ }
249
+ }
250
+ } catch (err) {
251
+ result = {
252
+ code: 500,
253
+ message: err.message,
254
+ status: "failed"
255
+ }
256
+ } finally {
257
+ if (browser) {
258
+ try { await browser.close() } catch {}
259
+ }
260
+ global.browserLimit++
261
+ }
262
+
263
+ const response = {
264
+ author: "fourstore",
265
+ hit: hitCount,
266
+ ...result,
267
+ runtime: getRuntimeInfo()
268
+ }
269
+
270
+ res.status(result.code ?? 200).json(response)
271
+ })
272
+
273
+ app.use((req, res) => {
274
+ hitCount++
275
+ res.status(404).json({
276
+ author: "fourstore",
277
+ hit: hitCount,
278
+ message: "Not Found",
279
+ runtime: getRuntimeInfo(),
280
+ status: "failed"
281
+ })
282
+ })
283
+
284
+ if (process.env.NODE_ENV === 'development') {
285
+ module.exports = app
286
+ }
package.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "puppeteer-real-browser": "^1.4.0"
12
+ },
13
+ "devDependencies": {
14
+ "nodemon": "^3.1.10"
15
+ }
16
+ }