官方还在审核,以下是源码。
handle = func(origin /*string*/) {
// 1. 拆分请求头和请求体
header, body = poc.Split(origin)
// 2. 获取 URL
// 使用 _ 接收 err,既能通过代码检测,又不会在运行时因为多变量赋值报错
u, _ = str.ExtractURLFromHTTPRequestRaw(header, false)
if u == nil {
return "错误: 无法解析 URL"
}
targetUrl = u.String()
// 3. 获取 Method
lines = header.Split("\r\n")
if len(lines) == 0 {
return "错误: 数据包格式非法"
}
firstLine = lines[0]
method = firstLine.Split(" ")[0]
// 4. 处理 Headers
headerMap = make(map[string]var)
for i = 1; i < len(lines); i++ {
line = lines[i]
if line == "" { continue }
kv = line.SplitN(": ", 2)
if len(kv) == 2 {
key = str.Trim(kv[0], " \r\n")
lowKey = key.Lower()
// 过滤 Host 和长度,由 Python requests 自动补全
if lowKey == "host" || lowKey == "content-length" {
continue
}
headerMap[key] = str.Trim(kv[1], " \r\n")
}
}
// 5. 将 Header 转为 JSON 字符串
// 修复:针对你的环境,json.dumps 看来只返回一个值
jsonHeader = json.dumps(headerMap)
// 6. 处理 Body (Base64 方案:一键支持文件上传、Webshell 二进制)
bodyBase64 = codec.EncodeBase64(body)
// 7. Python 脚本模板
pythonTemplate = `import requests
import base64
import urllib3
# 禁用 HTTPS 证书警告
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def run_poc():
# 目标 URL
url = "%s"
# 格式化后的 Headers
headers = %s
# 原始请求体 (Base64 还原)
# 无论原始包是 JSON、Webshell 还是文件上传二进制流,都能 100%% 还原
# 无需本地文件,脚本独立运行
raw_body = base64.b64decode("%s")
print(f"[*] Sending %s request to {url}...")
try:
response = requests.request(
method="%s",
url=url,
headers=headers,
data=raw_body,
verify=False,
timeout=20
)
print(f"[+] Status Code: {response.status_code}")
print(f"[+] Response Body (Top 500):\n{response.text[:500]}")
except Exception as e:
print(f"[!] Request Error: {e}")
if __name__ == "__main__":
run_poc()
`
// 8. 填充模板并返回
result = pythonTemplate % [targetUrl, jsonHeader, bodyBase64, method, method]
return result
}