1

我有一个以 pwnable.tw 命名的 ELF 32 位可执行文件orwhttps ://pwnable.tw/challenge/ 。在我的 Ubuntu18.04 中,可以执行 .bss 段: 在此处输入图像描述

但是在我的 Ubuntu20 和 IDA Pro 中,.bss 段没有可执行属性,为什么? 在此处输入图像描述 在此处输入图像描述

4

2 回答 2

1

为什么.bss段没有可执行属性?</p>

普通的可执行文件中.bss应该有执行权限,所以奇怪的是 Ubuntu 18.04 结果,而不是相反。

以下都是相关的:

  • 从输出readelf -Wl orw
  • 内核版本
  • 从输出cat /proc/cpuinfo
  • 模拟器详细信息(如果您使用的是某种模拟器)。

我怀疑您使用的是模拟器,并且它设置为模拟NX 前位处理器(其中W位也隐含 X位)。

或者,可执行文件缺少PT_GNU_STACK段,在这种情况下,这个答案很可能是正确的——这些二进制文件的内核默认值已经改变。

于 2021-12-18T21:28:10.787 回答
0

.bss is a segment for uninitialized global variables, so It's not normally executable (it doesn't need to). If you want it executable (because you are compiling machine code that you want to be able to test) you will probably need to select a special segment or to create two segments (one executable and other read/write) overlapping to allow to write the code while you can also execute it. This can be already specified in the standard script you use to link executables (with a different name, sure) or if it has not been done for you, you can specify a linker script that allows for those to be created. Read the linker documentation (in full, sorry) to know how the linker deals with this (and other) idiosynchracies of your processor architecture.

I don't know what architecture you are using, but for example, intel processors have an execution bit permissions in the segments, as they have read and write, which means that the memory access for an executable segment must be an opcode fetch access and not a data read access to load a data register. If you want to access the text segment for data reading, then you need to add also read access to the text segment to be able to see the code you are executing.

于 2021-12-20T08:13:56.773 回答