Ragekill3377 / Titanox

A hooking framework, symbol rebinder and memory-manager for jailed IOS, All-In-One.
8 stars 0 forks source link
fishhook framework hooking ios jailed memory-allocator theos

Titanox

Titanox is a hooking framework for iOS. It utilizes fishhook for symbol rebinding and CGuardMemory for advanced memory management.It also contains a reimplemented version of libhooker by coolstar (The creator of the electra jailbreak for IOS11.). This library supports function hooking, method swizzling, memory patching etc. It does not have any external dependencies and can be used on non-jailbroken/non-rooted IOS devices with full functionailty!!!

Features

APIs:~

Documentation:~

Usage:~

Initialize Memory Engine Before using any functions that require memory operations, initialize the memory-engine:

[TitanoxHook initializeMemoryEngine];

P.S: you do NOT have to initialize the engine. it will automatically be initialized in the memory related functions such as the mem write function. However if you want to make your own usages globally, then you should.

LHHookFunction for jailed IOS Hook a function via trampoline hook, using the reimplemented libhooker API.

if (hookRef.trampoline) { NSLog(@"Success."); } else { NSLog(@"Failed."); }


**Function Hooking by fishhook (static)**
Hook a function by symbol using fishhook (Will hook in main task process):

```objc
[TitanoxHook hookStaticFunction:"symbolName" withReplacement:newFunction outOldFunction:&oldFunction];

Hook a function in a specific library:(Will hook in target library/Binary specified in 'inLibrary'. Full name is required. Can be the main executable or a loaded library in the application.

[TitanoxHook hookFunctionByName:"symbolName" inLibrary:"libName" withReplacement:newFunction outOldFunction:&oldFunction];

Method Swizzling Swizzle a method in a class:

[TitanoxHook swizzleMethod:@selector(originalMethod) withMethod:@selector(swizzledMethod) inClass:[TargetClass class]];

Method Overriding Override a method in a class with a new implementation:

[TitanoxHook overrideMethodInClass:[TargetClass class]
                          selector:@selector(methodToOverride)
                   withNewFunction:newFunction
                 oldFunctionPointer:&oldFunction];

Memory Patching Patch memory at a specific address:

[TitanoxHook patchMemoryAtAddress:address withData:data length:length];

Boolean Hooking Toggle a boolean value in a dynamic library:


[TitanoxHook hookBoolByName:"booleanSymbol" inLibrary:"libName.dylib"];

Base Address & VM Address Slide Get the base address of a dynamic library:

uint64_t baseAddress = [TitanoxHook getBaseAddressOfLibrary:"libName.dylib"];

Get the VM address slide of a dynamic library:

intptr_t vmAddrSlide = [TitanoxHook getVmAddrSlideOfLibrary:"libName.dylib"];

Compiling From Source:~

Theos:~

theos: A cross-platform build system for creating iOS, macOS, Linux, and Windows programs.

Prequisites:~

For linux: sudo apt install bash curl sudo. Can vary depending on distribution. This is for kali/ubuntu/debian or other debian based distros.

For macOS: Install brew & xcode-command-line utilities, aswell as xcode itself.

For Windows: Install WSL (Window's subsystem for Linux) and use any linux distribution. I recommend Ubuntu.

Once that is done, copy paste this command:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/theos/theos/master/bin/install-theos)"

It will install theos for you. wait until installation is completed.

For more detailed/well-explained steps, please head over to https://theos.dev/docs for installing theos on your platform

Compiling:~

You will get a .deb file in your output directory i.e packages. Also, it will move the .dylib to your $THEOS/lib directory as libtitanox.dylib (Unless you changed TWEAK_NAME in Makefile). You can use this to link against your own code, or even you could merge Titanox's sources with your own.

Using release builds:~

In a Theos Makefile:

YOURTWEAKNAME_LDFLAGS = -L$(THEOS)/lib -ltitanox -Wl,-rpath,@executable_path # TODO: Change 'YOURTWEAKNAME' to your actual tweak name.

This will link libtitanox.dylib. From there, you can inject your own library or binary which uses Titanox, & Titanox itself.

Disclaimer: This is made solely for NON-JAILBROKEN DEVICES**

        # This framework cannot R/W directly to segments or modify protected segments, unless there is a jailbreak or JIT.
        # But, this was made for non-jailbroken devices and it's intended use is within an application's sandbox. So those capabilities will not be added.

TODO:

 * Incorporate ellekit's hooking mechanisms and improve memory manager..

License:

You are free to use this code. I am not responsible for any illegal or malicious acts caused by the use of this code.