如何创建一个“空”的空间?可执行文件中特定地址(gcc,linux)的空间?

发布于 2024-08-07 06:46:04 字数 337 浏览 1 评论 0原文

我本质上想做的是让另一个程序将数据写入这个“空白空间”,以便可执行文件“工作”,

我想向应用程序附加签名,然后写入数据,稍后搜索它,但这并没有”听起来不错...

现在,其他重要的事情...我知道应该可以使用如下代码创建一个代码洞穴:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你与昨日 2024-08-14 06:46:04

至少对于 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 seeks 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.

狼亦尘 2024-08-14 06:46:04

使用 ld 链接器脚本创建一个新节,并在文件映像中保留实际空间。您还需要将符号与新数据部分相关联。也许创建一个简短的汇编文件会更容易,如下所示:

.section .myresource
.align 4
.globl myres
myres:
.fill 1048576

然后在 C 代码中,您将使用符号来获取数据,如下所示:

extern const int* myres;

在此处查看 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:

.section .myresource
.align 4
.globl myres
myres:
.fill 1048576

Then in your C code you would use the symbol to get the data, like this:

extern const int* myres;

Check out the binutils documentation here:
http://sourceware.org/binutils/docs-2.19/

硪扪都還晓 2024-08-14 06:46:04

您可以使用 链接器脚本。

基本上,function_name = 脚本中的地址。

you can do what you asked by using linker scripts.

basically, function_name = address in the script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文