Quantcast
Channel: 睿论坛 - 最新话题
Viewing all articles
Browse latest Browse all 5702

记踩上codesign的一个仍未修复的远古bug

$
0
0

@BCDB9630EAB47648 wrote:

tl;dr

codesign --remove-signature 在删除代码签名之后没有修复MachO Header的偏移,导致生成的MachO文件畸形。我很确定应该有无数人踩过这个坑,自己研究一遍权当练习

正文

以Dash为例,操作之后的app打开直接crash,以lldb file后报warning:


warning: (x86_64) /Applications/Dash.app/Contents/MacOS/Dash load command 3 LC_SEGMENT_64 has a fileoff + filesize (0x335ed0) that extends beyond the end of the file (0x335ec4), the segment will be truncated to match
Current executable set to '/Applications/Dash.app/Contents/MacOS/Dash' (x86_64).

用MachOView打开可执行文件,定位到最后一个LC_SEGMENT:


简单的做下数学验证: 0x31D000+0x18ED0=0x335ED0,比文件实际大小0x335ec4大出0x335ED0-0x335ec4=0xC

将原来的File Size 减少0xC,改为0x18ec4,保存

结论

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5702

Trending Articles