代码
//clang -shared -undefined dynamic_lookup -o /Applications/BaiduNetdisk_mac.app/Contents/MacOS/libPCS.dylib BaiduYun.m
//optool install -c load -p @executable_path/libPCS.dylib -t /Applications/BaiduNetdisk_mac.app/Contents/MacOS/BaiduNetdisk_mac
/*
Their macOS client's download speed pretty much sucks even with a legitimate premium account.
*/
#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");
}
}
一.生成动态库libPCS.dylib:
clang -shared -undefined dynamic_lookup -o /Applications/BaiduNetdisk_mac.app/Contents/MacOS/libPCS.dylib BaiduYun.m
二.注入libPCS.dylib:
先要编译出optool:
1、git clone https://github.com/alexzielenski/optool.git
2、cd optool/
3、 git submodule update --init --recursive
ArgumentParser下载地址:https://github.com/mysteriouspants/ArgumentParser
optool下载地址:https://github.com/alexzielenski/optool
把解压的ArgumentParser放到/optool/FSArgumentParser
xcode编译得到optool
拿到optool执行注入:
/Users/zhang/tool/optool install -c load -p @executable_path/libPCS.dylib -t /Applications/BaiduNetdisk_mac.app/Contents/MacOS/BaiduNetdisk_mac
ok job done
原代码地址 github 版权:张总 Naville