使用fishhook hook函数fopen

使用fishhook hook函数fopen

#ios

#import 
#import 
#import "fishhook.h"

static FILE* (*orig_fopen)(const char *filename, const char *mode);

FILE* my_fopen(const char *filename, const char *mode) {
     
	printf("fopen hook\n");
	printf("fopen filename: %s\n", filename);
	return orig_fopen(filename, mode);
}

int main(int argc, char * argv[]) {
     
	rebind_symbols((struct rebinding[1]){
     {
     "fopen", my_fopen, (void *)&orig_fopen}}, 1);
	FILE *fp = fopen("/usr/bin/debugserver", "rb");
	fclose(fp);
	return 0;
}

编译:

clang fishhook.c fishhook_test.c -o fishhook_test.out
codesign -s - --entitlements ent.plist -f fishhook_test.out
./fishhook_test.out

ent.plist



<plist version="1.0">
	<dict>
		<key>com.apple.springboard.debugapplicationskey>
		<true/>
		<key>run-unsigned-codekey>
		<true/>
		<key>get-task-allowkey>
		<true/>
		<key>task_for_pid-allowkey>
		<true/>
	dict>
plist>

你可能感兴趣的:(越狱开发,ios)