echo"<br /><font color=red><B>This is a very simple challenge and if you solve it I will give you a flag. Good Luck!</B><br></font>";
if($_SERVER) { if ( preg_match('/shana|debu|aqua|cute|arg|code|flag|system|exec|passwd|ass|eval|sort|shell|ob|start|mail|\$|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|read|inc|info|bin|hex|oct|echo|print|pi|\.|\"|\'|log/i', $_SERVER['QUERY_STRING']) ) die('You seem to want to do something bad?'); }
if (!preg_match('/http|https/i', $_GET['file'])) { if (preg_match('/^aqua_is_cute$/', $_GET['debu']) && $_GET['debu'] !== 'aqua_is_cute') { $file = $_GET["file"]; echo"Neeeeee! Good Job!<br>"; } } elsedie('fxck you! What do you want to do ?!');
if($_REQUEST) { foreach($_REQUESTas$value) { if(preg_match('/[a-zA-Z]/i', $value)) die('fxck you! I hate English!'); } }
if (file_get_contents($file) !== 'debu_debu_aqua') die("Aqua is the cutest five-year-old child in the world! Isn't it ?<br>");
if ( sha1($shana) === sha1($passwd) && $shana != $passwd ){ extract($_GET["flag"]); echo"Very good! you know my password. But what is flag?<br>"; } else{ die("fxck you! you don't know my password! And you don't know sha1! why you come here!"); }
if(preg_match('/^[a-z0-9]*$/isD', $code) || preg_match('/fil|cat|more|tail|tac|less|head|nl|tailf|ass|eval|sort|shell|ob|start|mail|\`|\{|\%|x|\&|\$|\*|\||\<|\"|\'|\=|\?|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|print|echo|read|inc|flag|1f|info|bin|hex|oct|pi|con|rot|input|\.|log|\^/i', $arg) ) { die("<br />Neeeeee~! I have disabled all dangerous functions! You can't get my flag =w="); } else { include"flag.php"; $code('', $arg); } ?> This is a very simple challenge andif you solve it I will give you a flag. Good Luck! Aqua is the cutest five-year-old child in the world! Isn't it ?
有多个绕过,好多个知识点:
1.$_SERVER[‘QUERY_STRING’]绕过
1 2 3 4 5 6
if($_SERVER) { if ( //几乎ban掉了payload里所有可能用到的词 preg_match('/shana|debu|aqua|cute|arg|code|flag|system|exec|passwd|ass|eval|sort|shell|ob|start|mail|\$|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|read|inc|info|bin|hex|oct|echo|print|pi|\.|\"|\'|log/i', $_SERVER['QUERY_STRING']) ) die('You seem to want to do something bad?'); }
if (!preg_match('/http|https/i', $_GET['file'])) //不能包含http|https { if (preg_match('/^aqua_is_cute$/', $_GET['debu'])&& $_GET['debu'] !== 'aqua_is_cute') //需要在debu=xxx中匹配到‘/^&/’,且debu不能为‘aqua_is_cute’ { $file = $_GET["file"]; //用file=xxx传值 echo "Neeeeee! Good Job!<br>"; } } else die('fxck you! What do you want to do ?!');
if($_REQUEST) { foreach($_REQUEST as $value) { if(preg_match('/[a-zA-Z]/i', $value)) //要求不能有字母 die('fxck you! I hate English!'); } }
1
$_POST优先级高于$_GET,所以用POST传入的值会把$_GET中的值覆盖掉
4.file_get_contents绕过
1 2
if (file_get_contents($file) !== 'debu_debu_aqua') die("Aqua is the cutest five-year-old child in the world! Isn't it ?<br>");
此处用data伪协议即可绕过(data://text/plain,~)
5.sha1函数、比较类型数组绕过
1 2 3 4 5 6 7 8
if ( sha1($shana) === sha1($passwd) && $shana != $passwd ) //既要shana和passwd传入的值不相同,又要这两个传入的值经过sha1散列之后强相等 { extract($_GET["flag"]); echo "Very good! you know my password. But what is flag?<br>"; } else{ die("fxck you! you don't know my password! And you don't know sha1! why you come here!"); }
if(preg_match('/^[a-z0-9]*$/isD', $code) || preg_match('/fil|cat|more|tail|tac|less|head|nl|tailf|ass|eval|sort|shell|ob|start|mail|\`|\{|\%|x|\&|\$|\*|\||\<|\"|\'|\=|\?|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|print|echo|read|inc|flag|1f|info|bin|hex|oct|pi|con|rot|input|\.|log|\^/i', $arg) ) //ban了这么这么多,肯定不能用一般方法传入payload了 { die("<br />Neeeeee~! I have disabled all dangerous functions! You can't get my flag =w="); } else { include "flag.php";//包含了flag.php这个文件 $code('', $arg); } ?>