A-A+
php screw 解密 破解方法
PHP Screw是一个PHP加密工具。当您使用PHP开发商业软件包时,该脚本可以帮您实现脚本加密,保护您的知识产权。
PHP Screw加密解密算法
效果

PHP Screw解密
条件
- 加密key密钥
IDA获取加密key
现在尝试用ida64进行静态分析,获取隐藏在so文件中的密钥。密过程是在pm9screw_ext_fopen函数中实现的,所以只需要到这个函数中去找加密部分即可。
项⽬进⾏解密,步骤如下:
1、获取密钥
假如已有密钥,可直接跳过此步骤。有 php_screw.so ⽂件但没有密钥的情况下,则需要反编译此⽂件来查找密钥,使⽤IDA来获取密钥⽅式有两种,步骤分别如下:
⾸先可以通过命令 find / -name *screw*.so 找到 php_screw.so ⽂件,然后通过 IDA64 打开。

找到pm9screw_ext_fopen函数,双击,如图4所示:

然后右边的窗口就会如图5所示:

很明显,我标黄的就是加密密钥了,双击跳转至其指针保存处:

再次双击,跟踪变量,见下图7,打码处就是密钥了。

如下图8,右键,将十六进制的密钥转成十进制的,然后打开screwdecode.c,见下图9,将密钥替换掉,即可使用screw_decode解密。

软件包:https://github.com/firebroo/screw_decode

然后把文件和python 解密脚本放在一起。
Python解密
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 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 52 53 54 55 | # coding:utf-8
import os
import shutil
import zlib
PM9SCREW = b'\tPM9SCREW\t'
PM9SCREW_LEN = len(PM9SCREW)
pm9screw_mycryptkey = [11152, 368, 192, 1281, 62]
cryptkey_len = len(pm9screw_mycryptkey)
def decrypt(path, write=True):
data = bytearray(open(path, 'rb').read())
if len(data) < PM9SCREW_LEN:
return False
if data[:PM9SCREW_LEN] != PM9SCREW:
return False
data = data[PM9SCREW_LEN:]
data_len = len(data)
out = bytearray(data_len)
for i in range(data_len):
out[i] = (pm9screw_mycryptkey[(data_len - i) % cryptkey_len]
^ (~data[i])) % 256
try:
new = zlib.decompress(out)
except TypeError:
new = zlib.decompress(bytes(out)).encode()
if write:
shutil.move(path, path + ".bak")
open(path, 'wb').write(new)
else:
print(new)
def multi_decrypt(path):
if not os.path.exists(path):
print('Error: %s not Found.' % path)
return
if os.path.isdir(path):
folder = os.walk(path)
for fpathe, dirs, fs in folder:
for f in fs:
if f.endswith('.php'):
decrypt(os.path.join(fpathe, f), True)
else:
decrypt(path)
if __name__ == '__main__':
multi_decrypt('./') |
或者直接下载:https://github.com/Skactor/php_screw-decrypt 然后更改对应文件即可。
文章来源:https://www.uedbox.com/post/58666/
布施恩德可便相知重
微信扫一扫打赏
支付宝扫一扫打赏