buuctf web [BJDCTF2020]EzPHP

(出题人的博客,有详细步骤)

进入后是这样的
buuctf web [BJDCTF2020]EzPHP_第1张图片查看源代码发现注释
buuctf web [BJDCTF2020]EzPHP_第2张图片base32解码得到1nD3x.php,发现是源码

 This is a very simple challenge and if you solve it I will give you a flag. Good Luck!
"; 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!
"; } } 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!'); } } if (file_get_contents($file) !== 'debu_debu_aqua') die("Aqua is the cutest five-year-old child in the world! Isn't it ?
"); if ( sha1($shana) === sha1($passwd) && $shana != $passwd ){ extract($_GET["flag"]); echo "Very good! you know my password. But what is flag?
"; } 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("
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 and if 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.需要绕过preg_match(’/…/i’, $_SERVER[‘QUERY_STRING’]

(因为$_SERVER[‘QUERY_STRING’]不会url解码,可以通过url编码绕过)

2.(preg_match(’/^aqua_is_cute$/’, $_GET[‘debu’]) && $_GET[‘debu’] !== ‘aqua_is_cute’)

(可以用换行符绕过 ?debu=auqa_is_cute%0a)

3.if($_REQUEST) { foreach($_REQUEST as $value) { if(preg_match('/[a-zA-Z]/i', $value)) die('fxck you! I hate English!'); } }
($_REQUEST会解析GET,在解析POST,可以通过post一个新值绕过)

4.file_get_contents($file) !== 'debu_debu_aqua'

(使用data协议绕过)

5.sha1($shana) === sha1($passwd) && $shana != $passwd

(因为sha1无法处理数组,可用数组绕过)

6.create_function()代码注入

最后获取flag

你可能感兴趣的:(ctf)