reveal看到的类名是SYHDAppPayProject.MainTabBarController

需求:我想hook一个类
代码:%hook SYHDAppPayProject.MainTabBarController
%end
问题:我用class jump 导出了头文件 类名都没有SYHDAppPayProject.前缀,但是用reveal查看,都是带有前缀的,hook带前缀的类 编译报错,请问怎么hook带特殊字符前缀的类呢

这个是用Swift写的项目,具体怎么hook等大神来了回答吧。

这,,,好吧,你咋知道是swift写的呐

.就是Swift

不要用Logos即可
例子:

#import <objc/runtime.h>
#import <Foundation/Foundation.h>
static IMP request_increaseBytesTransferred=NULL;
static IMP setMaxBytesPerSecond=NULL;
static BOOL ISVIP(id obj){
  return YES;
}
static void getRekt(id obj){

}
static void hooked_request_increaseBytesTransferred(id obj,SEL _cmd,long long arg1,long long arg2){
  request_increaseBytesTransferred(obj,_cmd,MAXFLOAT,MAXFLOAT);
}
static void hooked_setMaxBytesPerSecond(id obj,SEL _cmd,unsigned long long arg1){
  setMaxBytesPerSecond(obj,_cmd,MAXFLOAT);
}
__attribute__((constructor))
static void fool() {
  Method m1 = class_getInstanceMethod(NSClassFromString(@"BandwidthManager"),NSSelectorFromString(@"request:increaseBytesTransferred:"));
  request_increaseBytesTransferred=method_getImplementation(m1);
  method_setImplementation(m1, (IMP)hooked_request_increaseBytesTransferred);
  Method m2 = class_getInstanceMethod(NSClassFromString(@"BandwidthManager"),NSSelectorFromString(@"setMaxBytesPerSecond:"));
  setMaxBytesPerSecond=method_getImplementation(m2);
  method_setImplementation(m2,(IMP)hooked_setMaxBytesPerSecond);
  Method m3 = class_getInstanceMethod(NSClassFromString(@"BandwidthManager"),NSSelectorFromString(@"performThrottling"));
  Method m4 = class_getInstanceMethod(NSClassFromString(@"BandwidthManager"),NSSelectorFromString(@"notifyThrottling"));
  method_setImplementation(m3,(IMP)getRekt);
  method_setImplementation(m4,(IMP)getRekt);
  Method m5 = class_getInstanceMethod(NSClassFromString(@"BDUser"),NSSelectorFromString(@"isSVip"));
  method_setImplementation(m5,(IMP)ISVIP);
  if(m1!=NULL&&m2!=NULL&&m3!=NULL&&m4!=NULL&&m5!=NULL&&request_increaseBytesTransferred!=NULL&&setMaxBytesPerSecond!=NULL){
    NSLog(@"Inj3ct3d");
  }
}
1 个赞

%hook AnyNameYouLike

  • (void)theFuncYouWantToHook {

}

%end

%ctor {
%init(AnyNameYouLike = objc_getClass(“SYHDAppPayProject.MainTabBarController”););
}

1 个赞

这是hook swift么

可以hook swift,还可以hook一些奇奇怪怪的类名,甚至中文。

展开就是我一开始贴的代码哇