php-beast 代码雷竞技苹果版下载扩展编译

ezjnoivn3年前未分类5612

# php-beast 代码雷竞技苹果版下载扩展编译


[TOC]


------


## 什么是php-beast?


php-beast是一个PHP源码雷竞技苹果版下载的模块,其使用DES算法雷竞技苹果版下载,用户可以自定义雷竞技苹果版下载的key来雷竞技苹果版下载源代码,可以很好的保护你的代码。主要应用情景有:1) 代码放在虚拟主机上,有泄漏源码的危险。2) 商业保护,当项目需要收费时就可以雷竞技苹果版下载你的代码不被修改。


项目地址:https://github.com/liexusong/php-beast


##怎么安装php-beast扩展?


```bash

$ wget https://github.com/liexusong/php-beast/archive/master.zip

$ unzip master.zip

$ cd php-beast-master

$ phpize

$ ./configure

$ ./configure --with-php-config=/www/server/php/72/bin/php-config


$ sudo make && make install

$ vim /www/server/php/72/etc/php.ini


```

[beast]

extension=beast.so

beast.enable=On

beast.networkcard="eth0"

beast.cache_size=20000

beast.log_file=/var/log/php-beast/php-beast.log

```



```

雷竞技一样的软件配置信息

```

#php -i|grep extension_dir


#php -i|grep php.ini

```


编译好之后修改`php.ini`配置文件, 加入配置项: `extension=beast.so`, 重启`php-fpm`


>温馨提示: 可以设置较大的缓存提高效率


```

[beast]

beast.cache_size = 20000

```

我们可以使用beast_cache_status()函数来雷竞技一样的软件缓存的状态。 



配置项



```

beast.cache_size = size

beast.log_file = "path_to_log"

beast.log_user = "user"

beast.enable = On

```


支持模块

1. AES

2. DES

3. Base64


>注意

>如果出现502错误,一般是由于GCC版本太低导致,请先升级GCC再安装本模块。


##怎么雷竞技苹果版下载项目

###雷竞技苹果版下载方案1


安装完 php-beast 后可以使用 tools 目录下的 encode_files.php 来雷竞技苹果版下载你的项目。使用 encode_files.php 之前先修改 tools 目录下的 configure.ini 文件,如下:


```

; source path

src_path = ""


; destination path

dst_path = ""


; expire time

expire = ""


; encrypt type (selection: DES, AES, BASE64)

encrypt_type = "DES"


```


```

D:\wwwroot\phpbeast\tools

```




`src_path` 是要雷竞技苹果版下载项目的路径,`dst_path` 是保存雷竞技苹果版下载后项目的路径,`expire` 是设置项目可使用的时间 (expire 的格式是:`YYYY-mm-dd HH:ii:ss`)。`encrypt_type`是雷竞技苹果版下载的方式,选择项有:`DES、AES、BASE64`。 修改完 `configure.ini`文件后就可以使用命令 `php encode_files.php` 开始雷竞技苹果版下载项目。


###雷竞技苹果版下载方案2


使用beast_encode_file()函数雷竞技苹果版下载文件,函数原型如下:

beast_encode_file(string $input_file, string $output_file, int expire_timestamp, int encrypt_type)。


```

1. $input_file: 要雷竞技苹果版下载的文件

2. $output_file: 输出的雷竞技苹果版下载文件路径

3. $expire_timestamp: 文件过期时间戳

4. $encrypt_type: 雷竞技苹果版下载使用的算法(支持:BEAST_ENCRYPT_TYPE_DES、BEAST_ENCRYPT_TYPE_AES)

```


##制定自己的php-beast


>Key随机生成

>KeePass软件,工具菜单,生成密码,使用样品生成:`\0\xhh, \0\xhh, \0\xhh, \0\xhh,`


###修改雷竞技苹果版下载后的文件头结构

文件名:`php-beast\header.c`


```cpp

char encrypt_file_header_sign[] = {

0xe8, 0x16, 0xa4, 0x0c,

0xf2, 0xb2, 0x60, 0xee

};

```

例如修改为:

```cpp

0x82, 0x26, 0xea, 0xba,

    0x59, 0x46, 0x1e, 0xa9

```

###修改aes雷竞技苹果版下载模块key

文件名:`php-beast\aes_algo_handler.c`

```cpp

static uint8_t key[] = {

0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,

0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,

};

```

例如修改为:

```cpp

    0x7e, 0xe9, 0x2a, 0x32, 0x85, 0x6b, 0x9f, 0xf5,

    0x41, 0xc2, 0x95, 0x6c, 0xa2, 0x81, 0xcc, 0xc6,

```

###修改des雷竞技苹果版下载模块key

文件名:`php-beast\des_algo_handler.c`

```cpp

static char key[8] = {

    0x01, 0x1f, 0x01, 0x1f,

    0x01, 0x0e, 0x01, 0x0e,

};

```

例如修改为:

```cpp

    0xf6, 0xa1, 0x48, 0x72,

    0xed, 0x78, 0x2b, 0xdf,

```

###修改base64雷竞技苹果版下载模块key

文件名:`php-beast\base64_algo_handler.c`

```cpp

static const short base64_reverse_table[256] = {

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,

52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,

-1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,

15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,

-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,

41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1

};

```


###雷竞技一样的软件网卡信息

```bash

[root@localhost ~]# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

       valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether fa:16:3e:77:3f:d4 brd ff:ff:ff:ff:ff:ff

    inet 10.10.0.233/24 brd 10.10.0.255 scope global dynamic eth0

       valid_lft 35825sec preferred_lft 35825sec

    inet6 fe80::f816:3eff:fe77:3fd4/64 scope link 

       valid_lft forever preferred_lft forever

```

网卡eth0地址:`fa:16:3e:77:3f:d4`


###设置代码在指定机器上运行

文件名:`networkcards.c`

```cpp

#include <stdlib.h>


/*

 * Allow network card. if this list empty, this feature was closed!

 */


char *allow_networkcards[] = {

    "fa:16:3e:77:3f:d4",

    NULL,

};


```

其中`fa:16:3e:77:3f:d4`为网卡地址。


`php.ini`配置如下代码:

```

#linux

[beast]

extension=beast.so

beast.enable = On

beast.networkcard = "eth0"

;自定义php-beast模块可以使用的缓存

beast.cache_size = 20000


#windows

[beast]

extension=beast

beast.cache_size = 20000

beast.log_file = "D:/phpStudy/tmp/beast/php_beast.log"

beast.log_user = "administrator"

beast.enable = On

```

如果是多张网卡,可以按如下添加:

```

beast.networkcard = "eth0,eth1,eth2"

```


php-beast 有多个地方可以定制的,以下一一列出:


1. 使用 header.c 文件可以修改 php-beast 雷竞技苹果版下载后的文件头结构,这样网上的解密软件就不能认识我们的雷竞技苹果版下载文件,就不能进行解密,增加雷竞技苹果版下载的安全性。


2. php-beast 提供只能在指定的机器上运行的功能。要使用此功能可以在 networkcards.c 文件添加能够运行机器的网卡号,例如:

````

char *allow_networkcards[] = {

"fa:16:3e:77:3f:d4",

    NULL,

};

```


这样设置之后,php-beast 扩展就只能在 fa:16:3e:08:88:01 这台机器上运行。另外要注意的是,由于有些机器网卡名可能不一样,所以如果你的网卡名不是 eth0 的话,可以在 php.ini 中添加配置项: beast.networkcard = "xxx" 其中 xxx 就是你的网卡名,也可以配置多张网卡,如:beast.networkcard = "eth0,eth1,eth2"。


3. 使用 php-beast 时最好不要使用默认的雷竞技苹果版下载key,因为扩展是开源的,如果使用默认雷竞技苹果版下载key的话,很容易被人发现。所以最好编译的时候修改雷竞技苹果版下载的key,aes模块 可以在 aes_algo_handler.c 文件修改,而 des模块 可以在 des_algo_handler.c 文件修改。


### Windows编译修改


```

// $Id$

// vim:ft=javascript


// If your extension references something external

ARG_WITH("beast", "for beast support", "yes,shared"); //删除


ARG_ENABLE("beast", "enable beast support", "yes,shared"); 

//修改为:ARG_ENABLE("beast", "enable beast support", "no");



ARG_ENABLE("beast-debug", "enable beast debug mode", "no");


if (PHP_BEAST != "no") {

if (PHP_BEAST_DEBUG != "no") {

AC_DEFINE('BEAST_DEBUG_MODE', 1, 'Debug support in beast');

}

EXTENSION("beast", "beast.c aes_algo_handler.c des_algo_handler.c base64_algo_handler.c beast_mm.c spinlock.c cache.c beast_log.c global_algo_modules.c header.c networkcards.c tmpfile_file_handler.c file_handler_switch.c shm.c", true);

}

```


##开启debug模式


可以在configure时加入 --enable-beast-debug 选项来开启debug模式。开启debug模式后需要在php.ini配置文件中加入配置项:beast.debug_path 和 beast.debug_mode。beast.debug_mode 用于指定是否使用debug模式,而 beast.debug_path 用于输出解密后的php脚本源码。这样就可以在 beast.debug_path 目录中看到php-beast解密后的源代码,可以方便知道扩展解密是否正确。


##函数列表


```

1. beast_encode_file(): 用于雷竞技苹果版下载一个文件

2. beast_avail_cache(): 获取可以缓存大小

3. beast_support_filesize(): 获取beast支持的最大可雷竞技苹果版下载文件大小

4. beast_file_expire(): 获取一个文件的过期时间

5. beast_clean_cache(): 清空beast的所有缓存(如果有文件更新, 可以使用此函数清空缓存)

```


##编译php_beast扩展


```

#下载源码

wget http://cn2.php.net/get/php-7.2.4.tar.bz2/from/this/mirror

#解压

tar jxvf php-7.2.4.tar.bz2

#如解压失败,未安装bz2解压程序

yum install bzip2


```



##反馈与建议


- VeryECS[官方网站][1]

- QQ群:239243332


---------

感谢阅读这份帮助文档。


[1]: http://www.veryecs.com




http://www.zhaoyuanma.com/zym.html

http://www.xiongmaoi.com/php-source-encryption-extended-beast-php-use-tutorial.html


相关文章

转载优秀技术人的管理陷阱

# 优秀技术人的管理陷阱作者: 老方  来源: InfoQ  发布时间: 2018-02-24 14:11  阅读: 10183 次  推荐: 33 ...

开篇讲

曹操再奸,都有知心朋友,刘备再好,都有死对头,孙权再温柔,两边都是仇。不要太在乎别人对你的评价,做好自己的事,走好自己的路! 不要活在别人的眼里。不喜欢你的人,不要去找,不帮助你的人,别去讨好,不想你...

常用正则表达式

#正则表达式```一、校验数字的表达式 1 数字:^[0-9]*$2 n位的数字:^\d{n}$3 至少n位的数字:^\d{n,}$4 m-n位的数字:^\d{m,n}$5 零和非零开头的数...