简体   繁体   English

构建加密的 Mach-o 文件

[英]Build Mach-o file as encrypted

I was wondering if it's possible to build a Mach-O file, or modify an existing one and then re-sign it so that the code sections will be encrypted.我想知道是否可以构建一个 Mach-O 文件,或者修改一个现有的文件,然后重新签名,以便对代码部分进行加密。

I know that there's a flag called cryptid that represent the encryption type (by values `EncryptionInfo32/64 for load commands LC_ENCRYPTION_INFO_32/64 respectively)我知道有一个名为cryptid的标志表示加密类型(分别为加载命令 LC_ENCRYPTION_INFO_32/64 的值“EncryptionInfo32/64”)

However, I couldn't find anywhere in Xcode for how it's done.但是,我无法在 Xcode 中的任何地方找到它是如何完成的。

EDIT : I'm well aware that it can be done in iOS, but my question relate to macOS, does the platform support this encryption feature in Mach-O file ?编辑:我很清楚它可以在 iOS 中完成,但我的问题与 macOS 有关,该平台是否支持 Mach-O 文件中的此加密功能?

EDIT2: So after reading the other question I understood that the whole encryption thing can only be done by appStore which is after the Mach-O file is already left the developer side. EDIT2:所以在阅读了另一个问题后,我明白整个加密的事情只能由 appStore 来完成,这是在 Mach-O 文件已经离开开发人员方面之后。 So in this case, Apple actually controlled the encryption/decryption algo+key and it's completely outside the developer hand, right ?所以在这种情况下,苹果实际上控制了加密/解密算法+密钥,完全不在开发者手中,对吧? Also, since the Mach-O is being changed during the encryption, so who's in charge to re-sign the application ?此外,由于 Mach-O 在加密期间正在更改,那么谁负责重新签署应用程序?

Thanks谢谢

No, you cannot do this.不,你不能这样做。

The only "supported" way of getting LC_ENCRYPTION_INFO added to your binary is by distributing through the iOS App Store.将 LC_ENCRYPTION_INFO 添加到二进制文件的唯一“受支持”方式是通过 iOS App Store 分发。 It is Apple who checks your binary for compliance with their rules, then encrypts the binary and re-signs it. Apple 会检查您的二进制文件是否符合他们的规则,然后对二进制文件进行加密并重新签名。

This is all backed by "FairPlay", Apple's proprietary DRM stack.这一切都由 Apple 专有的 DRM 堆栈“FairPlay”提供支持。 Not much is known about it since the code is heavily obfuscated, but it is widely believed that it's built on features of Apple's custom hardware AES engine.由于代码被严重混淆,因此对它知之甚少,但人们普遍认为它是建立在 Apple 定制硬件 AES 引擎的功能之上的。 Given this, it may or may not be possible to create an encryptor yourself, but it would require immense reverse engineering efforts to even find out.鉴于此,您自己创建加密器可能会也可能不会,但需要大量的逆向工程努力才能找到答案。

Further, the entire FairPlay stack is only present on Apple's own chips.此外,整个 FairPlay 堆栈仅存在于 Apple 自己的芯片上。 It is indeed available on M1 Macs, as you can install iOS apps off the shelf (so long as you leave SIP enabled), but it is not available at all on Intel Macs (the relevant kexts are IOTextEncryptionFamily.kext and FairPlayIOKit.kext , the latter of which is obfuscated).它确实在 M1 Mac 上可用,因为您可以安装现成的 iOS 应用程序(只要您启用 SIP),但它在 Intel Mac 上根本不可用(相关的 kext 是IOTextEncryptionFamily.kextFairPlayIOKit.kext ,后者被混淆)。

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

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