PHP 编码和混淆
PHP encoding and obfuscation
我一直在努力理解下面的代码在做什么。在基本层面上,我理解解码过程在做什么,但是,一旦到达 for 循环,它就会变得有点混乱。基本上,我正在尝试采用以下内容并编写一个适当的编码器,这将使我能够重用下面的解码例程。我用它来混淆 PHP 脚本。
有没有人愿意在以下方面提供帮助,并提供指导,说明我如何能够编写此(编码器)与提供的解码方法的逆向?
非常感谢任何帮助。
<?php
$B_yhp='bCtyDEF7u+8SszsSu+kgCO5ydU+XgC8PCVdhu1jwM7cyDU6dY0V7URbSZ/';
$L_qmfd=base64_decode($B_yhp);
for($i=0; $i<strlen($L_qmfd); $i++)
{
$L_qmfd[$i]=chr(ord($L_qmfd[$i])^((91403)%256));
}
$Laz_ep=@gzinflate(strrev($L_qmfd));
//Use $Lax_ep to generate a function IE:
//create_function('$runtime',$Laz_ep);
?>
已编辑:
我尝试使用以下内容创建编码器,但我认为我遗漏了/做错了什么。 CRC 值最终没有匹配,php 代码没有成功解码到它的原始状态,所以我知道我显然错过了一步或忽略了这里的某些东西。
<?php
$hash = hash_file('crc32b', $argv[1]);
$array = unpack('N', pack('H*', $hash));
$crc32 = $array[1];
printf("CRC: %u\n",$crc32);
$content = file_get_contents($argv[1]);
$content = strrev($content);
$content = gzdeflate($content, 9);
for($i=0; $i<strlen($content); $i++)
{
$content[$i]=chr( ord($content[$i])^((91403)%256));
}
$content=base64_encode($content);
file_put_contents($argv[1]. ".packed",$content);
?>
您按错误的顺序执行 gzdeflate
和 strrev
。先做gzdeflate
,然后反转泄气的$content
.
<?php
$hash = hash_file('crc32b', $argv[1]);
$array = unpack('N', pack('H*', $hash));
$crc32 = $array[1];
printf("CRC: %u\n",$crc32);
$content = file_get_contents($argv[1]);
$content = gzdeflate($content, 9); // Swapped these
$content = strrev($content); // two lines
for($i=0; $i<strlen($content); $i++)
{
$content[$i]=chr( ord($content[$i])^((91403)%256));
}
$content=base64_encode($content);
file_put_contents($argv[1]. ".packed",$content);
?>
我一直在努力理解下面的代码在做什么。在基本层面上,我理解解码过程在做什么,但是,一旦到达 for 循环,它就会变得有点混乱。基本上,我正在尝试采用以下内容并编写一个适当的编码器,这将使我能够重用下面的解码例程。我用它来混淆 PHP 脚本。
有没有人愿意在以下方面提供帮助,并提供指导,说明我如何能够编写此(编码器)与提供的解码方法的逆向?
非常感谢任何帮助。
<?php
$B_yhp='bCtyDEF7u+8SszsSu+kgCO5ydU+XgC8PCVdhu1jwM7cyDU6dY0V7URbSZ/';
$L_qmfd=base64_decode($B_yhp);
for($i=0; $i<strlen($L_qmfd); $i++)
{
$L_qmfd[$i]=chr(ord($L_qmfd[$i])^((91403)%256));
}
$Laz_ep=@gzinflate(strrev($L_qmfd));
//Use $Lax_ep to generate a function IE:
//create_function('$runtime',$Laz_ep);
?>
已编辑:
我尝试使用以下内容创建编码器,但我认为我遗漏了/做错了什么。 CRC 值最终没有匹配,php 代码没有成功解码到它的原始状态,所以我知道我显然错过了一步或忽略了这里的某些东西。
<?php
$hash = hash_file('crc32b', $argv[1]);
$array = unpack('N', pack('H*', $hash));
$crc32 = $array[1];
printf("CRC: %u\n",$crc32);
$content = file_get_contents($argv[1]);
$content = strrev($content);
$content = gzdeflate($content, 9);
for($i=0; $i<strlen($content); $i++)
{
$content[$i]=chr( ord($content[$i])^((91403)%256));
}
$content=base64_encode($content);
file_put_contents($argv[1]. ".packed",$content);
?>
您按错误的顺序执行 gzdeflate
和 strrev
。先做gzdeflate
,然后反转泄气的$content
.
<?php
$hash = hash_file('crc32b', $argv[1]);
$array = unpack('N', pack('H*', $hash));
$crc32 = $array[1];
printf("CRC: %u\n",$crc32);
$content = file_get_contents($argv[1]);
$content = gzdeflate($content, 9); // Swapped these
$content = strrev($content); // two lines
for($i=0; $i<strlen($content); $i++)
{
$content[$i]=chr( ord($content[$i])^((91403)%256));
}
$content=base64_encode($content);
file_put_contents($argv[1]. ".packed",$content);
?>