我有一个 arm 32 位 lsb 可执行文件,它在屏幕上打印“hello world”。如何使用radare2将字符串更改为“再见”。
我相信这将教会我 RE 和radare2 的基础知识。
谢谢 !
我有一个 arm 32 位 lsb 可执行文件,它在屏幕上打印“hello world”。如何使用radare2将字符串更改为“再见”。
我相信这将教会我 RE 和radare2 的基础知识。
谢谢 !
让我们从编写一个简单的 Hello, World 程序开始并编译它。
beet:/tmp$ cat helloworld.c
#include <stdio.h>
int main()
{
printf("Hello, World!\n");
return 0;
}
beet:/tmp$ gcc helloworld.c -o helloworld
beet:/tmp$ ./helloworld
Hello, World!
由于我们要修改二进制文件,建议使用原始文件的副本:
beet:/tmp$ cp helloworld modified_helloworld
现在在写入模式 ( -w) 中使用radare2 打开修改后的二进制文件:
beet:/tmp$ r2 -w modified_helloworld
-- Change the UID of the debugged process with child.uid (requires root)
[0x00400430]>
现在我们需要定位字符串“Hello, World!” 在程序中这样我们就会知道我们应该修改的地址。为此,我们将使用iz从数据部分打印字符串的命令:
[0x00400430]> iz
vaddr=0x004005c4 paddr=0x000005c4 ordinal=000 sz=14 len=13 section=.rodata type=ascii string=Hello, World!
我们可以看到“你好,世界!” 位于 ,0x004005c4其长度为“13”。这意味着我们需要用另一个长度为“13”的字符串替换这个字符串。我们将使用“好,再见!!!” 这也是 13 个字符的长度。
我们将使用w命令修改此地址中的字符串:
[0x00400430]> w Good, Bye!!!! @ 0x004005c4
现在退出radare2并执行程序,更改将立即受到影响。
beet:/tmp$ ./modified_helloworld
Good, Bye!!!!
等等!我们改变了输出。
您可以在radare2book的“编辑”一章中阅读更多内容。