Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
R2Socks — 通过 Cloudflare R2 对象存储隧道传输的 SOCKS5 代理,使用 Python 和无依赖的 C++ 代理通过加密的 R2 对象中继 TCP 流量以实现隐蔽访问。 | Kitploit
工具/GitHubGitHub/ivancabrera02/r2socks
加密/解密工具数据泄露后渗透利用网络安全渗透测试命令与控制红队远程访问工具
GitHubivancabrera02/r2socks

R2Socks

通过 Cloudflare R2 对象存储隧道传输的 SOCKS5 代理,使用 Python 和无依赖的 C++ 代理通过加密的 R2 对象中继 TCP 流量以实现隐蔽访问。

查看仓库
3161417天前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

R2Socks

通过 Cloudflare R2 存储桶隧道传输的 SOCKS5 代理。

root@kitploit:~
[客户端应用] ◄─SOCKS5─► [代理] ◄─── R2 存储桶 ───► [Agent] ◄─TCP─► [目标]

代理在操作者机器上运行本地 SOCKS5 服务器。每个 CONNECT 请求都被序列化为二进制数据包,并作为 R2 对象存储。Agent 从目标网络轮询同一个存储桶,获取连接请求,建立真实的 TCP 连接,并通过 R2 中继数据。

组件

组件语言文件描述
代理Pythonr2socks.pySOCKS5 服务器(操作者侧)
AgentPythonr2socks.py目标侧中继(agent 模式)
AgentC++r2agent.cpp独立 Windows agent,零依赖

C++ agent 与 Python 代理协议兼容。它仅使用 Windows 原生 API(WinHTTP、bcrypt、Winsock2),无需外部库。

快速开始

1. 创建 R2 存储桶

  1. 前往 Cloudflare Dashboard → R2 Object Storage
  2. 点击 Create bucket 并为其命名
  3. 从 URL 中记下你的 Account ID:dash.cloudflare.com/<ACCOUNT_ID>/r2/...

2. 创建 R2 API 令牌

  1. 在 R2 中 → Manage R2 API Tokens → Create API Token
  2. 将权限设置为 Object Read & Write
  3. 选择你的存储桶(或所有存储桶)
  4. 复制 Access Key ID 和 Secret Access Key(仅显示一次)

3. 启动代理

root@kitploit:~
pip install boto3
python r2socks.py proxy -b my-bucket -a <account_id> \
    --access-key <R2_ACCESS_KEY> --secret-key <R2_SECRET_KEY>

代理会生成一个通道 ID,并打印启动 agent 的命令。

4. 启动 Agent

Python agent:

root@kitploit:~
python r2socks.py agent -b my-bucket -a <account_id> -c <channel_id> \
    --access-key <R2_ACCESS_KEY> --secret-key <R2_SECRET_KEY>

C++ agent(Windows):

root@kitploit:~
.\r2agent.exe -b my-bucket -a <account_id> -c <channel_id> -k <access_key> -s <secret_key>

用法

代理(操作者侧)

root@kitploit:~
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

Agent(目标侧)

Python:

root@kitploit:~
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):

root@kitploit:~
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

清理

完成后移除通道中的所有 R2 对象:

root@kitploit:~
python r2socks.py clean -b my-bucket -a <account_id> -c <channel_id>

协议

代理与 agent 之间共享的二进制数据包格式:

root@kitploit:~
┌──────────┬────────────────────┬────────────┬──────────────────┐
│ CMD (1B) │ ConnectionID (16B) │ Len (4B BE)│ Payload (var)    │
└──────────┴────────────────────┴────────────┴──────────────────┘

多个数据包被批量合并为单个 R2 对象(最大 4MB),以减少 API 调用。对象以微秒时间戳命名以便排序,并在消费后删除。

加密

对所有 R2 载荷可选启用 AES-256-GCM 加密:

root@kitploit:~
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"

密钥使用 PBKDF2-SHA256 派生,迭代次数为 600,000 次。

构建 C++ Agent

从 Visual Studio Developer Command Prompt 中执行:

root@kitploit:~
cl /std:c++17 /EHsc /O2 r2agent.cpp /link ws2_32.lib winhttp.lib bcrypt.lib

自适应轮询

代理和 agent 都使用自适应休眠间隔:

  • 有流量时: 每 50ms 轮询一次,以实现低延迟
  • 空闲时: 间隔每周期增长 1.3 倍,最大 2 秒
  • 流量恢复时: 间隔下降 0.5 倍,快速回到 50ms

这在响应能力与 API 调用量之间取得平衡。每 30 秒记录一次统计信息,显示活动连接数、传输的对象数和移动的字节数。

故障排除

SignatureDoesNotMatch

  • 验证你的 R2 API 令牌凭据是否正确
  • 确保令牌对存储桶具有 Object Read & Write 权限
  • 检查系统时钟:w32tm /resync /force(Windows)或 sudo ntpdate pool.ntp.org(Linux)

RequestTimeTooSkewed

  • 系统时钟不同步。同步它:
    root@kitploit:~
    w32tm /resync /force
    

AccessDenied

  • API 令牌可能缺少对目标存储桶的权限
  • 在正确的存储桶上以 Object Read & Write 权限重新生成令牌

要求

代理(Python):

  • Python 3.8+
  • boto3(必需)
  • cryptography(可选,用于加密)

Agent(C++):

  • Windows 10/11
  • 无运行时依赖
下载工具
命令代码方向载荷
NEW0x01Proxy→AgentATYP + Address + Port
ACK0x02Agent→Proxy1 byte status (0=success)
DATA0x03BidirectionalRaw TCP data (up to 1MB)
CLOSE0x04BidirectionalEmpty
PING0x05BidirectionalEmpty