sledgeh4w/chomper

GitHub: sledgeh4w/chomper

Chomper 是一个基于 Unicorn 引擎的轻量级仿真框架,旨在帮助开发者在无物理设备环境下仿真执行 iOS 及 Android 原生库中的安全算法。

Stars: 593 | Forks: 146

# Chomper [![build](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/3de5f4acfb175916.svg)](https://github.com/sledgeh4w/chomper/actions/workflows/tests.yml) ![PyPI](https://img.shields.io/pypi/v/chomper) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/chomper) [![GitHub license](https://img.shields.io/github/license/sledgeh4w/chomper)](https://github.com/sledgeh4w/chomper/blob/main/LICENSE) Chomper 是一个基于 [Unicorn](https://github.com/unicorn-engine/unicorn) 的轻量级仿真框架。它主要用于仿真 iOS 可执行文件和库中的安全算法。此外,它也为 Android 原生库提供了有限的支持。 ## 功能 - 仿真 ELF 和 Mach-O 二进制文件 - 支持 iOS 系统库的子集(来自 iOS 14.4.0) ## 环境要求 - Python 3.9+ - Unicorn 2.0.0+ ## 安装 从 PyPI 安装稳定版本: ``` $ pip install chomper ``` 或从 GitHub 安装最新版本: ``` $ pip install git+https://github.com/sledgeh4w/chomper.git ``` 克隆 rootfs 仓库: ``` $ git clone https://github.com/sledgeh4w/rootfs.git ``` ## 用法 仿真 iOS 可执行文件。 ``` from chomper import Chomper from chomper.const import ARCH_ARM64, OS_IOS # 对于 iOS,系统库将自动从 `rootfs_path` 加载 emu = Chomper( arch=ARCH_ARM64, os_type=OS_IOS, rootfs_path="rootfs/ios", ) # 加载程序 discover = emu.load_module("examples/binaries/ios/com.xingin.discover/8.74/discover") s = "Mocha" # 构造参数 input_str = emu.create_string(s) input_len = len(s) result_buf = emu.create_buffer(120) buf_size = 120 result_len_ptr = emu.create_buffer(8) # 调用函数 emu.call_address(discover.base + 0x324EF10, input_str, input_len, result_buf, buf_size, result_len_ptr) result = emu.read_string(result_buf) ``` 使用 Objective-C。 ``` from chomper import Chomper from chomper.const import ARCH_ARM64, OS_IOS from chomper.objc import ObjcRuntime emu = Chomper( arch=ARCH_ARM64, os_type=OS_IOS, rootfs_path="rootfs/ios", ) objc = ObjcRuntime(emu) emu.load_module("examples/binaries/ios/cn.com.scal.sichuanair/zsch") # 使用此 context manager 确保 Objective-C 对象可以自动释放 with objc.autorelease_pool(): # Find class zsch_rsa_class = objc.find_class("ZSCHRSA") # Create NSString object input_str = objc.create_ns_string("Mocha") # Call Objective-C method req_sign = zsch_rsa_class.call_method("getReqSign:", input_str) # Convert NSString object to C string result_ptr = req_sign.call_method("UTF8String") result = emu.read_string(result_ptr) ``` 仿真 Android 原生库。 ``` from chomper import Chomper from chomper.const import ARCH_ARM64, OS_ANDROID emu = Chomper( arch=ARCH_ARM64, os_type=OS_ANDROID, rootfs_path="rootfs/android", ) # 加载依赖库 emu.load_module("rootfs/android/system/lib64/libz.so") libszstone = emu.load_module("examples/binaries/android/com.shizhuang.duapp/libszstone.so") s = "Mocha" input_str = emu.create_string(s) input_len = len(s) result_buf = emu.create_buffer(1024) result_len = emu.call_address(libszstone.base + 0x2F1C8, input_str, input_len, result_buf) result = emu.read_bytes(result_buf, result_len) ``` ## 示例 在 [algorithms](https://github.com/sledgeh4w/chomper/tree/main/examples/algorithms) 中有一些安全算法仿真代码。
标签:Android逆向, ARM64, ELF, iOS安全, Mach-O, Objective-C运行时, Python框架, Rootfs, Unicorn引擎, 二进制模拟, 云资产清单, 安全算法模拟, 目录枚举, 移动安全, 逆向工具, 逆向工程, 静态分析辅助