kittymemory-rs
Production-ready Rust bindings for KittyMemory — a comprehensive memory manipulation library for Android and iOS.
⚠️ Important: Use version 0.3.0 or higher. Version 0.3.0 includes complete feature parity with the original KittyMemory library with 100+ new functions and advanced capabilities.
Note: The
keystonefeature for assembly patching is currently experimental and may have build issues. Use hex/bytes patching for production. Windows currentely is not supported, you might get errors if you try to build it in a windows pc, its recomanded to use WSL2 to compile it for android.
Features
Core Functionality
- Memory Operations: Read, write, and protect memory with automatic permission handling
- Syscall Memory Operations: Alternative memory read/write using syscalls (Android)
- Memory Dumping: Dump memory regions or memory-mapped files to disk
- Memory Patching: Create patches from bytes, hex strings, or assembly code (with Keystone)
- Patch Inspection: Get current, original, and patch bytes as hex strings
- Memory Backup: Save and restore memory regions with byte inspection
- Pattern Scanning: Find byte patterns, hex patterns, IDA-style patterns, or arbitrary data
- Pointer Validation: Verify if pointers are readable, writable, or executable
Android-Specific Features
- ELF Scanner: Comprehensive ELF analysis with symbol lookup, debug symbols, and metadata
- Advanced ELF Introspection: Access program headers, dynamic section, hash tables, string/symbol tables
- LinkerScanner: Access Android linker internals and enumerate all loaded libraries
- LinkerScanner Extensions: Get somain and sonext library information
- NativeBridgeScanner: Full support for x86/x86_64 emulation on ARM (Houdini detection)
- NativeBridgeLinker: dlopen, dlsym, dlerror, dladdr operations for native bridge
- Process Maps: Parse and filter /proc/self/maps entries with helper methods
- ProcMap Helpers: Validate maps, check for ELF headers, test address containment
- RegisterNativeFn: Find JNI native method registrations by name and signature
- SoInfo Access: Get detailed information about loaded shared objects
- Android System Info: Get Android version, SDK level, and external storage path
iOS-Specific Features
- MemoryFileInfo: Access Mach-O binary information for dylibs and frameworks
- Segment/Section Access: Query __TEXT, __DATA and other segments/sections
- Symbol Lookup: Find symbols in specific files or libraries
- Address Translation: Convert relative offsets to absolute addresses
Utility Functions
- Hex Conversion: Convert between bytes and hex strings with validation
- Hex Dump: Format memory dumps with ASCII representation
- Page Helpers: Calculate page-aligned addresses
- File Operations: Complete file I/O abstraction (read, write, copy, delete, stat)
- String Utilities: String manipulation (trim, validation, random generation)
- File Path Utilities: Extract filename, directory, and extension from paths
- ZIP Utilities: List ZIP files, extract by offset, memory-map ZIP contents (Android)
Architecture
sys: Raw FFI bindings (auto-generated with bindgen)safe: Safe Rust wrappers with RAII and error handlingprelude: Convenient imports for common use cases
Installation
Add to your Cargo.toml:
[]
= "0.3" # Recommended: auto-updates to latest stable 0.3.x
With Keystone assembler support:
[]
= { = "0.3", = ["keystone"] }
Or from GitHub:
[]
= { = "https://github.com/rodroidmods/kittymemory-rs", = "main" }
Requirements
- Rust 1.70+
- C++ compiler (g++/clang++)
libclang(for bindgen)- Android NDK (for Android targets)
- Xcode (for iOS targets)
Quick Examples
Memory Operations
use *;
let addr = 0x12345678;
let value: i32 = mem_read?;
mem_write?;
Memory Patching
use *;
// Basic patching with absolute address
let mut patch = with_hex?;
patch.modify?;
patch.restore?;
Library-Based Patching (Android)
Create patches using library name + offset - just like the C++ API:
use *;
// Helper to convert hex string to offset
// Create patch using library name + offset (like C++ MemoryPatch::createWithHex)
let mut money_patch = with_hex_lib?;
money_patch.modify?;
// Or with raw bytes
let mut bytes_patch = with_bytes_lib?;
bytes_patch.modify?;
Assembly Patching (requires keystone feature)
// With absolute address
let mut patch = with_asm?;
patch.modify?;
// With library name + offset (Android only)
let mut asm_patch = with_asm_lib?;
Pattern Scanning
use *;
if let Some = find_pattern_first
let all_matches = find_hex_all;
for addr in all_matches
Android: ELF Scanner
use *;
let elf = find.expect;
if let Some = elf.find_symbol
println!;
println!;
println!;
Android: LinkerScanner
use *;
let linker = get;
for lib in linker.all_soinfo
if let Some = linker.find_soinfo
Android: Process Maps
use *;
let maps = get_all_maps;
for map in maps
let lib_maps = get_maps_filtered;
iOS: MemoryFileInfo
use *;
let base = get_base_info;
println!;
if let Some = get_file_info
Utility Functions
use *;
let data = vec!;
let hex = data_to_hex;
println!;
let bytes = hex_to_data?;
let dump = hex_dump;
println!;
Building
Desktop (Development)
Android
iOS
Examples
Run the basic example:
Run the advanced features example (showcasing new v0.3.0 features):
The advanced example demonstrates:
- Syscall-based memory operations (Android)
- Memory dumping to disk
- Patch and backup byte inspection
- Advanced ELF scanner capabilities
- ProcMap helper methods
- String utilities
- File path utilities
- Android system information
- Advanced linker scanner features
- NativeBridge scanner (x86 emulation support)
Documentation
Generate and open the documentation:
Feature Flags
keystone: Enable assembly patching with Keystone assemblerandroid: Android-specific features (auto-detected)ios: iOS-specific features (auto-detected)
Safety
safemodule: RAII wrappers with automatic cleanup and error handlingsysmodule: Raw FFI - requires manual memory management andunsafeblocks
Platform Support Matrix
| Feature | Android | iOS | Cross-Platform |
|---|---|---|---|
| Memory R/W | ✅ | ✅ | ✅ |
| Patching | ✅ | ✅ | ✅ |
| Pattern Scanning | ✅ | ✅ | ✅ |
| ELF Analysis | ✅ | N/A | - |
| Mach-O Analysis | N/A | ✅ | - |
| LinkerScanner | ✅ | N/A | - |
| Process Maps | ✅ | N/A | - |
| JNI Support | ✅ | N/A | - |
| Pointer Validation | ✅ | ✅ | ✅ |
License
MIT
Credits
- Original Library: KittyMemory by MJx0
- Rust Bindings: Rodroid Dev
- Community:
- Telegram Group: https://t.me/+QylrYL1GNsJiYjc0
- Telegram Channel: https://t.me/+WmudnO0-xoNhMDQ8
Contributing
Contributions welcome! Open issues or submit pull requests.
Changelog
Version 0.3.0 (Latest)
- Complete Feature Parity: Added 100+ new functions matching original KittyMemory library
- Library-Based Patching: Create patches using library name + offset (Android)
Patch::with_hex_lib()- Create hex patch with library name + offsetPatch::with_bytes_lib()- Create bytes patch with library name + offsetPatch::with_asm_lib()- Create assembly patch with library name + offset (requires keystone)
- Syscall Memory Operations: Alternative memory read/write using syscalls (Android)
- Memory Dumping: Dump memory regions or files to disk
- Patch/Backup Inspection: Get current, original, and patch bytes as hex strings
- Advanced ELF Scanner: Access program headers, dynamic section, hash tables, string/symbol tables
- ELF Refresh: Refresh ELF scanner data
- LinkerScanner Extensions: Get somain and sonext library information
- NativeBridgeScanner: Full support for x86/x86_64 emulation on ARM (Houdini detection)
- NativeBridgeLinker: dlopen, dlsym, dlerror, dladdr operations
- ProcMap Helpers: Validation, ELF detection, address containment checks
- Android System Info: Get Android version, SDK level, external storage
- String Utilities: Trim, validation, random generation
- File Path Utilities: Extract filename, directory, extension
- File I/O Abstraction: Complete file operations wrapper
- ZIP Utilities: List, extract, and memory-map ZIP contents (Android)
- Documentation: Improved rustdoc support for crates.io publishing
- Examples: New advanced_features example showcasing all new capabilities
Version 0.2.6
- Previous stable release
Disclaimer
Intended for education, research, and legitimate reverse engineering only. Users are responsible for compliance with applicable laws and platform terms.