提升 mach_inject 的使用权限
如何使用授权 API 将用户权限提升为 root,以便可以使用 mach_inject?
How do you elevate user rights to root using the Authorization API so that it is possible to use mach_inject?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于那些希望在 macOS 10.11 及更高版本上使用 mach_inject(内部使用 task_for_pid())的用户,您需要添加适当的权限才能使其工作。 然后用 sudo 运行。 请参阅下面的示例: https://gist.github.com/attilathedud/e58917c9fd095a84fd5bbfb31674be05
您可以只要至少设置了该权利并且您拥有正确的权限,就可以使用终端程序和 cocoa 应用程序执行此操作。
For those who wish to use mach_inject (which uses task_for_pid() internally) for macOS 10.11 and above, you will need to add the proper entitlement for this to work. Then run with sudo. See the example below: https://gist.github.com/attilathedud/e58917c9fd095a84fd5bbfb31674be05
You can do this with both terminal programs and cocoa apps as long as at least that entitlement is set and you have the right privileges.
您无需成为 root 即可使用 mach_inject; 相反,您需要签署您的代码。 仅出于测试目的(在 10.4/10.5 中),您还可以使应用程序 setgid procmod。
有关详细信息,请参阅 TN2206。
You don't need to be root to use mach_inject; instead, you need to sign your code. For testing purposes only (and in 10.4/10.5) you can also make your application setgid procmod.
See TN2206 for more information.
老问题,但答案不正确:
除非您拥有 pid/task,否则您实际上需要成为 root 或成为 procmod 的成员。 在 OS X 中,这与代码签名关系不大。 Mach_inject/Mach_star 由Mach trap task_for_pid() 使用,需要上述权限。 在 iOS 中,您还需要相应的权利(task_for_pid-allow),这就是代码签名派上用场的地方(使用 ldid 进行自签名)。
Old question, but incorrect answer:
Unless you own the pid/task, you actually do need to EITHER be root or be a member of procmod. In OS X, this has little to do with code signing. Mach_inject/Mach_star use by the Mach trap task_for_pid(), which requires the above privileges. In iOS , you also need the corresponding entitlement (task_for_pid-allow), which is where code signing would come in handy (using ldid for self signing).