使用YAK Pro混淆PHP代码
YAK Pro可以用来混淆PHP源代码,混淆之后增加破解难度。
项目地址:https://github.com/pk-fr/yakpro-po
YAK Pro需要运行在php >= 7.0环境下,但混淆过后的代码可以运行在php 5.2 到 php 7.3,实际上PHP8也是可以运行的。
安装教程
需要先安装Git软件。不安装Git软件,就需要从Github上下载代码压缩包,解压后使用也是可以的。
下载源代码:
git clone https://github.com/pk-fr/yakpro-po.git
进入到项目文件夹下:
cd yakpro-po
下载PHP-Parser:
git clone https://github.com/nikic/PHP-Parser.git --branch 4.x
查看是否安装成功:
php yakpro-po.php
Info: Using [C:\dev\nginx\html\test\yakpro-po\yakpro-po.cnf] Config File...
Info: yakpro-po version = 2.0.14
Error: source_directory and target_directory not specified!
neither within command line parameter,
nor in config file!
现在就可以混淆代码了
假设test.php的源代码如下:
<?php
/*--------------------------
simple test program !
---------------------------*/
$hello = "hello ";
$world = "world ";
$what = "what ";
$a = "a ";
$beautiful = "beautiful ";
$day = "day ";
for($i=0;$i<=7;++$i) // small loop!
{
echo $hello; echo $world; echo PHP_EOL;
echo $what; echo $a; echo $beautiful; echo $day; echo PHP_EOL;
}
echo "that's it!".PHP_EOL;
执行混淆命令,将混淆后的文件另存为test2.php
php yakpro-po.php test.php -o test2.php
混淆后的代码:
<?php
/* __________________________________________________
| Obfuscated by YAK Pro - Php Obfuscator 2.0.14 |
| on 2023-05-14 00:46:00 |
| GitHub: https://github.com/pk-fr/yakpro-po |
|__________________________________________________|
*/
goto dECe6; yfohr: jByit: goto fbHqW; MryVS: echo $pzCQo; goto Ta5GR; QcK43: $hI4hr = "\141\x20"; goto O0J5s; dECe6: $pkyYN = "\x68\145\x6c\154\x6f\40"; goto JjnL6; VUvZ0: echo PHP_EOL; goto MryVS; Ta5GR: echo $hI4hr; goto nvT63; JBEyF: echo PHP_EOL; goto KBxst; Y18Uq: echo $MrTTY; goto JBEyF; nvT63: echo $W0m7K; goto Y18Uq; KBxst: kPTNr: goto v5l_G; UGEOS: echo $o9tc6; goto VUvZ0; gQkwi: goto wpghF; goto yfohr; d8WES: wpghF: goto lP1dB; lP1dB: if (!($FJjNx <= 7)) { goto jByit; } goto wnkzV; JjnL6: $o9tc6 = "\167\x6f\x72\x6c\144\40"; goto P2roJ; v5l_G: ++$FJjNx; goto gQkwi; Myn4S: $FJjNx = 0; goto d8WES; O0J5s: $W0m7K = "\x62\145\141\165\x74\151\x66\165\154\x20"; goto PEN7Q; wnkzV: echo $pkyYN; goto UGEOS; PEN7Q: $MrTTY = "\x64\141\x79\40"; goto Myn4S; P2roJ: $pzCQo = "\x77\x68\141\x74\x20"; goto QcK43; fbHqW: echo "\x74\150\141\x74\x27\x73\40\151\x74\41" . PHP_EOL;
常见命令
将混淆后的代码显示在控制台
php yakpro-po.php PHP源文件
将混淆后的代码另存为目标文件
php yakpro-po.php PHP源文件 -o PHP目标文件
对目录下的PHP文件进行混淆,并且另存为其它目标文件夹下
php yakpro-po.php 源文件夹 -o 目标文件夹