Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jx6f committed Oct 26, 2016
0 parents commit c804b2e
Show file tree
Hide file tree
Showing 10 changed files with 1,011 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.theos
theos
*.deb
13 changes: 13 additions & 0 deletions Makefile
@@ -0,0 +1,13 @@
ARCHS = armv7s armv7

include theos/makefiles/common.mk

ADDITIONAL_CCFLAGS = -Qunused-arguments -w

TWEAK_NAME = itracer
itracer_FILES = Tweak.xmi tracer.mm hijack_arm.S
itracer_LIBRARIES = substrate
itracer_FRAMEWORKS = Foundation

include $(THEOS_MAKE_PATH)/tweak.mk

92 changes: 92 additions & 0 deletions README.md
@@ -0,0 +1,92 @@
# itracer

## Requirement

Jailbreaked 32bit iOS device

## Install itracer

1. download debian package
1. copy debian package to your iOS device
1. ssh login and install debian package
```sh
ssh -l root <ios_device_ip>
dpkg -i /path/to/package
```

## Uninstall itracer

```sh
dpkg -r cdi.itracer
```

## Using itracer

1. Choose the trace target from `Settings > itracer`
1. Run target application
1. Check `/tmp/itracer_<target_app_bundlename>.log`

### Sample output

<pre>
[NSSQLBindVariable setIndex:]
(uint)3

[_NSSQLGenerator appendSQL:]
<__NSCFConstantString>", "

[_NSSQLGenerator appendSQL:]
<__NSCFConstantString>"?"

[NSSQLBindVariable initWithValue:sqlType:attributeDescription:]
<__NSCFString>"P@ssw0rd"
(uint)6
<NSAttributeDescription>

[NSSQLBindVariable setIndex:]
(uint)4

[_NSSQLGenerator appendSQL:]
<__NSCFConstantString>", "

[_NSSQLGenerator appendSQL:]
</pre>

## Building itracer

### Build

```sh
make
```

### Packaging

```sh
make package
```


License
--------

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
32 changes: 32 additions & 0 deletions Tweak.xmi
@@ -0,0 +1,32 @@

extern "C" void HookObjcFunctions( const char *appName );

static NSString *preferenceFilePath = @"/private/var/mobile/Library/Preferences/cdi.itracer.plist";

// Tweak starts here
%ctor {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

// Only hook Apps the user has selected in itracer's settings panel
NSString *appId = [[NSBundle mainBundle] bundleIdentifier];

// Load itracer preferences
NSMutableDictionary *preferences = [[NSMutableDictionary alloc] initWithContentsOfFile:preferenceFilePath];
id shouldHook = [preferences objectForKey:appId];
if ( (shouldHook == nil) || (! [shouldHook boolValue]) ) {
NSLog(@"itracer - Profiling disabled for %@", appId);
[preferences release];
[pool drain];
return;
}

// Initialize DB storage
NSLog(@"itracer - Profiling enabled for %@", appId);

HookObjcFunctions( [ appId UTF8String ] );

[preferences release];
[pool drain];
}

/* vim: set filetype=objc : */
27 changes: 27 additions & 0 deletions hijack_arm.S
@@ -0,0 +1,27 @@
.macro HIJACK
.section __TEXT,__text,regular,pure_instructions
.globl _replaced_$0
.align 4
_replaced_$0:
stmdb sp!, {r0-r12, lr}
bl _msg_debug_$1
ldmia sp!, {r0-r12, lr}
stmdb sp!, {r0, pc}
ldr r0, reloc_$0
reloc_pc_$0:
ldr r0, [pc, r0]
ldr r0, [r0]
str r0, [sp, #4]
ldmia sp!, {r0, pc}

.align 4
reloc_$0:
.long _old_$0$non_lazy_ptr-(reloc_pc_$0+8)
.section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
_old_$0$non_lazy_ptr:
.indirect_symbol _old_$0
.long 0
.endmacro

#define FUNC(symbol, prototype) HIJACK symbol, prototype
#include "objc_funcs.h"
8 changes: 8 additions & 0 deletions layout/DEBIAN/control
@@ -0,0 +1,8 @@
Package: cdi.itracer
Name: itracer
Depends: mobilesubstrate, preferenceloader, applist
Version: 0.0.1
Architecture: iphoneos-arm
Maintainer: jx6f
Author: jx6f
Section: Tweaks
27 changes: 27 additions & 0 deletions layout/Library/PreferenceLoader/Preferences/itracer.plist
@@ -0,0 +1,27 @@
entry = {
bundle = AppList;
cell = PSLinkCell;
icon = "/Library/PreferenceLoader/Preferences/itracer.png";
isController = 1;
label = "itracer";
ALSettingsPath = "/var/mobile/Library/Preferences/cdi.itracer.plist";
ALSettingsKeyPrefix = "";
ALChangeNotification = "cdi.itracer";
ALAllowsSelection = 1;
ALSectionDescriptors = (
{
title = "User Applications";
predicate = "isSystemApplication = FALSE";
"cell-class-name" = "ALSwitchCell";
"icon-size" = 30;
"suppress-hidden-apps" = 1;
},
{
title = "System Applications";
predicate = "isSystemApplication = TRUE";
"cell-class-name" = "ALSwitchCell";
"icon-size" = 30;
"suppress-hidden-apps" = 1;
}
);
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions objc_funcs.h
@@ -0,0 +1,4 @@
FUNC(objc_msgSend , regular)
FUNC(objc_msgSend_stret , stret)
FUNC(objc_msgSendSuper , super)
FUNC(objc_msgSendSuper_stret , super_stret)

0 comments on commit c804b2e

Please sign in to comment.