缓冲区溢出内存映射解释

发布于 2024-08-14 06:23:45 字数 1769 浏览 1 评论 0原文

我正在处理一个微不足道的缓冲区溢出(是的,利用;但与问题无关),当启用 GCC 的堆栈保护器时,我试图找出内存映射中的字段。举例来说:

$ ./overflow
*** stack smashing detected ***: ./overflow terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb7f67da8]
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x0)[0xb7f67d60]
./overflow[0x804845c]
[0x41414141]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:06 3704767    /home/hatred/w0rk/bugz
08049000-0804a000 r--p 00000000 08:06 3704767    /home/hatred/w0rk/bugz
0804a000-0804b000 rw-p 00001000 08:06 3704767    /home/hatred/w0rk/bugz
0804b000-0806c000 rw-p 0804b000 00:00 0          [heap]
b7e5a000-b7e67000 r-xp 00000000 08:06 368705     /lib/libgcc_s.so.1
b7e67000-b7e68000 r--p 0000c000 08:06 368705     /lib/libgcc_s.so.1
b7e68000-b7e69000 rw-p 0000d000 08:06 368705     /lib/libgcc_s.so.1
b7e69000-b7e6a000 rw-p b7e69000 00:00 0 
b7e6a000-b7fc6000 r-xp 00000000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc6000-b7fc7000 ---p 0015c000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc7000-b7fc9000 r--p 0015c000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc9000-b7fca000 rw-p 0015e000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fca000-b7fcd000 rw-p b7fca000 00:00 0 
b7fdf000-b7fe1000 rw-p b7fdf000 00:00 0 
b7fe1000-b7fe2000 r-xp b7fe1000 00:00 0          [vdso]
b7fe2000-b7ffe000 r-xp 00000000 08:06 368654     /lib/ld-2.9.so
b7ffe000-b7fff000 r--p 0001b000 08:06 368654     /lib/ld-2.9.so
b7fff000-b8000000 rw-p 0001c000 08:06 368654     /lib/ld-2.9.so
bffeb000-c0000000 rw-p bffeb000 00:00 0          [stack]
Aborted

所以,如你所见;有回溯,然后是内存映射,有 5 个字段,然后是可选的第六个字段,其中可能包括 .so.1 (共享库?)我问这些字段是什么,以及它们的含义,例如十六进制字段,以及 rw-p 的含义等。

我已经在谷歌上进行了搜索,但没有出现这样的情况。

谢谢。

I'm tackling a trivial buffer overflow (yes, exploitation; but unrelated to the problem) I'm trying to figure out the fields in the memory map, when GCC's stack protector is enabled. As an illustration:

$ ./overflow
*** stack smashing detected ***: ./overflow terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb7f67da8]
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x0)[0xb7f67d60]
./overflow[0x804845c]
[0x41414141]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:06 3704767    /home/hatred/w0rk/bugz
08049000-0804a000 r--p 00000000 08:06 3704767    /home/hatred/w0rk/bugz
0804a000-0804b000 rw-p 00001000 08:06 3704767    /home/hatred/w0rk/bugz
0804b000-0806c000 rw-p 0804b000 00:00 0          [heap]
b7e5a000-b7e67000 r-xp 00000000 08:06 368705     /lib/libgcc_s.so.1
b7e67000-b7e68000 r--p 0000c000 08:06 368705     /lib/libgcc_s.so.1
b7e68000-b7e69000 rw-p 0000d000 08:06 368705     /lib/libgcc_s.so.1
b7e69000-b7e6a000 rw-p b7e69000 00:00 0 
b7e6a000-b7fc6000 r-xp 00000000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc6000-b7fc7000 ---p 0015c000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc7000-b7fc9000 r--p 0015c000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc9000-b7fca000 rw-p 0015e000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fca000-b7fcd000 rw-p b7fca000 00:00 0 
b7fdf000-b7fe1000 rw-p b7fdf000 00:00 0 
b7fe1000-b7fe2000 r-xp b7fe1000 00:00 0          [vdso]
b7fe2000-b7ffe000 r-xp 00000000 08:06 368654     /lib/ld-2.9.so
b7ffe000-b7fff000 r--p 0001b000 08:06 368654     /lib/ld-2.9.so
b7fff000-b8000000 rw-p 0001c000 08:06 368654     /lib/ld-2.9.so
bffeb000-c0000000 rw-p bffeb000 00:00 0          [stack]
Aborted

So, as you can see; There's the backtrace, and then there's the memory map, with 5 fields, and then an optional sixth one which may include a .so.1 (shared libraries?) I'm asking about what these fields are, and what they mean, like the hex fields, and what rw-p means, etc.

I've gone on google and searched but nothing like this comes up.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

旧梦荧光笔 2024-08-21 06:23:45

查看 /proc 文件系统 的手册页,它包含您需要的所有信息:

/proc/[数字]/地图
包含当前映射的内存区域及其访问权限的文件
权限。

格式为:

地址 权限 偏移量 dev inode 路径名
08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm
08056000-08058000 rw-p 0000d000 03:0c 64593 /usr/sbin/gpm
08058000-0805b000 读写 00000000 00:00 0
40000000-40013000 r-xp 00000000 03:0c 4165 /lib/ld-2.2.4.so
40013000-40015000 rw-p 00012000 03:0c 4165 /lib/ld-2.2.4.so
4001f000-40135000 r-xp 00000000 03:0c 45494 /lib/libc-2.2.4.so
40135000-4013e000 rw-p 00115000 03:0c 45494 /lib/libc-2.2.4.so
4013e000-40142000 读写 00000000 00:00 0
bffff000-c0000000 rwxp 00000000 00:00 0

其中address是它占用的进程中的地址空间,perms

是一组权限:

<前><代码>r = 已读
w = 写
x = 执行
s = 共享
p = 私有(写入时复制)

offset 是文件/其他内容的偏移量,dev 是设备

(major:minor),inode为inode
在该设备上。 0表示没有
inode 与内存关联
区域,就像 bss 的情况一样。

Check out the man page for the /proc filesystem, it has all the info you need:

/proc/[number]/maps
A file containing the currently mapped memory regions and their access
permissions.

The format is:

address           perms offset  dev   inode      pathname
08048000-08056000 r-xp 00000000 03:0c 64593      /usr/sbin/gpm
08056000-08058000 rw-p 0000d000 03:0c 64593      /usr/sbin/gpm
08058000-0805b000 rwxp 00000000 00:00 0
40000000-40013000 r-xp 00000000 03:0c 4165       /lib/ld-2.2.4.so
40013000-40015000 rw-p 00012000 03:0c 4165       /lib/ld-2.2.4.so
4001f000-40135000 r-xp 00000000 03:0c 45494      /lib/libc-2.2.4.so
40135000-4013e000 rw-p 00115000 03:0c 45494      /lib/libc-2.2.4.so
4013e000-40142000 rw-p 00000000 00:00 0
bffff000-c0000000 rwxp 00000000 00:00 0

where address is the address space in the process that it occupies, perms

is a set of permissions:

r = read
w = write
x = execute
s = shared
p = private (copy on write)

offset is the offset into the file/whatever, dev is the device

(major:minor), and inode is the inode
on that device. 0 indicates that no
inode is associated with the memory
region, as the case would be with bss.

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