【发布时间】:2013-12-12 21:12:37
【问题描述】:
我正在尝试符号化反转的 iOS 二进制文件。所以我开始学习 Mach-O 格式 here 并编写了一个基本程序来测试一个简单的示例,即手动将一个符号添加到剥离的二进制文件中(!):
#include <stdio.h>
#include <stdlib.h>
int division(int a, int b);
int m;
int main(void)
{
int i,j;
printf("initializing i\n");
i = 10;
printf("initializing j\n");
j=1;
printf("i = %d, j = %d\n", i, j);
m = division(i, j);
printf("m = %d / %d = %d\n", i, j, m);
return 0;
}
int division(int a, int b)
{
return a / b;
}
我做了什么:
- 将源代码编译到 ARM 上面,没有任何优化,称为“helloworld”。
- 剥离了这个“helloworld”程序并将其命名为“helloworld_stripped”。
- 在 MachOView 和 hexfiend 中打开了“helloworld_stripped”(进行编辑)。
- 另存为“helloworld_stripped”为“helloworld_stripped2”
- 通过在字符串表末尾添加“_division”修改字符串表
- 在“helloworld_stripped2”的符号表中添加了一个条目,如下所示:
- 修改了 LC_SYMTAB 和 LC_DYNSYMTAB 加载命令以反映新的字符串表大小、偏移量等。以下
otool -l输出反映了这一点(“* * * * *”是 helloworld_stripped,“----”是 helloworld_stripped2): - 然后我在 IDA pro 中打开 'helloworld_stripped' 和 'helloworld_stripped2' 并看到这个:
问题:
修补后的可执行文件“helloworld_stripped2”缺少 printf 函数。为什么 printf 函数在剥离的可执行文件中而不是在修补的可执行文件中?我没有在符号表中更改它,并且 printf 在字符串表中的位置没有更改。
非常感谢任何建议!
编辑:请参阅下面的答案。
【问题讨论】:
-
问三个问题而不是一个问题