fishhook関数fopenを使う
fishhook関数fopenを使う
湖北省にある地名
湖北省にある地名
#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
");
printf("fopen filename: %s
", 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>