如何创建一个“空”的空间?可执行文件中特定地址(gcc,linux)的空间?
我本质上想做的是让另一个程序将数据写入这个“空白空间”,以便可执行文件“工作”,
我想向应用程序附加签名,然后写入数据,稍后搜索它,但这并没有”听起来不错...
现在,其他重要的事情...我知道应该可以使用如下代码创建一个代码洞穴:
void function(void) {
__asm {
nop
nop
nop
nop
};
}
那么,即使这实际上是相同的(除了它会在.data 部分,因此不可执行):
const char data[3];
问题是其他应用程序将没有明确的地址可写入。
What I essentially want to do is have another program write data into this "empty space" for the executable to "work" on
I thought of appending a signature to the application and then writing the data, searching for it later, but that doesn't quite sound right...
Now, other important thing ... I know it should be possible to create a code cave by using code like :
void function(void) {
__asm {
nop
nop
nop
nop
};
}
then, even this is practically the same (apart from the fact that it will be in the .data section, so not executable):
const char data[3];
The problem then is that the other application will not have a definite address to write to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
至少对于 PE 和 ELF 来说,您可以将数据附加到可执行文件的末尾,而完全不会影响程序。
标准方法是将数据附加到可执行文件,然后附加一个数字来指示已附加的字节数。然后,可执行文件打开自身进行读取,查看指示数据长度的最后 N 个字节,然后按该值向后搜索到附加数据的开头。
这篇文章讲得很不错详细介绍如何使用上述方法制作自解压可执行文件。这与您想要的有点不同,但读取可执行文件中包含的数据的原理保持不变。
At least for PEs and ELFs, you can append data to the end of the executable without affecting the program at all.
A standard approach is to append your data to the executable, and then append a number indicating how many bytes have been appended. The executable then opens itself for reading, looks at the last N bytes indicating the data length, and then
seek
s backwards by that value, to the beginning of the appended data.This article goes into pretty good detail on how to use the above method to make a self-extracting executable. That's a little different from what you want, but the principle of reading data contained in the executable remains the same.
使用 ld 链接器脚本创建一个新节,并在文件映像中保留实际空间。您还需要将符号与新数据部分相关联。也许创建一个简短的汇编文件会更容易,如下所示:
然后在 C 代码中,您将使用符号来获取数据,如下所示:
在此处查看 binutils 文档:
http://sourceware.org/binutils/docs-2.19/
Use an ld linker script to make a new section, and to reserve actual space in the file image. You also need to associate a symbol with the new data section. Perhaps it would be even easier to create a short assembly file instead, like this:
Then in your C code you would use the symbol to get the data, like this:
Check out the binutils documentation here:
http://sourceware.org/binutils/docs-2.19/
您可以使用 链接器脚本。
基本上,function_name = 脚本中的地址。
you can do what you asked by using linker scripts.
basically, function_name = address in the script.