ios dylib反检测系统api


#import "fishHookDemo.h"
#import "fishhook.h"
#import <mach-o/dyld.h>
#include<string.h>

@implementation fishHookDemo

char *arr[1000];

+ (void)load{
    struct rebinding ptracebd, db_name;
    // 要hook的方法名
    ptracebd.name = "_dyld_image_count";
    db_name.name = "_dyld_get_image_name";

    // 保存原来方法的地址
    ptracebd.replaced = (void *)&dyld_image_count_p;
    db_name.replaced = (void *)&dyld_get_image_name_p;

    // 新方法
    ptracebd.replacement = my_dyld_image_count;
    db_name.replacement = my_dyld_get_image_name;

     
    struct rebinding bds[] = {ptracebd, db_name};
    rebind_symbols(bds, 2);
//    _dyld_get_image_name()
}
 
// 函数指针
uint32_t (*dyld_image_count_p)(void);
const char* (*dyld_get_image_name_p)(uint32_t image_index);

uint32_t my_dyld_image_count(void){
    int dyCount = dyld_image_count_p();
    // 新计数
    int index = 0;
    for (int i = 0; i < dyCount; i++) {
        // 获取原始dylib库
        char * imageName = dyld_get_image_name_p(i);
        NSString *res = [NSString stringWithUTF8String:imageName];
        NSLog(@"dylib String-->:%@",res);
        // 过滤敏感dylib
        if (![res containsString:@"xxx.dylib"]) {
            arr[index++]=imageName;
//         strcpy(arr[index++],imageName);
        }


        
          
       }
    return index;
}
const char*   my_dyld_get_image_name(uint32_t image_index){
    return arr[image_index];
}

@end

 

ios dylib反检测系统api

上一篇:.net core 中Session使用


下一篇:C++Builder(XE)如何转换字符串编码为UTF-8并转换成char数组