Files
CyberStrikeAI/tools/http-repeater.yaml
T
2025-11-21 23:20:41 +08:00

82 lines
2.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: "http-repeater"
command: "python3"
args:
- "-c"
- |
import json
import sys
import textwrap
import requests
if len(sys.argv) < 2:
sys.stderr.write("缺少 request_spec 参数\n")
sys.exit(1)
spec_raw = sys.argv[1]
repeat = int(sys.argv[2]) if len(sys.argv) > 2 and sys.argv[2] else 1
delay = float(sys.argv[3]) if len(sys.argv) > 3 and sys.argv[3] else 0.0
try:
spec = json.loads(spec_raw)
except json.JSONDecodeError as exc:
sys.stderr.write(f"请求规范解析失败: {exc}\n")
sys.exit(1)
url = spec.get("url")
if not url:
sys.stderr.write("request_spec 中缺少 url 字段\n")
sys.exit(1)
method = spec.get("method", "GET").upper()
headers = spec.get("headers") or {}
cookies = spec.get("cookies") or {}
data = spec.get("data")
json_data = spec.get("json")
session = requests.Session()
for idx in range(repeat):
response = session.request(
method,
url,
headers=headers,
cookies=cookies,
data=data,
json=json_data,
allow_redirects=False,
)
print(f"===== Response #{idx + 1} =====")
print(f"Status: {response.status_code}")
print(f"Headers:\n{textwrap.indent(str(dict(response.headers)), ' ')}")
print("Body:")
print(response.text)
if delay and idx + 1 < repeat:
import time
time.sleep(delay)
enabled: true
short_description: "发送精心制作的HTTP请求(Burp Repeater等效)"
description: |
以JSON描述请求细节(URL/方法/头/正文),运行时可重复发送并查看响应。
parameters:
- name: "request_spec"
type: "string"
description: "请求规范(JSON格式),支持 url, method, headers, cookies, data/json"
required: true
position: 0
format: "positional"
- name: "repeat"
type: "int"
description: "重复发送次数(默认1"
required: false
default: 1
position: 1
format: "positional"
- name: "delay"
type: "string"
description: "重复发送的间隔秒数(默认0)"
required: false
default: "0"
position: 2
format: "positional"