Author: In Ming Loh (inming.loh@countercept.com - @tantaryu) <br />
Company: Countercept (@countercept) <br />
Website: https://www.countercept.com <br />
## Introduction
A script that helps researcher to unpack and decompile executable written in python. However, right now this only supports executable created with py2exe and pyinstaller.
This script glues together several tools available to the community. Hopefully, this can help people in their daily job. Several YARA rules are available to determine if the executable is written in python (This script also confirms if the executable is created with either py2exe or pyinstaller).
## Requirements
- Python 2.7 or later.
- Install all the dependency needed:<br/>
`pip2 install --user -r requirements.txt`<br/>
or if you fancy to have your dependency installed with root permission<br/>
`sudo pip2 install -r requirements.txt`
## Getting Started
- python python_exe_unpack.py -i [malware.exe]
* pyinstaller
* A folder will be created with the original filename concatenated with "_extracted". For example: "malware.exe_extracted".
* The main python file that contains the logic will usually be the file without any extension (In the folder that concatenated with "_extracted"). In the following example, "hello" is the one that contains the main python logic:<br/>
`-rw-rw-r-- 1 testuser testuser 70K Nov 14 13:08 bz2.pyd`<br/>
`-rw-rw-r-- 1 testuser testuser 993K Nov 14 13:08 _hashlib.pyd`<br/>
`-rw-rw-r-- 1 testuser testuser 111 Nov 14 13:08 hello`<br/>
`-rw-rw-r-- 1 testuser testuser 1009 Nov 14 13:08 hello.exe.manifest`<br/>
`-rw-rw-r-- 1 testuser testuser 1.1K Nov 14 13:08 Microsoft.VC90.CRT.manifest`<br/>
`-rw-rw-r-- 1 testuser testuser 220K Nov 14 13:08 msvcm90.dll`<br/>
`-rw-rw-r-- 1 testuser testuser 557K Nov 14 13:08 msvcp90.dll`<br/>
`-rw-rw-r-- 1 testuser testuser 638K Nov 14 13:08 msvcr90.dll`<br/>
`-rw-rw-r-- 1 testuser testuser 628K Nov 14 13:08 out00-PYZ.pyz`<br/>
`drwxrwxr-x 2 testuser testuser 12K Nov 14 13:08 out00-PYZ.pyz_extracted`<br/>
`-rw-rw-r-- 1 testuser testuser 5.2K Nov 14 13:08 pyiboot01_bootstrap`<br/>
`-rw-rw-r-- 1 testuser testuser 2.5K Nov 14 13:08 pyimod01_os_path`<br/>
`-rw-rw-r-- 1 testuser testuser 12K Nov 14 13:08 pyimod02_archive`<br/>
`-rw-rw-r-- 1 testuser testuser 22K Nov 14 13:08 pyimod03_importers`<br/>
`-rw-rw-r-- 1 testuser testuser 0 Nov 14 13:08 pyi-windows-manifest-filename hello.exe.manifest`<br/>
`-rw-rw-r-- 1 testuser testuser 2.6M Nov 14 13:08 python27.dll`<br/>
`-rw-rw-r-- 1 testuser testuser 10K Nov 14 13:08 select.pyd`<br/>
`-rw-rw-r-- 1 testuser testuser 234 Nov 14 13:08 struct`<br/>
`-rw-rw-r-- 1 testuser testuser 671K Nov 14 13:08 unicodedata.pyd`<br/>
* pyinstaller has an option that can encrypt python bytecode. This script will try to decrypt it and decompile the decrypted code.
* py2exe
* The result of unpacking and decompiling will be located in folder "unpacked" or the location you specify.
* If error like this shows "Error in unpacking the exe. Probably due to version incompability (exe created using python 2 and run this script with python 3)", try setting your python to a different version than the one you are using. Eg: "alias python=python2" or "alias python=python3"
- python python_exe_unpack.py -p [pyc file]
* In the above example, sometimes the python file that contains the main logic will not be in the format that uncompyle6 accept (Missing python magic numbers). The above command will prepend magic numbers and decompile it (If magic number is already preprended it will not add it and just proceed with decompiling).
## Credits
- Extreme Coders for their pyinstxtractor.py script to help unpack pyinstaller executable.
- Extreme Coders for their instruction on how to decrypt encrypted python byte code: https://0xec.blogspot.sg/2017/02/extracting-encrypted-pyinstaller.html
- unpy2exe
- uncompyle6
徐浪老师
- 粉丝: 8585
- 资源: 1万+
最新资源
- 使用深度学习预测低压网络的电压分布 低电压(LV)电路的能量分布将发生变化,而以前的被动适应和-“忘记”的网络管理方法将是低效的,以确保其有效运行 需要一种自适应的方法,包括对电路风险的预测
- 小型六轴机器人样机,可二次开发,脉冲加方向,仪嘉控制器,
- 基于扩展卡尔曼滤波EKF和模型预测控制MPC,自动泊车场景建模开发,文复现 MATLAB(工程项目线上支持)
- (工程项目线上支持)横向控制,稳定性控制,直接横摆力矩控制 汽车电子稳定性控制建模仿真 包括模型和说明书 DYC, ESP
- 低成本dsp变频器方案,有C语言源码,编译码,PCB图纸,物料清单
- 三维重建程序~基于多视图几何的三维重建 代码特点: 1.使用osmbundler进行特征点提取与匹配; 2.使用cmvs进行稀疏点云的生成; 3.使用pmvs进行稠密点云的生成; 4.用户界面使用py
- 电动汽车动力系统整车仿真,具有双向DCDC变器实现能量反馈,可带异步电机,永磁同步电机仿真,应用最大转矩电流比控制加独特的弱磁控制策略
- 基于OpenCV的口罩识别系统 相关技术:python,opencv,pyqt (请自行安装向日葵远程软件,以便提供远程帮助) 软件说明:读取用户设备的摄像头,可实时检测画面中的人的口罩佩戴情况,并给
- matlab程序 研究方向:综合能源系统,微电网,主从博弈,合作,非合作博弈相关方向,多时间尺度
- 研究考虑综合需求响应和碳交易机制的冷、热、电、气4种能源形式的综合能源系统,系统内含能源设备主要包括光伏电源、风力机组、燃气轮机和燃气锅炉;储能系统主要包括储电设备蓄电池、储热设备蓄热槽;能量转设备包
- 研究考虑综合需求响应和碳交易机制的冷、热、电、气4种能源形式的综合能源系统,系统内含能源设备主要包括光伏电源、风力机组、燃气轮机和燃气锅炉;储能系统主要包括储电设备蓄电池、储热设备蓄热槽;能量转设备包
- labview自动化贴合设备程序 labview自动化贴合设备程序,包括上下CCD标定算法,9点标定,整机贴合精度0.1mm,边缘抓取全套源代码,标准架构,快速上手,其他项目快速适用
- system_ftnn_gbid.mp3
- stm32真实企业项目1,源码原理图PCB图,感谢已经拿后的多位客户,你们愿意为学习投资,节省时间 包含源码,原理图设计和pcb 项目要求与网上搜的那些开发板的例程完全不在一个级别,也不是那些凑合性质
- 提供基于comsol中相场方法模拟多孔介质两相驱替(水气、油水等等)的算例(也可以定做水平集驱替的算例),可在此基础上学会利用comsol软件进行两相流驱替的模拟,拓展研究,具体参考算例附后 附赠基
- C#,C#程序实例,C#与西门子,C#与西门子PLC通讯,C#与S7-200SMART以太网通讯,C#与西门子PLC通讯,原生Socket通讯,异步通讯,多线程操作,连接PLC数量没有限制,占用内存少
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈