Skip to main content

A lightweight emulation framework for emulating security algorithms of iOS executables and libraries.

Project description

Chomper

build PyPI PyPI - Python Version GitHub license

Chomper is a lightweight emulation framework based on Unicorn. It is mainly used to emulate security algorithms in iOS executables and libraries. In addition, it also provides limited support for Android native libraries.

Features

  • Emulation of ELF and Mach-O binaries
  • Support for a subset of iOS system libraries (from iOS 14.4.0)

Requirements

  • Python 3.9+
  • Unicorn 2.0.0+

Installation

Install the stable version from PyPI:

$ pip install chomper

Or install the latest version from GitHub:

$ pip install git+https://github.com/sledgeh4w/chomper.git

Clone rootfs repository:

$ git clone https://github.com/sledgeh4w/rootfs.git

Usage

Emulate iOS executables.

from chomper import Chomper
from chomper.const import ARCH_ARM64, OS_IOS

# For iOS, system libraries will be automatically loaded from `rootfs_path`
emu = Chomper(
    arch=ARCH_ARM64,
    os_type=OS_IOS,
    rootfs_path="rootfs/ios",
)

# Load program
discover = emu.load_module("examples/binaries/ios/com.xingin.discover/8.74/discover")

s = "Mocha"

# Construct arguments
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)

# Call function
emu.call_address(discover.base + 0x324EF10, input_str, input_len, result_buf, buf_size, result_len_ptr)

result_len = emu.read_u64(result_len_ptr)
result = emu.read_bytes(result_buf, result_len)

Working with 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")

# Use this context manager to ensure that Objective-C objects can be automatically released
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)

Emulate Android native libraries.

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",
)

# Load dependency libraries
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)

Examples

There are some security algorithm emulation codes in algorithms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chomper-0.3.8.tar.gz (96.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chomper-0.3.8-py3-none-any.whl (99.3 kB view details)

Uploaded Python 3

File details

Details for the file chomper-0.3.8.tar.gz.

File metadata

  • Download URL: chomper-0.3.8.tar.gz
  • Upload date:
  • Size: 96.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for chomper-0.3.8.tar.gz
Algorithm Hash digest
SHA256 2fc919ccb5b55915c91b4db9e349d53864dfa26c8bddb9d743e79f5ac0788755
MD5 5942c3373957686b37ca47dda6d2bc14
BLAKE2b-256 df4e2eb06c4eeae46cce8880b355aa83081d51da66f5f4e33809669c0197a3a8

See more details on using hashes here.

File details

Details for the file chomper-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: chomper-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 99.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for chomper-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a305ffdbc2b36e1283511d0b2a140daeff4df5b49659a29ba6f7ad0eaf751beb
MD5 45badd1eeb4bfc3336955bc839a88c82
BLAKE2b-256 20ae82019ce8ae606273fdca475c485c18e7d915b9806ae25b59ef1ec89fcbd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page