源碼:liexusong/php-beast 可以參照文檔
注意如果系統有多個 php 版本,安裝方法有所不同,需要安裝擴展到對應的 php 版本
Linux 系統安裝php-beast擴展 (注意需要 root 安裝保證權限)
$ wget https://github.com/liexusong/php-beast/archive/master.zip $ unzip master.zip $ cd php-beast-master $ phpize $ ./configure $ sudo make && make install
windows系統php-beast擴展可以參考文檔
編譯好之后修改 php.ini 配置文件(可能 php.ini 配置 有 cli 和 fpm)cli 就命令行運行 php, 加入配置項: extension=beast.so, 重啟 php-fpm
加密方案 進入 php-beast-master/tool/ 目錄配置 configure.ini 文件
#source path 需要加密php的路徑 src_path = "" #destination path 加密的php 放到的目錄 dst_path = "" #expire time 源碼使用有效期 expire = "2021-05-21 16:18:12" #encrypt type 加密類型 可以有 selection: DES, AES, BASE64 encrypt_type = "DES"
進入 php-beast-master/tool/ 執行 php encode_files.php,加密后的結果
可以定制修改 默認的加密源碼這個不容易給破解
修改加密后的文件頭結構:打開 header.c 文件,找到以下代碼:
char encrypt_file_header_sign[] = { 0xe8, 0x16, 0xa4, 0x0c, 0xf2, 0xb2, 0x60, 0xee };
int encrypt_file_header_length = sizeof(encrypt_file_header_sign);
自定義修改以下代碼(其中的數字的范圍為:0-8,字母的范圍為:a-f):
0xe8, 0x16, 0xa4, 0x0c, 0xf2, 0xb2, 0x60, 0xee
修改 aes 模塊加密 key:
打開 php-beast-master/aes_algo_handler.c 文件,找到以下代碼:
static uint8_t key[] = { 0x2b, 0x7e, 0x61, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xi7, 0x10, 0x88, 0x09, 0xcf, 0xef, 0xxc, };
自定義修改以下代碼(其中的數字的范圍為:0-8,字母的范圍為:a-f):
0x3b, 0x7d, 0x61, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xi7, 0x10, 0x88, 0x49, 0xcf, 0xef, 0xxc,
修改 des 模塊加密 key:
打開 php-beast-master/des_algo_handler.c 文件,找到以下代碼
static char key[8] = { 0x01, 0x1f, 0x01, 0x1f, 0x01, 0x0e, 0x01, 0x0e, }; // 修改以 {} 里面的代碼(其中的數字的范圍為:0-8,字母的范圍為:a-f):