iOS私有库的正确使用

昨天看到狗剩在获得iDevice中获得已安装的使用了私有库,采用如下的加载方式,objc_getClass(“LSApplicationWorkspace”)来获得类及其实例,今天我想试着用下其他的私有库,却不行了。下面是我的尝试。

我想加载这个库,PrivateFrameworks/FrontBoard.framework/FrontBoard,
于是我用find 去搜索了机器里面的文件,得到以下几个路径包含有这个库,如下:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/FrontBoard.framework
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/FrontBoard.framework
/Users/username/Library/Developer/Xcode/iOS DeviceSupport/8.0 (12A365)/Symbols/System/Library/PrivateFrameworks/FrontBoard.framework
/Users/username/Library/Developer/Xcode/iOS DeviceSupport/8.0.2 (12A405)/Symbols/System/Library/PrivateFrameworks/FrontBoard.framework

拿到这路径以后用第一条记录里面的文件尝试去使用里面类,FBProcessManager,采用objc_getClass(“FBProcessManager”)但是没有成功,拿到的是NULL返回;

接着又尝试了采用静态库加载的方式,如下:
#define FrontBoard_PATH “/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/FrontBoard.framework/FrontBoard”
采用dlopen去动态加载,还是失败了;

接着又尝试了第三条记录,分别试了没有转义的路径跟转义后的路径,都没有成功的加载到这个类,不知道是哪儿的步骤错了,希望大家指点。

目的就是成功加载到FBProcessManager类就行了。

/System/Library/PrivateFrameworks/FrontBoard.framework/FrontBoard
只要这个路径就够了

感谢,但是我看电脑里面没有这个路径没有东西啊。这路径是电脑里面的路径还是手机中的?

静态的方式,你的工程导入这个framework了吗?
动态的方式,报什么错?

静态:那framework倒是倒入了,但是里面没有Headers,我把runtime的header导进去的时候会报错。
动态:调试的时候,dlopen拿到的内容是NULL的。

那就不知道了,我猜是沙盒原因吧!

请问楼主有进展吗?我也想知道这个 frontBoard 的用法,求分享

没有没有,你有进步么?

写hook是在真机上运行的 肿么能用mac上的路径去加载呢

当然是手机上的库的路径

貌似我还真是犯了这个错误,感谢提醒,试试看去。感谢。

二楼的答案是正解啊,加载的时候是动态加载,是加载手机里面的路径,而不是电脑里面的路径

method name ==== ping
method name ==== dealloc
method name ==== init
method name ==== description
method name ==== addObserver:
method name ==== removeObserver:
method name ==== applicationProcessForPID:
method name ==== applicationProcessesForBundleIdentifier:
Test ‘icationProcessesForBundleIdentifier:’ completed successfuly
method name ==== _setPreferredForegroundApplicationProcess:
Test ‘PreferredForegroundApplicationProcess:’ completed successfuly

method name ==== allProcesses
Test ‘rocesses’ completed successfuly
method name ==== createApplicationProcessForBundleID:
Test ‘teApplicationProcessForBundleID:’ completed successfuly

how to use in ios9

iOS 10下的/Library/PrivateFrameworks/FrontBoard.framework/FrontBoard,dlopen这个私有库,dlerror报错:out of adress space,进程路径确实是有的,但是还是不行,我觉得是要重定向出路径出来??

NSBundle *a = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/PassKitCore.framework"];
if ([a load]) {
        NSLog(@"%s>>>>>>%d",__func__,__LINE__);
        Class aa = NSClassFromString(@"FUAirline");
        id aaa = [[aa alloc]init];
        
        NSLog(@"%s>>>>>>%d>>>>>>%@",__func__,__LINE__,[aaa performSelector:@selector(phoneNumber)]);
}

我是这样加载的!加载都能成功!

2 个赞

你好 问一下这个库 我在iOS 11里没有看到呀