在OS X 10.13上对旧的Director投影仪进行编码 - 可能会操纵__LINKEDIT段值

问题描述 投票:1回答:3

(参见本文末尾的更新)

出于各种原因,我需要对旧的Director投影机进行编码,使我们无法再重新发布(无法访问原始源代码或Director)。

我这样做是因为在没有签名的情况下运行时,应用程序现在打开一个Finder窗口,其中提示“Where is ...”,要求提供一个嵌入式投影机资源之一的文件。

但是......如果我cd进入Projector.app内容(它不是真的称之为,但你明白了)并在Contents/MacOS/中找到投影机二进制文件并从终端运行这个二进制文件,应用程序启动并运行正常,一旦它解压缩(大概是在二进制文件的末尾添加了档案...

/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Common/ChunkCompression.cpp:50: Error: unsupported compressor 8
/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Exceptions.plist'
/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Common/ChunkCompression.cpp:50: Error: unsupported compressor 8
/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/AppExceptions.bundle/Exceptions.plist'
271 blocks
1120 blocks
274 blocks
136 blocks
255 blocks
120 blocks
1487 blocks
575 blocks
1128 blocks
570 blocks
104 blocks
2042 blocks
4889 blocks
677 blocks
388 blocks
363 blocks
700 blocks
23010 blocks

...app opens and runs correctly at this point

我不能要求我们的用户这样做(他们非常非技术性)所以我猜测“哪里是......”提示是OS X Gatekeeper的某些方面,因此我希望签署二进制文件将使其再次点击可运行。

当我尝试编码二进制App.app/Contents/MacOS/projector时,我得到:

main executable failed strict validation

设置--no-strict codesign选项可以提供更多细节:

the __LINKEDIT segment does not cover the end of the file (can't be processed)

我认为这是因为Director投影仪是一个带有捆绑存档的二进制文件,其中包含应用程序资源的其余部分,附加到可执行文件的末尾。一些googling shows认为其他项目的嵌入式资源存在类似问题。

我已经尝试使用macho_edit来查看我是否可以修改二进制文件,但没有任何乐趣。我也尝试使用jtool进行签名,但同样,这不起作用。

所以现在,在MachOView中打开二进制文件:

MachOView of binary

我希望我可以对二进制文件进行十六进制并更改__LINKEDIT segment的值,使其覆盖文件的末尾,因此代码签名将起作用,但我不知道修改后的值应该是什么,或者如果还有什么呢我需要改变的一切。任何提示赞赏。

更新1 - 响应Kamil.S's answer

我已经尝试调整__LINKEDIT段中的File Size值,所以这+ File Offset与实际二进制相同(我尝试了几次;你实际上需要将VM Size更改为与File Size相同的值或者你得到Killed: 9通过操作系统。如果你将File Size设置为二进制文件的总大小,也会发生相同的情况,但没有运气。使用新的File SizeVM Size值,我仍然可以运行二进制文件,但我无法对其进行编码;但是,我会收到一个略有不同的错误消息:

file not in an order that can be processed (link edit information does not fill the __LINKEDIT segment)

更新2 - https://github.com/pyinstaller/pyinstaller/wiki/Recipe-OSX-Code-Signing#pyinstaller-fix-implementation有关于同一问题的更多细节:

PyInstaller打破了OSX代码签名,因为它在二进制文件末尾附加了python代码。在可执行文件末尾附加数据会破坏Mach-o格式结构。 codesign实用程序抱怨以下消息。

the __LINKEDIT segment does not cover the end of the file (can't be processed)

file not in an order that can be processed (link edit information does not fill the __LINKEDIT segment)
  • 修复__LINKEDIT - 文件大小(偏移+文件大小== exe大小),VM大小 - 与'文件大小'相同
  • 修复LC_SYMTAB - 字符串表大小 - mach-o文件中的最后一个数据(offset + size =文件系统上的exe大小) - 附加到可执行文件的数据将成为'字符串表'的一部分(Mach-O文件中的最后一个数据部分) )。

我将看看修复LC_SYMTAB,看看是否有帮助。

macos codesign mach-o adobe-director
3个回答
© www.soinside.com 2019 - 2024. All rights reserved.