Update plugins/cloudflare-bypass.js
Browse files- plugins/cloudflare-bypass.js +66 -91
plugins/cloudflare-bypass.js
CHANGED
|
@@ -1,104 +1,79 @@
|
|
| 1 |
const axios = require('axios');
|
| 2 |
|
| 3 |
-
const BASE_URL = 'https://herzaj-turnstile-solver.hf.space';
|
| 4 |
-
|
| 5 |
-
async function callBypassAPI(url, sitekey) {
|
| 6 |
-
try {
|
| 7 |
-
const submitResponse = await axios.get(`${BASE_URL}/turnstile`, {
|
| 8 |
-
params: {
|
| 9 |
-
url: url,
|
| 10 |
-
sitekey: sitekey
|
| 11 |
-
},
|
| 12 |
-
headers: {
|
| 13 |
-
'Accept': 'application/json',
|
| 14 |
-
'Content-Type': 'application/json'
|
| 15 |
-
}
|
| 16 |
-
});
|
| 17 |
-
|
| 18 |
-
const submitData = submitResponse.data;
|
| 19 |
-
|
| 20 |
-
if (!submitData.task_id) {
|
| 21 |
-
throw new Error('Failed to get task_id from API');
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
const taskId = submitData.task_id;
|
| 25 |
-
|
| 26 |
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
| 27 |
-
|
| 28 |
-
const resultResponse = await axios.get(`${BASE_URL}/result`, {
|
| 29 |
-
params: {
|
| 30 |
-
id: taskId
|
| 31 |
-
},
|
| 32 |
-
headers: {
|
| 33 |
-
'Accept': 'application/json'
|
| 34 |
-
}
|
| 35 |
-
});
|
| 36 |
-
|
| 37 |
-
const resultData = resultResponse.data;
|
| 38 |
-
|
| 39 |
-
if (resultData.value) {
|
| 40 |
-
return {
|
| 41 |
-
token: resultData.value,
|
| 42 |
-
solved_time: resultData.elapsed_time
|
| 43 |
-
};
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
throw new Error('Failed to get token from result');
|
| 47 |
-
|
| 48 |
-
} catch (error) {
|
| 49 |
-
throw error;
|
| 50 |
-
}
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
const handler = async (req, res) => {
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
return res.status(400).json({
|
| 66 |
-
success: false,
|
| 67 |
-
error: 'Missing required parameter: sitekey'
|
| 68 |
-
});
|
| 69 |
-
}
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
|
| 75 |
-
author: "Herza",
|
| 76 |
-
success: true,
|
| 77 |
-
data: {
|
| 78 |
-
token: result.token,
|
| 79 |
-
solved_at: solvedAt,
|
| 80 |
-
solved_time: result.solved_time
|
| 81 |
-
}
|
| 82 |
-
});
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
};
|
| 92 |
|
| 93 |
module.exports = {
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
};
|
|
|
|
| 1 |
const axios = require('axios');
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
const handler = async (req, res) => {
|
| 4 |
+
try {
|
| 5 |
+
const { site_url, site_key, key } = req.query;
|
| 6 |
+
|
| 7 |
+
if (!site_url || !site_key || !key) {
|
| 8 |
+
return res.status(400).json({
|
| 9 |
+
author: 'Herza',
|
| 10 |
+
success: false,
|
| 11 |
+
error: 'Missing required parameters: site_url, site_key, or key'
|
| 12 |
+
});
|
| 13 |
+
}
|
| 14 |
|
| 15 |
+
const solverUrl = `https://herzaj-turnstile-solver.hf.space/turnstile?url=${encodeURIComponent(site_url)}&sitekey=${encodeURIComponent(site_key)}`;
|
| 16 |
+
|
| 17 |
+
const firstResponse = await axios.get(solverUrl, {
|
| 18 |
+
timeout: 30000
|
| 19 |
+
});
|
| 20 |
+
|
| 21 |
+
const taskId = firstResponse.data?.task_id;
|
| 22 |
+
if (!taskId) {
|
| 23 |
+
return res.status(400).json({
|
| 24 |
+
author: 'Herza',
|
| 25 |
+
success: false,
|
| 26 |
+
error: 'Failed to obtain task_id from solver service'
|
| 27 |
+
});
|
| 28 |
+
}
|
| 29 |
|
| 30 |
+
await new Promise(resolve => setTimeout(resolve, 8000));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
const resultUrl = `https://herzaj-turnstile-solver.hf.space/result?id=${encodeURIComponent(taskId)}`;
|
| 33 |
+
|
| 34 |
+
const secondResponse = await axios.get(resultUrl, {
|
| 35 |
+
timeout: 30000
|
| 36 |
+
});
|
| 37 |
|
| 38 |
+
const { elapsed_time, value } = secondResponse.data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
if (!value) {
|
| 41 |
+
return res.status(400).json({
|
| 42 |
+
author: 'Herza',
|
| 43 |
+
success: false,
|
| 44 |
+
error: 'Failed to retrieve token value from solver service'
|
| 45 |
+
});
|
| 46 |
}
|
| 47 |
+
|
| 48 |
+
return res.json({
|
| 49 |
+
author: 'Herza',
|
| 50 |
+
success: true,
|
| 51 |
+
data: {
|
| 52 |
+
elapsed_time,
|
| 53 |
+
value,
|
| 54 |
+
site_url,
|
| 55 |
+
site_key
|
| 56 |
+
}
|
| 57 |
+
});
|
| 58 |
+
|
| 59 |
+
} catch (error) {
|
| 60 |
+
return res.status(500).json({
|
| 61 |
+
author: 'Herza',
|
| 62 |
+
success: false,
|
| 63 |
+
error: error.message
|
| 64 |
+
});
|
| 65 |
+
}
|
| 66 |
};
|
| 67 |
|
| 68 |
module.exports = {
|
| 69 |
+
name: 'Cloudflare Turnstile Bypass',
|
| 70 |
+
description: 'Generate Cloudflare Turnstile tokens with custom site URL and site key',
|
| 71 |
+
type: 'GET',
|
| 72 |
+
routes: ['api/tools/bypasscf'],
|
| 73 |
+
tags: ['utility', 'turnstile', 'solver'],
|
| 74 |
+
parameters: ['site_url', 'site_key', 'key'],
|
| 75 |
+
enabled: true,
|
| 76 |
+
main: ['tools'],
|
| 77 |
+
limit: 8,
|
| 78 |
+
handler
|
| 79 |
};
|