Update README.md
Browse files
README.md
CHANGED
|
@@ -1,30 +1,111 @@
|
|
| 1 |
-
# π Cloudflare
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
## β¨ Fitur
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
- **Mode Sitekey** β inject fake page dengan sitekey eksplisit
|
| 9 |
- **Mode Page** β solve langsung dari halaman target (auto-detect turnstile)
|
| 10 |
- Screen recording tiap sesi (`.mp4`) via `puppeteer-screen-recorder`
|
| 11 |
- Support proxy dengan autentikasi
|
| 12 |
- Output token dalam format JSON
|
| 13 |
|
|
|
|
|
|
|
| 14 |
## π¦ Instalasi
|
| 15 |
|
| 16 |
```bash
|
| 17 |
npm install puppeteer-real-browser puppeteer-screen-recorder
|
| 18 |
```
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
```js
|
| 23 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
const solver = new TurnstileSolver({
|
| 26 |
-
timeout: 60000,
|
| 27 |
-
record: true,
|
| 28 |
recordDir: './recordings',
|
| 29 |
// proxy: { host: '...', port: 8080, username: 'user', password: 'pass' },
|
| 30 |
width: 1280,
|
|
@@ -36,14 +117,14 @@ await solver.initialize();
|
|
| 36 |
// Mode 1: pakai sitekey eksplisit
|
| 37 |
const result = await solver.solve('https://example.com', '0x4AAAAAAA...');
|
| 38 |
|
| 39 |
-
// Mode 2:
|
| 40 |
const result = await solver.solve('https://example.com');
|
| 41 |
|
| 42 |
console.log(result);
|
| 43 |
await solver.cleanup();
|
| 44 |
```
|
| 45 |
|
| 46 |
-
### Options Konstruktor
|
| 47 |
|
| 48 |
| Option | Tipe | Default | Deskripsi |
|
| 49 |
|--------|------|---------|-----------|
|
|
@@ -54,17 +135,17 @@ await solver.cleanup();
|
|
| 54 |
| `width` | `number` | `1280` | Viewport & recording width |
|
| 55 |
| `height` | `number` | `720` | Viewport & recording height |
|
| 56 |
|
| 57 |
-
###
|
| 58 |
|
| 59 |
| Method | Deskripsi |
|
| 60 |
|--------|-----------|
|
| 61 |
-
| `initialize()` | Launch browser (opsional, auto-called saat solve) |
|
| 62 |
-
| `solve(url, siteKey?)` | Solve turnstile β
|
| 63 |
| `solveWithSitekey(url, siteKey)` | Inject fake page dengan sitekey eksplisit |
|
| 64 |
| `solveFromPage(url)` | Solve langsung dari halaman target |
|
| 65 |
-
| `cleanup()` | Tutup browser |
|
| 66 |
|
| 67 |
-
##
|
| 68 |
|
| 69 |
Berhasil:
|
| 70 |
|
|
@@ -87,58 +168,88 @@ Gagal:
|
|
| 87 |
}
|
| 88 |
```
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
Kalau `record: true`, setiap sesi disimpan ke `recordDir` dengan
|
| 93 |
|
| 94 |
```
|
| 95 |
recordings/
|
| 96 |
-
βββ
|
| 97 |
-
βββ page_solve_1747123456789.mp4
|
| 98 |
```
|
| 99 |
|
|
|
|
|
|
|
| 100 |
## βοΈ Cara Kerja
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
3. `waitForSelector` menunggu sampai token siap
|
| 111 |
|
| 112 |
-
|
| 113 |
|
| 114 |
-
|
| 115 |
-
- `ffmpeg` (dibutuhkan `puppeteer-screen-recorder` untuk encode MP4)
|
| 116 |
-
- Xvfb (untuk headless di Linux β dihandle otomatis oleh `puppeteer-real-browser`)
|
| 117 |
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
|
| 125 |
|
| 126 |
-
|
| 127 |
|
| 128 |
-
|
| 129 |
-
of this software and associated documentation files (the "Software"), to deal
|
| 130 |
-
in the Software without restriction, including without limitation the rights
|
| 131 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 132 |
-
copies of the Software, and to permit persons to whom the Software is
|
| 133 |
-
furnished to do so, subject to the following conditions:
|
| 134 |
|
| 135 |
-
|
| 136 |
-
copies or substantial portions of the Software.
|
| 137 |
|
| 138 |
-
|
| 139 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 140 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 141 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 142 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 143 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 144 |
-
SOFTWARE.
|
|
|
|
| 1 |
+
# π Cloudflare Solver
|
| 2 |
|
| 3 |
+
Dua solver otomatis untuk proteksi Cloudflare menggunakan `puppeteer-real-browser`:
|
| 4 |
+
|
| 5 |
+
- **`cloudflare-solver.js`** β Bypass Cloudflare challenge page dan ekstrak cookie `cf_clearance`
|
| 6 |
+
- **`turnstile-solver.js`** β Solve Cloudflare Turnstile widget dan dapatkan token
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
|
| 10 |
## β¨ Fitur
|
| 11 |
|
| 12 |
+
### Cloudflare Solver
|
| 13 |
+
- Bypass halaman challenge Cloudflare secara otomatis
|
| 14 |
+
- Deteksi tipe challenge: `non-interactive`, `managed`, `interactive`
|
| 15 |
+
- Klik iframe Cloudflare (checkbox β label β widget β body fallback)
|
| 16 |
+
- Ekstrak cookie `cf_clearance` + semua cookies + cookie string siap pakai
|
| 17 |
+
- Support proxy URL (`http://user:pass@ip:port`) dan proxy file
|
| 18 |
+
- Random User-Agent dari `data/useragents.txt`
|
| 19 |
+
|
| 20 |
+
### Turnstile Solver
|
| 21 |
- **Mode Sitekey** β inject fake page dengan sitekey eksplisit
|
| 22 |
- **Mode Page** β solve langsung dari halaman target (auto-detect turnstile)
|
| 23 |
- Screen recording tiap sesi (`.mp4`) via `puppeteer-screen-recorder`
|
| 24 |
- Support proxy dengan autentikasi
|
| 25 |
- Output token dalam format JSON
|
| 26 |
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
## π¦ Instalasi
|
| 30 |
|
| 31 |
```bash
|
| 32 |
npm install puppeteer-real-browser puppeteer-screen-recorder
|
| 33 |
```
|
| 34 |
|
| 35 |
+
> **Requirements tambahan:**
|
| 36 |
+
> - Node.js >= 18
|
| 37 |
+
> - `ffmpeg` β dibutuhkan `puppeteer-screen-recorder` untuk encode MP4
|
| 38 |
+
> - `Xvfb` β untuk headless di Linux (dihandle otomatis oleh `puppeteer-real-browser`)
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## π§ Penggunaan
|
| 43 |
+
|
| 44 |
+
### Cloudflare Solver
|
| 45 |
|
| 46 |
```js
|
| 47 |
+
const { solveCloudflare } = require('./cloudflare-solver');
|
| 48 |
+
|
| 49 |
+
const result = await solveCloudflare({
|
| 50 |
+
url: 'https://example.com',
|
| 51 |
+
headless: false, // tampilkan browser
|
| 52 |
+
timeout: 30, // timeout dalam detik
|
| 53 |
+
// proxy: 'http://user:pass@ip:port',
|
| 54 |
+
// proxyFile: 'data/proxies.txt',
|
| 55 |
+
});
|
| 56 |
+
|
| 57 |
+
console.log(result);
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
#### Options
|
| 61 |
+
|
| 62 |
+
| Option | Tipe | Default | Deskripsi |
|
| 63 |
+
|--------|------|---------|-----------|
|
| 64 |
+
| `url` | `string` | β | **Wajib.** URL target |
|
| 65 |
+
| `headless` | `boolean` | `true` | Tampilkan browser atau tidak |
|
| 66 |
+
| `proxy` | `string` | `null` | Proxy URL: `http://user:pass@ip:port` |
|
| 67 |
+
| `proxyFile` | `string` | `null` | Path ke file daftar proxy (satu per baris) |
|
| 68 |
+
| `timeout` | `number` | `30` | Batas waktu solve challenge (detik) |
|
| 69 |
+
|
| 70 |
+
#### Output
|
| 71 |
+
|
| 72 |
+
Berhasil:
|
| 73 |
+
|
| 74 |
+
```json
|
| 75 |
+
{
|
| 76 |
+
"success": true,
|
| 77 |
+
"url": "https://example.com",
|
| 78 |
+
"proxy": null,
|
| 79 |
+
"user_agent": "Mozilla/5.0 ...",
|
| 80 |
+
"cf_clearance": "abc123...",
|
| 81 |
+
"all_cookies": [...],
|
| 82 |
+
"cookie_string": "cf_clearance=abc123; ...",
|
| 83 |
+
"unix_timestamp": 1747000000,
|
| 84 |
+
"timestamp": "2025-05-12T00:00:00.000Z",
|
| 85 |
+
"domain": ".example.com"
|
| 86 |
+
}
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
Gagal:
|
| 90 |
+
|
| 91 |
+
```json
|
| 92 |
+
{
|
| 93 |
+
"success": false,
|
| 94 |
+
"url": "https://example.com",
|
| 95 |
+
"error": "Failed to obtain cf_clearance cookie"
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
### Turnstile Solver
|
| 102 |
+
|
| 103 |
+
```js
|
| 104 |
+
const TurnstileSolver = require('./turnstile-solver');
|
| 105 |
|
| 106 |
const solver = new TurnstileSolver({
|
| 107 |
+
timeout: 60000,
|
| 108 |
+
record: true,
|
| 109 |
recordDir: './recordings',
|
| 110 |
// proxy: { host: '...', port: 8080, username: 'user', password: 'pass' },
|
| 111 |
width: 1280,
|
|
|
|
| 117 |
// Mode 1: pakai sitekey eksplisit
|
| 118 |
const result = await solver.solve('https://example.com', '0x4AAAAAAA...');
|
| 119 |
|
| 120 |
+
// Mode 2: auto-detect dari halaman target
|
| 121 |
const result = await solver.solve('https://example.com');
|
| 122 |
|
| 123 |
console.log(result);
|
| 124 |
await solver.cleanup();
|
| 125 |
```
|
| 126 |
|
| 127 |
+
#### Options Konstruktor
|
| 128 |
|
| 129 |
| Option | Tipe | Default | Deskripsi |
|
| 130 |
|--------|------|---------|-----------|
|
|
|
|
| 135 |
| `width` | `number` | `1280` | Viewport & recording width |
|
| 136 |
| `height` | `number` | `720` | Viewport & recording height |
|
| 137 |
|
| 138 |
+
#### Methods
|
| 139 |
|
| 140 |
| Method | Deskripsi |
|
| 141 |
|--------|-----------|
|
| 142 |
+
| `initialize()` | Launch browser (opsional, auto-called saat `solve`) |
|
| 143 |
+
| `solve(url, siteKey?)` | Solve turnstile β sitekey mode kalau diisi, page mode kalau tidak |
|
| 144 |
| `solveWithSitekey(url, siteKey)` | Inject fake page dengan sitekey eksplisit |
|
| 145 |
| `solveFromPage(url)` | Solve langsung dari halaman target |
|
| 146 |
+
| `cleanup()` | Tutup browser dan reset state |
|
| 147 |
|
| 148 |
+
#### Output
|
| 149 |
|
| 150 |
Berhasil:
|
| 151 |
|
|
|
|
| 168 |
}
|
| 169 |
```
|
| 170 |
|
| 171 |
+
---
|
| 172 |
+
|
| 173 |
+
## π Screen Recording
|
| 174 |
|
| 175 |
+
Kalau `record: true`, setiap sesi disimpan ke `recordDir` dengan format:
|
| 176 |
|
| 177 |
```
|
| 178 |
recordings/
|
| 179 |
+
βββ sitekey_0x4AAAAAAA__1747123456789.mp4 β mode sitekey
|
| 180 |
+
βββ page_solve_1747123456789.mp4 β mode page
|
| 181 |
```
|
| 182 |
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
## βοΈ Cara Kerja
|
| 186 |
|
| 187 |
+
### Cloudflare Solver
|
| 188 |
+
|
| 189 |
+
1. Launch browser via `puppeteer-real-browser` dengan `turnstile: false`
|
| 190 |
+
2. Navigate ke URL target
|
| 191 |
+
3. Cek apakah `cf_clearance` sudah ada di cookies
|
| 192 |
+
4. Kalau belum, deteksi tipe challenge dari HTML (`cType: '...'`)
|
| 193 |
+
5. Cari iframe `challenges.cloudflare.com` lalu klik: checkbox β label β widget β body (fallback)
|
| 194 |
+
6. Poll cookies sampai `cf_clearance` muncul atau timeout
|
| 195 |
+
7. Return `cf_clearance`, semua cookies, dan `cookie_string` siap pakai
|
| 196 |
+
|
| 197 |
+
### Turnstile Solver β Mode Sitekey (`solveWithSitekey`)
|
| 198 |
|
| 199 |
+
1. Aktifkan request interception
|
| 200 |
+
2. Intercept request ke URL target, balas dengan fake HTML yang berisi widget Turnstile
|
| 201 |
+
3. `puppeteer-real-browser` dengan `turnstile: true` handle solve otomatis
|
| 202 |
+
4. Token diambil dari input hidden `[name="cf-response"]`
|
| 203 |
+
|
| 204 |
+
### Turnstile Solver β Mode Page (`solveFromPage`)
|
| 205 |
+
|
| 206 |
+
1. Inject polling script via `evaluateOnNewDocument` yang cek `window.turnstile.getResponse()`
|
| 207 |
+
2. Saat token tersedia, tulis ke input hidden `[name="cf-response"]`
|
| 208 |
3. `waitForSelector` menunggu sampai token siap
|
| 209 |
|
| 210 |
+
---
|
| 211 |
|
| 212 |
+
## π Contoh Lengkap (`run.js`)
|
|
|
|
|
|
|
| 213 |
|
| 214 |
+
```js
|
| 215 |
+
const { solveCloudflare } = require('./cloudflare-solver');
|
| 216 |
+
const TurnstileSolver = require('./turnstile-solver');
|
| 217 |
+
|
| 218 |
+
// Cloudflare challenge
|
| 219 |
+
async function runCloudflare() {
|
| 220 |
+
const result = await solveCloudflare({
|
| 221 |
+
url: 'https://example.com',
|
| 222 |
+
headless: false,
|
| 223 |
+
timeout: 60,
|
| 224 |
+
});
|
| 225 |
+
console.log(result);
|
| 226 |
+
}
|
| 227 |
|
| 228 |
+
// Turnstile
|
| 229 |
+
async function runTurnstile() {
|
| 230 |
+
const solver = new TurnstileSolver({ record: true });
|
| 231 |
+
try {
|
| 232 |
+
const res = await solver.solve('https://www.waifu2x.net', '0x4AAAAAABqlY7DKXMzoS81U');
|
| 233 |
+
console.log(res);
|
| 234 |
+
} finally {
|
| 235 |
+
await solver.cleanup();
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
|
| 239 |
+
(async () => {
|
| 240 |
+
// await runCloudflare();
|
| 241 |
+
await runTurnstile();
|
| 242 |
+
})();
|
| 243 |
+
```
|
| 244 |
+
|
| 245 |
+
---
|
| 246 |
|
| 247 |
+
## β οΈ Disclaimer
|
| 248 |
|
| 249 |
+
Tool ini dibuat untuk keperluan edukasi dan testing. Penggunaan untuk bypass proteksi tanpa izin pemilik situs adalah tanggung jawab pengguna sepenuhnya.
|
| 250 |
|
| 251 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
+
## π License
|
|
|
|
| 254 |
|
| 255 |
+
MIT License β Copyright (c) 2025 XAi Community
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|