Giter Site home page Giter Site logo

screw-plus's Introduction

php screw plus

20220621 screw plus不再进行维护,对加密运行有需求的朋友可转向screw opcode,基于opcode的加密,可为php提供更安全、高效的加密运行环境



github https://github.com/del-xiong/screw-plus
oschina http://git.oschina.net/splot/php-screw-plus

详细配置教程 http://www.jianshu.com/p/f6425e2f8643 (使用screw plus来保护php代码安全)

交流QQ群 530887505

支持版本: php 5.6-8.1
supported versions: php 5.6-8.1

简述

  • 2016/08/13更新:给screw增加批量解密功能
  • 2016/06/27更新:增加了STRICT_MODE,如果只允许服务器执行加过密的php文件,设置php_screw_plus.h STRICT_MODE为1(set STRICT_MODE to 1 if you only want the crypted php files to be executed),此举可防止黑客或其他人执行任意php文件。
  • 2016/06/24更新:改进了加密算法 使用高强度的AES256 CBC模式进行加密

基于php screw
主要做了以下改进:
增加了批量加密 更加方便
原生加密算法太弱易被破解,升级了加密算法,更加安全可靠
加密的优点:
可防止源码泄露,本程序是php扩展加密运行,只能在vps上运行,由于需要扩展进行动态解密,加密后被别人全部下载也无法被破解
商业源码可加密核心功能,只开放接口给客户
部分公司需要团队开发的,可防止源码泄露
其他。。。我编不出来了

效果演示

原生代码:

<?php
if(!defined('IN_COMSENZ')) {
  exit('Access Denied');
}

define('SOFT_NAME', 'Discuz!');

define('INSTALL_LANG', 'SC_UTF8');

define('CONFIG', './config/config_global.php');
define('CONFIG_UC', './config/config_ucenter.php');

加密后:

a57f658413a1a06742855           2盆閡?煉A%匛��I�f???骗叴�聒诧l膢*C??禳�颲??蜁爨t?犡�c?��毉TC誥1�%-?q1|9B鑐�/,擤`�M柼Vd`q?.r:婺X�o廰損??軋?�訍祔tq忄,?uj*坵括罸 ???�? -a�?A�?�硾亀浑湀(J蒷驗I榮CRd?~踾T? ~��r刜-�7嗎?炐z(9�.?
t0��+c箝侶Y漟W)?1�?吲i�碀
^P;y伙異战耠甿�F夺9�瓟�愕簎嵾*B續酉??�朴瀹)輤q��q疏?Ρo??_族��嬇R�緬?|?筹誀K�T钄籘79薗勜PhS恺�堨猞?j_�)及B盭w??吠辱c?ra?敺奓嵑$j鹳啎` ?秽⒗P鮡姩到
?羮?I?'湣挸]Ι話宛Lr 驜�腢瀶k辖K姲眯J��噤N?g喴邃彛¢梴k~?1�丛疫葘齍
o4芉!�#漫}�耑�-??朒漜垃�
芎wQa?)Dx�聢D?w�*鬿�<?笴!熹6#鲙��飯*W.吢濹酋咵攎:5隁?5鄨蚀?ク胍蠜?;V飉5?)笵f�餻傿輆l?迳???逢婉I蘈)退欺
瞰RX鹴?�地?\┄b槱馐?吕??嫇k釷,Pw7y0臈懚y?�??鴀�^ 屽�洵&戉_
蒈Z霃"�鮼昖靚6簝hS歉??O低盖??禜?啀Fm=???盾殝斺娎?A≡m-SWg祫a廠睛hV')/ぐE??友?徛7gU勭u脘愨赔?抇�/剡飃I-?穟?E愧憂=Bp=楱殓\d膛�*鱦鷂�?�鞦驲藛W;?疉陛菔��鐰?eYM葼乛飌间∫曖>�c�ケ�:嬺郠椦TY�魷 FJ??觺杠B`9€X]┚�呿�4?k娤?豯v?9??\螐廱�鲟�`漬\F?#假
�?S阮�??8邂璟襹B�跷沯�僯{��¬UI憤

使用方法:

  1. 下载本程序并解压到某个目录
  2. 在screw plus目录中执行php bin中的phpize自动生成扩展所需文件(如果你的php里没有可以去官网下载)
  3. 执行./configure --with-php-config=[php config path] 进行配置,[php config path]是你的php-config的绝对路径
  4. 修改php_screw_plus.h中的CAKEY,改为一个你认为安全的字符串
  5. 执行make生成扩展 modules/php_screw_plus.so
  6. 把扩展路径加入php.ini中 重启php
  7. 进入tools文件夹 执行make
  8. 执行./screw [目录或文件] ,后面带上你要加密的目录或文件即可自动开始加密

执行./screw [path] 是加密 后面加-d参数则是解密 例如

./screw /home/web/ -d

表示解密web目录的所有php文件

现在可以访问php文件,如果前面没有发生错误,应该可以正常执行了。

screw-plus's People

Contributors

bryant1410 avatar del-xiong avatar m9rco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

screw-plus's Issues

whether it support php 7.2 or not?

I have a warning when I completed installing.

The message like below:
PHP Startup: Invalid library (maybe not a PHP library) 'php_screw_plus.so' in Unknown on line 0

docker 放入 php_screw_plus.so

想请问能在docker容器中放入
不同环境产的php_screw_plus.so档跟修改php.ini设定档吗?

类似下面dockerfile 段落
COPY config/php_screw_plus.so /usr/lib/php7/modules/
RUN echo "extension=php_screw_plus.so" >> /etc/php7/php.ini

测过只能使用在dockerfile 执行make产 php_screw_plus.so档
还是我的设定上需要调整

我容器使用的环境
PHP 7.2.26 (cli) (built: Dec 22 2019 06:01:52) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

composer 无法使用

您好,启用扩展后 composer 无法使用的问题,现在有好的解决方案了吗?

make时报错了,怎么解决呢?

[root@localhost screw_plus]# make
/bin/sh /home/screw_plus/libtool --mode=link cc -DPHP_ATOM_INC -I/home/screw_plus/include -I/home/screw_plus/main -I/home/screw_plus -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -o php_screw_plus.la -export-dynamic -avoid-version -prefer-pic -module -rpath /home/screw_plus/modules php_screw_plus.lo
libtool: link: `php_screw_plus.lo' is not a valid libtool object
make: *** [php_screw_plus.la] 错误 1

环境centOS7.0, PHP 7.0.7

Path Buffer Overflow

The path handed via command line is not checked for length and gets written into static buffer path[300], which can result in a buffer overflow. This could be fixed by using strncpy(path,argv[1], 299); in screw.c#43

编译so后的问题

编译了7.4下的so文件,又编译了7.3下的so文件,
用一个php文件在7.4下加密后,拿到7.3上不能使用,有遇到这样清情况的吗?

请问能否迁移运行环境

比如我在php5.5动态编译,如果我提取这个so文件当我重装服务器再安装php(或许版本会高于5.5)之后不知可否直接添加这个so文件和修改php.ini

composer命令会报错

安装配置完该扩展,执行composer install就会报错
#!/usr/bin/env php
*** buffer overflow detected ***: php terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7338f)[0x7f6af378e38f]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f6af3825c9c]
/lib/x86_64-linux-gnu/libc.so.6(+0x109b60)[0x7f6af3824b60]
/lib/x86_64-linux-gnu/libc.so.6(__fread_chk+0x13c)[0x7f6af382523c]
/usr/lib/php/20151012/php_screw_plus.so(pm9screw_ext_fopen+0xf7)[0x7f6ae5818737]
/usr/lib/php/20151012/php_screw_plus.so(pm9screw_compile_file+0xba)[0x7f6ae581890a]
php(compile_filename+0x95)[0x7f6af5515045]
php(+0x2d5867)[0x7f6af55ce867]

whether it supports PHP 7.2 or not?

My PHP version 7.2.10.

I had a warning when I completed installing.

the message like below:
PHP Startup: Invalid library (maybe not a PHP library) 'php_screw_plus.so' in Unknown on line 0

whether it support php 8.0.3 or not?

/usr/local/php8/code/php-screw-plus/php_screw_plus.c:73:85: error: expected ‘;’, ‘,’ or ‘)’ before ‘TSRMLS_DC’
ZEND_API zend_op_array *(*org_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
^
/usr/local/php8/code/php-screw-plus/php_screw_plus.c:75:87: error: expected ‘;’, ‘,’ or ‘)’ before ‘TSRMLS_DC’
ZEND_API zend_op_array *pm9screw_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC)
^
/usr/local/php8/code/php-screw-plus/php_screw_plus.c: In function ‘zm_startup_php_screw_plus’:
/usr/local/php8/code/php-screw-plus/php_screw_plus.c:145:3: error: ‘org_compile_file’ undeclared (first use in this function)
org_compile_file = zend_compile_file;
^
/usr/local/php8/code/php-screw-plus/php_screw_plus.c:145:3: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/php8/code/php-screw-plus/php_screw_plus.c:146:23: error: ‘pm9screw_compile_file’ undeclared (first use in this function)
zend_compile_file = pm9screw_compile_file;
^
/usr/local/php8/code/php-screw-plus/php_screw_plus.c: In function ‘zm_shutdown_php_screw_plus’:
/usr/local/php8/code/php-screw-plus/php_screw_plus.c:153:23: error: ‘org_compile_file’ undeclared (first use in this function)
zend_compile_file = org_compile_file;
make: *** [php_screw_plus.lo] Error 1

php5.5.1编译时报错

/bin/sh /root/screw-plus-master/libtool --mode=compile cc -I. -I/root/screw-plus-master -DPHP_ATOM_INC -I/root/screw-plus-master/include -I/root/screw-plus-master/main -I/root/screw-plus-master -I/Data/apps/php/include/php -I/Data/apps/php/include/php/main -I/Data/apps/php/include/php/TSRM -I/Data/apps/php/include/php/Zend -I/Data/apps/php/include/php/ext -I/Data/apps/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/screw-plus-master/php_screw_plus.c -o php_screw_plus.lo
mkdir .libs
cc -I. -I/root/screw-plus-master -DPHP_ATOM_INC -I/root/screw-plus-master/include -I/root/screw-plus-master/main -I/root/screw-plus-master -I/Data/apps/php/include/php -I/Data/apps/php/include/php/main -I/Data/apps/php/include/php/TSRM -I/Data/apps/php/include/php/Zend -I/Data/apps/php/include/php/ext -I/Data/apps/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/screw-plus-master/php_screw_plus.c -fPIC -DPIC -o .libs/php_screw_plus.o
/root/screw-plus-master/php_screw_plus.c: 在函数‘pm9screw_compile_file’中:
/root/screw-plus-master/php_screw_plus.c:95: 错误:提供给函数‘zend_fopen’的实参太少
/root/screw-plus-master/php_screw_plus.c:97: 错误:提供给函数‘org_compile_file’的实参太少
/root/screw-plus-master/php_screw_plus.c:106: 错误:提供给函数‘org_compile_file’的实参太少
make: *** [php_screw_plus.lo] 错误 1
能帮忙解决一下吗

php 7.4 无法编译

➜  screw-plus git:(master) ✗ make
/bin/sh /tmp/screw-plus/libtool --mode=compile cc  -I. -I/tmp/screw-plus -DPHP_ATOM_INC -I/tmp/screw-plus/include -I/tmp/screw-plus/main -I/tmp/screw-plus -I/usr/local/Cellar/php/7.4.3/include/php -I/usr/local/Cellar/php/7.4.3/include/php/main -I/usr/local/Cellar/php/7.4.3/include/php/TSRM -I/usr/local/Cellar/php/7.4.3/include/php/Zend -I/usr/local/Cellar/php/7.4.3/include/php/ext -I/usr/local/Cellar/php/7.4.3/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/screw-plus/php_screw_plus.c -o php_screw_plus.lo
mkdir .libs
 cc -I. -I/tmp/screw-plus -DPHP_ATOM_INC -I/tmp/screw-plus/include -I/tmp/screw-plus/main -I/tmp/screw-plus -I/usr/local/Cellar/php/7.4.3/include/php -I/usr/local/Cellar/php/7.4.3/include/php/main -I/usr/local/Cellar/php/7.4.3/include/php/TSRM -I/usr/local/Cellar/php/7.4.3/include/php/Zend -I/usr/local/Cellar/php/7.4.3/include/php/ext -I/usr/local/Cellar/php/7.4.3/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/screw-plus/php_screw_plus.c  -fno-common -DPIC -o .libs/php_screw_plus.o
In file included from /tmp/screw-plus/php_screw_plus.c:20:
In file included from ./md5.h:49:
./md5.c:170:20: warning: passing 'char *' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    MD5Update(&md5,str,strlen(str));
                   ^~~
./md5.c:17:48: note: passing argument to parameter 'input' here
void MD5Update(MD5_CTX *context,unsigned char *input,unsigned int inputlen)
                                               ^
./md5.c:167:26: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess]
    memset(dest,0,sizeof(dest));
           ~~~~          ^~~~
./md5.c:167:26: note: did you mean to provide an explicit length?
    memset(dest,0,sizeof(dest));
                         ^~~~
/tmp/screw-plus/php_screw_plus.c:54:17: warning: passing 'char *' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between pointers to integer types with
      different sign [-Wpointer-sign]
    screw_aes(0,datap,datalen,key,&datalen);
                ^~~~~
./aes_crypt.c:4:35: note: passing argument to parameter 'buf' here
void screw_aes(int crypt,uint8_t *buf,int bufLen,uint8_t *key,int *rLen){
                                  ^
/tmp/screw-plus/php_screw_plus.c:44:27: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *'
      [-Wsizeof-pointer-memaccess]
  memset(datap, 0, sizeof(datap));
         ~~~~~            ^~~~~
/tmp/screw-plus/php_screw_plus.c:44:27: note: did you mean to provide an explicit length?
  memset(datap, 0, sizeof(datap));
                          ^~~~~
/tmp/screw-plus/php_screw_plus.c:106:28: error: use of undeclared identifier 'ZEND_HANDLE_FD'; did you mean 'ZEND_HANDLE_FP'?
  if (file_handle->type == ZEND_HANDLE_FD) close(file_handle->handle.fd);
                           ^~~~~~~~~~~~~~
                           ZEND_HANDLE_FP
/usr/local/Cellar/php/7.4.3/include/php/Zend/zend_stream.h:39:2: note: 'ZEND_HANDLE_FP' declared here
        ZEND_HANDLE_FP,
        ^
/tmp/screw-plus/php_screw_plus.c:106:70: error: no member named 'fd' in 'union _zend_file_handle::(anonymous at /usr/local/Cellar/php/7.4.3/include/php/Zend/zend_stream.h:52:2)'
  if (file_handle->type == ZEND_HANDLE_FD) close(file_handle->handle.fd);
                                                 ~~~~~~~~~~~~~~~~~~~ ^
4 warnings and 2 errors generated.
make: *** [php_screw_plus.lo] Error 1

不明白为什么用md5

感谢提供扩展!
只是我看源码,md5(CAKEY)的使用很疑惑,为什么不直接指定一个md5后的new_key,而是每次动态运算?
如果是指定值,那么理论上应该不必再加载md5模块,而且也不必再每次计算,是否更好?

网上已经出现这个加密的破解

提供so和加密文件可百分百解密,

老大是否考虑再升级加强一下呢?因为有些场景,比如程序给客户了,客户自己的服务器,这种场景很常见,然后他肯定有SO也有加密文件!

composer 命令报错

安装扩展后,加密laravel5.6版本的项目,再执行composer会报错:
Warning: Unexpected character in input: ' in phar:///usr/bin/composer/bin/composer on line 57

另外:php artisan执行后,新添加的命令也无法执行

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.