Xcode怎么给自己开发的应用签task_for_pid-allow

996.icu LICENSE

  • 问题背景
  • 解决方法
  • 总结

阅读之前注意:

本文阅读建议用时:10min
本文阅读结构如下表:

项目下属项目测试用例数量
问题背景0
解决方法1
总结0

问题背景

一个测试的项目,给自己的应用签task_for_pid-allow。
在工程中创建了pidTest.entitlements,如下图:
在这里插入图片描述

ViewController.m代码非常简单,如下:

#import <Foundation/NSProcessInfo.h>
#import <mach-o/dyld_images.h>

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
   
    kern_return_t    rc;
    mach_port_t    task;
    int pid;
    
    pid =  [[NSProcessInfo processInfo] processIdentifier];//获取进程的id,即平常使用ps -e | grep xxx得到的进程端口号
    rc = task_for_pid(mach_task_self(), pid, &task);
    
    if (rc) { fprintf (stderr, "task_for_pid() failed with error %d - %s\n", rc, mach_error_string(rc)); exit(1); }
    printf ("RC %d - Task: %d\n",rc, task);
}

但是Xcode无法编译通过,提示如下:

Showing All Messages
👎 Automatic signing is unable to resolve an issue with the “get_pid” target’s entitlements. Automatic signing can’t add the task_for_pid-allow entitlements to your provisioning profile. Switch to manual signing and resolve the issue by downloading a matching provisioning profile from the developer website. Alternatively, to continue using automatic signing, remove these entitlements from your entitlements file and their associated functionality from your code. (in target ‘get_pid’)

其中重点是Automatic signing can’t add the task_for_pid-allow entitlements to your provisioning profile,以及Switch to manual signing。

解决方法

参考不越狱可以砸壳了可以解决。
翻译叫“通灵纸”漏洞?作者说就算没有iOS背景或者漏洞利用背景的人,也能理解这个。
原理是构建特定的xml签名文件,利用系统4个模块对xml文件的解析不同,导致上层看不到,但是底层检测到是有权限的。

总结

构建特定的xml签名文件,可以给应用签上task_for_pid-allow等其他权限属性。
如果本文对你有帮助,不如请我一罐可乐吧 🎃
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值