iOS11/iOS12上通过LSApplicationWorkspace获取应用列表(只能获取带有 plugin 的app)


#1
NSMethodSignature *methodSignature = [NSClassFromString(@"LSApplicationWorkspace") methodSignatureForSelector:NSSelectorFromString(@"defaultWorkspace")];
NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:methodSignature];
[invoke setSelector:NSSelectorFromString(@"defaultWorkspace")];
[invoke setTarget:NSClassFromString(@"LSApplicationWorkspace")];

[invoke invoke];
NSObject * objc;
[invoke getReturnValue:&objc];


NSMethodSignature *installedPluginsmethodSignature = [NSClassFromString(@"LSApplicationWorkspace") instanceMethodSignatureForSelector:NSSelectorFromString(@"installedPlugins")];
NSInvocation *installed = [NSInvocation invocationWithMethodSignature:installedPluginsmethodSignature];
[installed setSelector:NSSelectorFromString(@"installedPlugins")];
[installed setTarget:objc];

[installed invoke];
NSObject * arr;
[installed getReturnValue:&arr];


for (NSObject *objc in arr) {

	NSMethodSignature *installedPluginsmethodSignature = [NSClassFromString(@"LSPlugInKitProxy") instanceMethodSignatureForSelector:NSSelectorFromString(@"containingBundle")];
	NSInvocation *installed = [NSInvocation invocationWithMethodSignature:installedPluginsmethodSignature];
	[installed setSelector:NSSelectorFromString(@"containingBundle")];
	[installed setTarget:objc];

	[installed invoke];
	NSObject * app;
	[installed getReturnValue:&app];
	NSLog(@"%@",app);
}

以上来自 NGE 商业化实验室 对某助手的逆向


#2

感谢分享。
我唯一的意见是这一堆并不需要的NSInvocation极大的降低了代码的可读性,这段代码看起来像是字节跳动员工写的。

除此之外,10/10


#3

经过测试,只有用NSInvocation 才能调用成功啊张总


#4

这是哥们我自己写的😂


#5

还有这种事情?

这是哥们我自己写的😂

我知道,我只是顺带完成一下黑字节跳动的日常任务


#6

这么屌? 他还检查 caller 不成


#7

还有这种操作,张总能把我加进混淆器的那个 QQ群里吗,我现在也在研究 编译器


#8

估计是的,这个是 某 P 助手 的写法,原封不动


#9

那群我早就解散了。加我微信好了


#10

那么微信是什么呢


#11


请问前辈我哪边弄错了呢!?


#12

image
内存泄露


#13

哥们,模拟器会崩溃,真机测试没问题,结论:不要用模拟器


#14


我是使用真机操作的 …


#16

###我的也有这个问题,求大神解答


#17

大神也没回应我 QQ


#18

你们为啥写个反射代码这么长

    id space = [NSClassFromString(@"LSApplicationWorkspace") performSelector:@selector(defaultWorkspace)];
    NSArray *plugins = [space performSelector:@selector(installedPlugins)];
    NSMutableSet *list = [[NSMutableSet alloc] init];
    for (id plugin in plugins) {
        id bundle = [plugin performSelector:@selector(containingBundle)];
        if (bundle)
            [list addObject:bundle];
    }
    
    for (id plugin in list) {
        NSLog(@"%@", [plugin performSelector:@selector(applicationIdentifier)]);
    }