Skip to content

Commit

Permalink
Refactor CommonDigest Hooks
Browse files Browse the repository at this point in the history
Updates #2.
  • Loading branch information
nabla-c0d3 committed Apr 29, 2013
1 parent 78d44b6 commit d9eb5f5
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 475 deletions.
9 changes: 0 additions & 9 deletions testapp/CryptoTester.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ + (void) testCommonDigest {
CC_MD5_Final(dataOut, &ctx);

CC_MD5(testData, 16, dataOut);

CC_SHA512_CTX ctx2;
unsigned char dataOut2[CC_SHA512_DIGEST_LENGTH];

CC_SHA512_Init(&ctx2);
CC_SHA512_Update(&ctx2, testData, 16);
CC_SHA512_Final(dataOut2, &ctx2);

CC_SHA512(testData, 16, dataOut2);
}


Expand Down
1 change: 1 addition & 0 deletions tracer/CallStackInspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// We don't want to hook internal calls, only what the App is directly calling.
// So we use this to figure out who called the function we're hooking.
+ (BOOL) wasDirectlyCalledByApp;
+ (BOOL) wasCalledByAppAtIndex:(NSUInteger)index;


@end
11 changes: 8 additions & 3 deletions tracer/CallStackInspector.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
@implementation CallStackInspector


+ (BOOL) wasDirectlyCalledByApp {

+ (BOOL) wasCalledByAppAtIndex:(NSUInteger)index {
//NSLog(@"%@",[NSThread callStackSymbols]);
NSString *appProcessName = [[NSProcessInfo processInfo] processName];
NSArray *callStack = [NSThread callStackSymbols];

// Not ideal: Check if the app's process name is close enough in the call stack
NSRange caller2 = [[callStack objectAtIndex:2] rangeOfString: appProcessName];
NSRange callerAtIndex = [[callStack objectAtIndex:index] rangeOfString: appProcessName];

if ((caller2.location == NSNotFound)) {
if ((callerAtIndex.location == NSNotFound)) {
return false;
}
return true;
}

+ (BOOL) wasDirectlyCalledByApp {
return [self wasCalledByAppAtIndex:2];
}


@end
2 changes: 1 addition & 1 deletion tracer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
include theos/makefiles/common.mk

TWEAK_NAME = introspy
introspy_FILES = Tweak.xmi CallTracer.m hooks/CC_MD5Hooks.m hooks/CC_SHAHooks.m hooks/KeychainHooks.m hooks/DelegateProxies.m PlistObjectConverter.m hooks/CCKeyDerivationPBKDFHooks.m CallStackInspector.m SQLiteStorage.m hooks/SecurityHooks.m hooks/CCCryptorHooks.m hooks/CCHmacHooks.m
introspy_FILES = Tweak.xmi CallTracer.m hooks/CommonDigestHooks.m hooks/KeychainHooks.m hooks/DelegateProxies.m PlistObjectConverter.m hooks/CCKeyDerivationPBKDFHooks.m CallStackInspector.m SQLiteStorage.m hooks/SecurityHooks.m hooks/CCCryptorHooks.m hooks/CCHmacHooks.m
introspy_LIBRARIES = sqlite3

introspy_FRAMEWORKS = UIKit, Foundation, Security
Expand Down
6 changes: 2 additions & 4 deletions tracer/Tweak.xmi
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ static NSString *preferenceFilePath = @"/private/var/mobile/Library/Preferences/
#import "hooks/CCCryptorHooks.h"
#import "hooks/CCHmacHooks.h"
#import "hooks/CCKeyDerivationPBKDFHooks.h"
#import "hooks/CC_MD5Hooks.h"
#import "hooks/CC_SHAHooks.h"
#import "hooks/CommonDigestHooks.h"



Expand Down Expand Up @@ -127,8 +126,7 @@ static void traceURISchemes() {
[CCCryptorHooks enableHooks];
[CCHmacHooks enableHooks];
[CCKeyDerivationPBKDFHooks enableHooks];
[CC_MD5Hooks enableHooks];
[CC_SHAHooks enableHooks];
[CommonDigestHooks enableHooks];
}
if (getBoolFromPreferences(preferences, @"SecurityHooks")) {
[SecurityHooks enableHooks];
Expand Down
9 changes: 0 additions & 9 deletions tracer/hooks/CC_MD5Hooks.h

This file was deleted.

220 changes: 0 additions & 220 deletions tracer/hooks/CC_MD5Hooks.m

This file was deleted.

9 changes: 0 additions & 9 deletions tracer/hooks/CC_SHAHooks.h

This file was deleted.

Loading

0 comments on commit d9eb5f5

Please sign in to comment.