Cloudflare Workers’ı pass-through proxy’leri olarak kötüye kullanma (IP rotasyonu, FireProx tarzı)
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- Abonelik planlarını kontrol edin!
- Katılın 💬 Discord group veya telegram group veya Twitter’da bizi takip edin 🐦 @hacktricks_live.
- PR göndererek hacking tricks paylaşın: HackTricks ve HackTricks Cloud github repos.
Cloudflare Workers, upstream hedef URL’si istemci tarafından sağlanan şeffaf HTTP pass-through proxy’leri olarak dağıtılabilir. İstekler Cloudflare ağından egress olur, bu yüzden hedef istemci yerine Cloudflare IP’lerini görür. Bu, AWS API Gateway üzerindeki bilinen FireProx tekniğini yansıtır, ancak Cloudflare Workers kullanır.
Temel yetenekler
- Tüm HTTP yöntemlerini destekler (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD)
- Hedef query parametresi (?url=…), bir header (X-Target-URL) ile veya hatta path içinde kodlanmış olarak (ör. /https://target) sağlanabilir
- Header’lar ve body gerektiğinde hop-by-hop/header filtresi uygulanarak proxy’lenir
- Yanıtlar status kodunu ve çoğu header’ı koruyarak geri iletilir
- Opsiyonel olarak X-Forwarded-For taklidi (Worker bunu kullanıcı kontrollü bir header’dan ayarlıyorsa)
- Birden fazla Worker endpoint’i dağıtarak ve istekleri fan-out yaparak son derece hızlı/kolay rotasyon
Nasıl çalışır (akış)
- İstemci bir Worker URL’sine (
<name>.<account>.workers.devveya bir custom domain route) HTTP isteği gönderir. - Worker hedefi ya bir query parametresinden (?url=…), X-Target-URL header’ından veya uygulanmışsa bir path segmentinden çıkarır.
- Worker gelen method, header’lar ve body’i belirtilen upstream URL’e iletir (problemli header’ları filtreleyerek).
- Upstream yanıtı Cloudflare üzerinden istemciye stream edilir; origin Cloudflare çıkış IP’lerini görür.
Worker uygulama örneği
- Hedef URL’yi query param, header veya path’ten okur
- Güvenli bir header alt kümesini kopyalar ve orijinal method/body’yi iletir
- Opsiyonel olarak X-Forwarded-For’u kullanıcı kontrollü bir header (X-My-X-Forwarded-For) veya rastgele bir IP kullanarak ayarlar
- Geniş izinli CORS ekler ve preflight’ı işler
Pass-through proxy için örnek Worker (JavaScript)
```javascript /** * Minimal Worker pass-through proxy * - Target URL from ?url=, X-Target-URL, or /https://... * - Proxies method/headers/body to upstream; relays response */ addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) })async function handleRequest(request) { try { const url = new URL(request.url) const targetUrl = getTargetUrl(url, request.headers)
if (!targetUrl) { return errorJSON(‘No target URL specified’, 400, { usage: { query_param: ‘?url=https://example.com’, header: ‘X-Target-URL: https://example.com’, path: ‘/https://example.com’ } }) }
let target try { target = new URL(targetUrl) } catch (e) { return errorJSON(‘Invalid target URL’, 400, { provided: targetUrl }) }
// Forward original query params except control ones const passthru = new URLSearchParams() for (const [k, v] of url.searchParams) { if (![‘url’, ‘_cb’, ‘_t’].includes(k)) passthru.append(k, v) } if (passthru.toString()) target.search = passthru.toString()
// Build proxied request const proxyReq = buildProxyRequest(request, target) const upstream = await fetch(proxyReq)
return buildProxyResponse(upstream, request.method) } catch (error) { return errorJSON(‘Proxy request failed’, 500, { message: error.message, timestamp: new Date().toISOString() }) } }
function getTargetUrl(url, headers) { let t = url.searchParams.get(‘url’) || headers.get(‘X-Target-URL’) if (!t && url.pathname !== ‘/’) { const p = url.pathname.slice(1) if (p.startsWith(‘http’)) t = p } return t }
function buildProxyRequest(request, target) { const h = new Headers() const allow = [ ‘accept’,‘accept-language’,‘accept-encoding’,‘authorization’, ‘cache-control’,‘content-type’,‘origin’,‘referer’,‘user-agent’ ] for (const [k, v] of request.headers) { if (allow.includes(k.toLowerCase())) h.set(k, v) } h.set(‘Host’, target.hostname)
// Optional: spoof X-Forwarded-For if provided const spoof = request.headers.get(‘X-My-X-Forwarded-For’) h.set(‘X-Forwarded-For’, spoof || randomIP())
return new Request(target.toString(), { method: request.method, headers: h, body: [‘GET’,‘HEAD’].includes(request.method) ? null : request.body }) }
function buildProxyResponse(resp, method) { const h = new Headers() for (const [k, v] of resp.headers) { if (![‘content-encoding’,‘content-length’,‘transfer-encoding’].includes(k.toLowerCase())) { h.set(k, v) } } // Permissive CORS for tooling convenience h.set(‘Access-Control-Allow-Origin’, ‘’) h.set(‘Access-Control-Allow-Methods’, ‘GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD’) h.set(‘Access-Control-Allow-Headers’, ‘’)
if (method === ‘OPTIONS’) return new Response(null, { status: 204, headers: h }) return new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers: h }) }
function errorJSON(msg, status=400, extra={}) { return new Response(JSON.stringify({ error: msg, …extra }), { status, headers: { ‘Content-Type’: ‘application/json’ } }) }
function randomIP() { return [1,2,3,4].map(() => Math.floor(Math.random()*255)+1).join(‘.’) }
</details>
### FlareProx ile dağıtım ve rotasyonu otomatikleştirme
FlareProx, Cloudflare API'yi kullanarak birçok Worker endpoints dağıtan ve bunlar arasında rotasyon yapan bir Python aracıdır. Bu, Cloudflare’s network üzerinden FireProx-benzeri IP rotasyonu sağlar.
Kurulum
1) “Edit Cloudflare Workers” şablonunu kullanarak bir Cloudflare API Token oluşturun ve dashboard'dan Account ID'nizi alın.
2) FlareProx'i yapılandırın:
```bash
git clone https://github.com/MrTurvey/flareprox
cd flareprox
pip install -r requirements.txt
flareprox.json yapılandırma dosyasını oluşturun:
{
"cloudflare": {
"api_token": "your_cloudflare_api_token",
"account_id": "your_cloudflare_account_id"
}
}
CLI kullanımı
- N adet Worker proxy oluşturun:
python3 flareprox.py create --count 2
- Uç noktaları listele:
python3 flareprox.py list
- Health-test endpoints:
python3 flareprox.py test
- Tüm endpoints’leri sil:
python3 flareprox.py cleanup
Worker üzerinden trafiği yönlendirme
- Sorgu parametresi biçimi:
curl "https://your-worker.account.workers.dev?url=https://httpbin.org/ip"
- Başlık formu:
curl -H "X-Target-URL: https://httpbin.org/ip" https://your-worker.account.workers.dev
- Yol biçimi (uygulandıysa):
curl https://your-worker.account.workers.dev/https://httpbin.org/ip
- Yöntem örnekleri:
# GET
curl "https://your-worker.account.workers.dev?url=https://httpbin.org/get"
# POST (form)
curl -X POST -d "username=admin" \
"https://your-worker.account.workers.dev?url=https://httpbin.org/post"
# PUT (JSON)
curl -X PUT -d '{"username":"admin"}' -H "Content-Type: application/json" \
"https://your-worker.account.workers.dev?url=https://httpbin.org/put"
# DELETE
curl -X DELETE \
"https://your-worker.account.workers.dev?url=https://httpbin.org/delete"
X-Forwarded-For kontrol
Worker X-My-X-Forwarded-For’u dikkate alıyorsa, upstream X-Forwarded-For değerini etkileyebilirsiniz:
curl -H "X-My-X-Forwarded-For: 203.0.113.10" \
"https://your-worker.account.workers.dev?url=https://httpbin.org/headers"
Programatik kullanım
FlareProx kütüphanesini kullanarak endpoints oluşturun/listeleyin/test edin ve istekleri Python’dan yönlendirin.
Python örneği: Rastgele bir Worker endpoint üzerinden bir POST gönderin
```python #!/usr/bin/env python3 from flareprox import FlareProx, FlareProxError import jsonInitialize
flareprox = FlareProx(config_file=“flareprox.json”) if not flareprox.is_configured: print(“FlareProx not configured. Run: python3 flareprox.py config”) exit(1)
Ensure endpoints exist
endpoints = flareprox.sync_endpoints() if not endpoints: print(“Creating proxy endpoints…”) flareprox.create_proxies(count=2)
Make a POST request through a random endpoint
try: post_data = json.dumps({ “username”: “testuser”, “message”: “Hello from FlareProx!”, “timestamp”: “2025-01-01T12:00:00Z” })
headers = { “Content-Type”: “application/json”, “User-Agent”: “FlareProx-Client/1.0” }
response = flareprox.redirect_request( target_url=“https://httpbin.org/post”, method=“POST”, headers=headers, data=post_data )
if response.status_code == 200: result = response.json() print(“✓ POST successful via FlareProx”) print(f“Origin IP: {result.get(‘origin’, ‘unknown’)}“) print(f“Posted data: {result.get(‘json’, {})}”) else: print(f“Request failed with status: {response.status_code}“)
except FlareProxError as e: print(f“FlareProx error: {e}“) except Exception as e: print(f“Request error: {e}”)
</details>
**Burp/Scanner entegrasyonu**
- Araçları (örneğin, Burp Suite) Worker URL'sine yönlendirin.
- Gerçek upstream'i ?url= veya X-Target-URL kullanarak sağlayın.
- HTTP semantics (methods/headers/body) korunur; kaynak IP'niz Cloudflare arkasında maskelenir.
**Operasyonel notlar ve sınırlamalar**
- Cloudflare Workers Free plan hesap başına günde yaklaşık 100.000 isteğe izin verir; gerekirse trafiği dağıtmak için birden fazla endpoint kullanın.
- Workers Cloudflare’ın ağında çalışır; birçok hedef yalnızca Cloudflare IP'lerini/ASN'lerini görecektir, bu da basit IP izin/red listelerini veya coğrafi heuristikleri atlatabilir.
- Sorumlu şekilde ve yalnızca yetki/izin ile kullanın. ToS ve robots.txt'e uyun.
## Referanslar
- [FlareProx (Cloudflare Workers pass-through/rotation)](https://github.com/MrTurvey/flareprox)
- [Cloudflare Workers fetch() API](https://developers.cloudflare.com/workers/runtime-apis/fetch/)
- [Cloudflare Workers pricing and free tier](https://developers.cloudflare.com/workers/platform/pricing/)
- [FireProx (AWS API Gateway)](https://github.com/ustayready/fireprox)
> [!TIP]
> AWS Hacking'i öğrenin ve pratik yapın:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://hacktricks-training.com/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> GCP Hacking'i öğrenin ve pratik yapın: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://hacktricks-training.com/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> Az Hacking'i öğrenin ve pratik yapın: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://hacktricks-training.com/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>HackTricks'i Destekleyin</summary>
>
> - [**Abonelik planlarını**](https://github.com/sponsors/carlospolop) kontrol edin!
> - **Katılın** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) veya [**telegram group**](https://t.me/peass) veya **Twitter**'da bizi **takip edin** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
> - **PR göndererek hacking tricks paylaşın:** [**HackTricks**](https://github.com/carlospolop/hacktricks) ve [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
>
> </details>
HackTricks Cloud

