[MRCTF2020]Ezaudit
[MRCTF2020]Ezaudit
考点
使用
php_mt_seed破解mt_rand伪随机万能密码
wphp
目录扫描存在www.zip,解压出index.php,给了公钥,要知道私钥才能登录
// genarate public_key
function public_key($length = 16) {
$strings1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$public_key = '';
for ( $i = 0; $i < $length; $i++ )
$public_key .= substr($strings1, mt_rand(0, strlen($strings1) - 1), 1);
return $public_key;
}
//genarate private_key
function private_key($length = 12) {
$strings2 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$private_key = '';
for ( $i = 0; $i < $length; $i++ )
$private_key .= substr($strings2, mt_rand(0, strlen($strings2) - 1), 1);
return $private_key;
}
$Public_key = public_key();
//$Public_key = KVQP0LdJKRaV3n9D使用了mt_rand获取随机字符,而它是伪随机的,可以用php_mt_seed破解。
先把公钥转换
用php_mt_seed计算随机数种子,得到结果1775196155

在返回头可以看到PHP版本为5.6.40,在该版本下用得到的随机数种子运行private_key()即可
再用万能密码登录即可

最后更新于