2017-02-21 64 views
0

我可以拦截类似sqlite3_preparesqlite3_open的通用系统调用CC_MD5libcommonCrypto与Theos(jailed versione)调整吗?是否可以通过Theos Tweak拦截系统调用?被拘留的版本

我会拦截所有这些调用并在控制台或日志文件中打印。 我读过一些关于MSHookFunction的内容,但我不确定。

编辑:我添加了一些我在这几天写的代码。这是我的Tweak.xm,我会拦截CC_MD5调用,并且在简单的消息日志之后,我将返回到正常流程。调整是注入,但我看不到任何消息。

#include <substrate.h> 
#include <CommonCrypto/CommonDigest.h> 

static unsigned char * (*original_CC_MD5)(const void *data, CC_LONG len, unsigned char *md); 

static unsigned char * replaced_CC_MD5(const void *data, CC_LONG len, unsigned char *md) { 

     NSLog(@"Calling MD5"); 
     return original_CC_MD5(data, len, md); 
} 

MSInitialize { 
     MSHookFunction(CC_MD5, replaced_CC_MD5, &original_CC_MD5); 
} 

回答

0

我发现了这个问题。我使用的Theos version是用于监禁的设备。用这个版本MSHookFunction被fishhook替代。

使用鱼钩这一切都ok了:明明的代码更改

#include <substrate.h> 
#include <CommonCrypto/CommonDigest.h> 
#import <fishhook.h> 

static unsigned char * (*original_CC_MD5)(const void *data, CC_LONG len, unsigned char *md); 

static unsigned char * replaced_CC_MD5(const void *data, CC_LONG len, unsigned char *md) { 

     NSLog(@"Calling MD5"); 
     return original_CC_MD5(data, len, md); 
} 

%ctor { 

rebind_symbols((struct rebinding[1]){{"CC_MD5", replaced_CC_MD5, (void *)&original_CC_MD5}},1); 

} 
相关问题