简体   繁体   English

能够在扩展过程中使 macOS 端点扩展失败

[英]Ability to fail macOS endpoint extension from within the extension process

I'd like to protect against unauthorised system extension teardown that are triggered by the container application following this command:我想防止容器应用程序按照以下命令触发未经授权的系统扩展拆卸:

self.deactivationRequest = 
        OSSystemExtensionRequest.deactivationRequest(
                    forExtensionWithIdentifier: extensionIdentifier, queue: .main)
self.deactivationRequest!.delegate = self
OSSystemExtensionManager.shared.submitRequest(self.deactivationRequest!)

Is there a callback in the endpoint extension code, that can be invoked upon this deactivation request, and may block/allow it?端点扩展代码中是否有回调,可以根据这个停用请求调用,并且可以阻止/允许它?

thanks谢谢

There is no public API to control the system extension deactivation with EndpointSecurity or inside sysext itself (activation and deactivation management, I think, is a job for some daemon, like sysextd).没有公共 API 来控制使用 EndpointSecurity 或在 sysext 本身内部的系统扩展停用(我认为,激活和停用管理是某些守护进程的工作,如 sysextd)。

I could advice to try two approaches for your case:我可以建议为您的案例尝试两种方法:

  1. You may still be able to deny deactivation with EndpointSecurity, just not in direct way.您可能仍然可以使用 EndpointSecurity 来拒绝停用,只是不是直接的方式。 To deactivate sysext the responsible processes would do a lot of stuff, including opening some specific files, reading them, etc. In case you are lucky, you may be able to fail the deactivation process by blocking one of such operations before it really deativated.要停用 sysext,负责的进程会做很多事情,包括打开一些特定文件、读取它们等。如果幸运的话,您可以通过在真正停用之前阻止其中一个操作来使停用过程失败。 However, the context of operation (how do you know the target is your extension) may vary and be less than you need.然而,操作的上下文(你怎么知道目标是你的扩展)可能会有所不同并且比你需要的要少。

  2. You may intercept the OSSystemExtensionManager.shared.submitRequest call inside your application, and add some condition to really call original method from interception method.您可以在您的应用程序中拦截 OSSystemExtensionManager.shared.submitRequest 调用,并添加一些条件以真正从拦截方法调用原始方法。 The interception for submitRequest will be a swizzling . submitRequest 的拦截将是一个swizzling Or you can place an old good hook on something deeper, like xpc_* stuff, and filter your deactivation request by some unique string from request, also calling original method only on some condition.或者你可以在更深层次的东西上放置一个旧的好钩子,比如 xpc_* 东西,并通过请求中的一些独特字符串过滤你的停用请求,也只在某些条件下调用原始方法。

Both ways are not bulletproof from perspective of tampering protection ofc, but nothing really is, we just requesting additional efforts from hacker.从篡改保护的角度来看,这两种方式都不是防弹的,但实际上并不是,我们只是要求黑客付出额外的努力。

If you haven't disabled library validation for your app, there are two ways of tampering it: either turning SIP off, or using some 0-day system breach.如果您没有为您的应用程序禁用库验证,则有两种方法可以对其进行篡改:关闭 SIP,或使用一些 0-day 系统漏洞。 You can't really protect your app from such treats: 0-days are new, you don't know what it may be, and with SIP off the one may unload/disable/alter all possible kinds of protection stuff.您无法真正保护您的应用程序免受此类对待:0 天是新的,您不知道它可能是什么,并且关闭 SIP 可能会卸载/禁用/更改所有可能的保护类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM