
Proxy SOCKS5 incanalato attraverso l'archiviazione di oggetti Cloudflare R2, con agenti Python e C++ senza dipendenze che inoltrano traffico TCP tramite oggetti R2 cifrati per un accesso occulto.
Proxy SOCKS5 incanalato attraverso bucket Cloudflare R2.
[Client App] ◄─SOCKS5─► [Proxy] ◄─── R2 Bucket ───► [Agent] ◄─TCP─► [Target]
Il proxy esegue un server SOCKS5 locale sulla macchina dell'operatore. Ogni richiesta CONNECT viene serializzata come pacchetti binari e memorizzata come oggetti R2. L'agent esegue il polling dello stesso bucket dalla rete di destinazione, preleva le richieste di connessione, stabilisce connessioni TCP reali e ritrasmette i dati attraverso R2.
| Componente | Linguaggio | File | Descrizione |
|---|---|---|---|
| Proxy | Python | r2socks.py | Server SOCKS5 (lato operatore) |
| Agent | Python | r2socks.py | Relay lato destinazione (modalità agent) |
| Agent | C++ | r2agent.cpp | Agent Windows standalone, zero dipendenze |
L'agent C++ è compatibile a livello di protocollo con il proxy Python. Utilizza solo API native di Windows (WinHTTP, bcrypt, Winsock2) senza librerie esterne richieste.
dash.cloudflare.com/<ACCOUNT_ID>/r2/...pip install boto3
python r2socks.py proxy -b my-bucket -a <account_id> \
--access-key <R2_ACCESS_KEY> --secret-key <R2_SECRET_KEY>
Il proxy genera un channel ID e stampa il comando per avviare l'agent.
Agent Python:
python r2socks.py agent -b my-bucket -a <account_id> -c <channel_id> \
--access-key <R2_ACCESS_KEY> --secret-key <R2_SECRET_KEY>
Agent C++ (Windows):
.\r2agent.exe -b my-bucket -a <account_id> -c <channel_id> -k <access_key> -s <secret_key>
python r2socks.py proxy [options]
Required:
-b, --bucket BUCKET R2 bucket name
-a, --account-id ID Cloudflare account ID
Optional:
-c, --channel ID Channel ID (auto-generated if omitted)
-l, --listen ADDR Listen address (default: 127.0.0.1:1080)
--access-key KEY R2 API token Access Key ID
--secret-key KEY R2 API token Secret Access Key
--socks-user USER Enable SOCKS5 user/pass authentication
--socks-pass PASS SOCKS5 password
-p, --password PWD AES-256-GCM encryption password
-v, --verbose Debug logging
Python:
python r2socks.py agent [options]
Required:
-b, --bucket BUCKET R2 bucket name
-a, --account-id ID Cloudflare account ID
-c, --channel ID Channel ID (from proxy output)
C++ (Windows):
r2agent.exe [options]
Required:
-b, --bucket BUCKET R2 bucket name
-a, --account-id ID Cloudflare account ID
-c, --channel ID Channel ID (from proxy output)
Credentials (flags override env vars):
-k, --access-key KEY R2 API token Access Key ID
-s, --secret-key KEY R2 API token Secret Access Key
Optional:
-v, --verbose Debug logging
Rimuovi tutti gli oggetti R2 da un canale al termine:
python r2socks.py clean -b my-bucket -a <account_id> -c <channel_id>
Formato pacchetto binario condiviso tra proxy e agent:
┌──────────┬────────────────────┬────────────┬──────────────────┐
│ CMD (1B) │ ConnectionID (16B) │ Len (4B BE)│ Payload (var) │
└──────────┴────────────────────┴────────────┴──────────────────┘
Più pacchetti vengono raggruppati in un singolo oggetto R2 (fino a 4MB) per ridurre le chiamate API. Gli oggetti sono nominati con timestamp al microsecondo per l'ordinamento e vengono eliminati dopo il consumo.
Crittografia AES-256-GCM opzionale per tutti i payload R2:
pip install cryptography
# Both sides must use the same password
python r2socks.py proxy -b bucket -a account_id -p "my-secret-password"
python r2socks.py agent -b bucket -a account_id -c channel -p "my-secret-password"
La chiave viene derivata utilizzando PBKDF2-SHA256 con 600.000 iterazioni.
Da un Visual Studio Developer Command Prompt:
cl /std:c++17 /EHsc /O2 r2agent.cpp /link ws2_32.lib winhttp.lib bcrypt.lib
Sia il proxy che l'agent utilizzano intervalli di sleep adattivi:
Questo bilancia la reattività rispetto al volume di chiamate API. Le statistiche vengono registrate ogni 30 secondi mostrando connessioni attive, oggetti trasferiti e byte spostati.
SignatureDoesNotMatchw32tm /resync /force (Windows) o sudo ntpdate pool.ntp.org (Linux)RequestTimeTooSkewedw32tm /resync /force
AccessDeniedProxy (Python):
boto3 (richiesto)cryptography (opzionale, per la crittografia)Agent (C++):
| Comando | Codice | Direzione | Payload |
|---|
| NEW | 0x01 | Proxy→Agent | ATYP + Address + Port |
| ACK | 0x02 | Agent→Proxy | 1 byte status (0=success) |
| DATA | 0x03 | Bidirezionale | Dati TCP grezzi (fino a 1MB) |
| CLOSE | 0x04 | Bidirezionale | Vuoto |
| PING | 0x05 | Bidirezionale | Vuoto |