eval(gzinflate(str_rot13(base64_decode('BASE64內容'))))
將 eval() 替換為 echo,捕獲輸出緩衝區內容,逐層剝離。
<?php
$a = "eval(gzinflate(str_rot13(base64_decode('...'))));";
function decodephp($a) {
$max = 300;
for ($i=0; $i<$max; $i++) {
ob_start();
eval(str_replace('eval', 'echo', $a));
$a = ob_get_clean();
if (strpos($a, 'eval(gzinflate(str_rot13(base64_decode') === false) return $a;
}
}
echo decodephp($a);
?>
<?php
$fp1 = fopen('coded.txt','r');
$c = fread($fp1, filesize('coded.txt')); fclose($fp1);
while (preg_match('/eval\(gzinflate/',$c)) {
$c = preg_replace('/<\?|\?>/','',$c);
eval(preg_replace('/eval/','$c=',$c));
}
file_put_contents('decoded.txt', trim($c));
?>
coded.txt(僅 eval(...) 內容)。decoded.txt。eval、gzinflate。防禦建議:伺服器啟用 disable_functions=eval,assert,create_function,採用程式碼簽名與完整性驗證。