PWN 学习笔记

PWN 学习笔记

原理知识:

  • 基础篇(栈的原理):

    • https://ctf-wiki.github.io/ctf-wiki/pwn/stackoverflow/stack_intro/
      1
      2
      3
      4
      https://ctf-wiki.github.io/ctf-wiki/pwn/stackoverflow/stack_intro/
      http://www.cnblogs.com/clover-toeic/p/3755401.html
      http://www.mamicode.com/info-detail-1990426.html
      https://ctf-wiki.github.io/ctf-wiki/pwn/stackoverflow/stackoverflow_basic/
  • file 命令: 用来探测给定文件的类型。file命令对文件的检查分为文件系统、魔法幻数检查和语言检查3个过程

    1
    2
    root@kali:~/Desktop# file what_the_fuck
    what_the_fuck: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=f5874ff98d454f054743d010a0456a89f09aa535, stripped
  • checksec命令: 该脚本来查询该文件使用了哪些防护技术

    1
    2
    3
    4
    5
    6
    7
    root@kali:~/Desktop# checksec what_the_fuck
    [*] '/root/Desktop/what_the_fuck'
    Arch: amd64-64-little
    RELRO: Partial RELRO
    Stack: Canary found
    NX: NX enabled
    PIE: No PIE (0x400000)
  • 数据保护机制:

    • NX 类似于(windows上的DEP)

      1
      2
      3
      在AMD64位CPU上,在页面表(page table)中的页面信息加了一个特殊的位,NX位(No eXecute)。
      如果NX位为0,这个页面上可以执行指令。
      如果NX位为1,这个页面上不允许执行指令。如果试图执行指令的话,就会产生异常。
    • Stack Canary

      1
      2
      3
      在缓冲区和控制信息(如 EBP 等)间插入一个 canary word。
      这样,当缓冲区被溢出时,在返回地址被覆盖之前 canary word 会首先被覆盖。
      通过检查 canary word 的值是否被修改,就可以判断是否发生了溢出攻击
    • PIE 地址空间分布随机化 ALSR

      1
      2
      3
      4
      5
      6
      7
      8
      9
      内存地址随机化机制(address space layout randomization),有以下三种情况

      0 - 表示关闭进程地址空间随机化。
      1 - 表示将mmap的基址,stack和vdso页面随机化。
      2 - 表示在1的基础上增加栈(heap)的随机化。
      可以防范基于Ret2libc方式的针对DEP的攻击。ASLR和DEP配合使用,能有效阻止攻击者在堆栈上运行恶意代码。

      Built as PIE:位置独立的可执行区域(position-independent executables)。
      这样使得在利用缓冲溢出和移动操作系统中存在的其他内存崩溃缺陷时采用面向返回的编程(return-oriented programming)方法变得难得多。
    • RELRO 符号重定向表格

      1
      设置符号重定向表格为只读或在程序启动时就解析并绑定所有动态符号,从而减少对GOT(Global Offset Table)攻击。

linux保护机制整理

DEP,ASLR,更强的Selinux,内核代码段只读,PXN

DEP,ASLR,Selinux等技术在PC时代就已经比较成熟了。内核代码段只读也是可以通过修改ptmx_fops指针表等方案来绕过

  • DEP(windows)、NX(linux)堆栈代码执行保护
    绕过方法:

    1
    2
    使用 (ROP)Return-Oriented Programming.绕过 (如ret2data、ret2libc、ret2strcpy、ret2gets、ret2syscall)
    gadget:virtualprotect、jmp esp、mona.py
  • ASLR 地址随机化

    • 绕过方法:

      1
      2
      3
      4
      5
      1、直接RET替换(一般进程也会加载没有随机化的模块,可以找到JMP ESP指令的跳板直接调用)
      2、替换EIP一部分(找到没有随机化的模块然后使用利息泄漏确定EIP的位置,再算出模块的基地址,最后算出要跳的函数地址)
      3、NOP喷射(DEP没开的情况下,创建一大块NOP+shellcode,Heap Spray是在shellcode的前面加上大量的slide code(滑板指令),组成一个注入代码段。然后向系统申请大量内存,并且反复用注入代码段来填充。这样就使得进程的地址空间被大量的注入代码所占据。然后结合其他的漏洞攻击技术控制程序流,使得程序执行到堆上,最终将导致shellcode的执行。
      统slide code(滑板指令)一般是NOP指令,譬如0x0C(0x0C0C代表的x86指令是OR AL 0x0C),0x0D等等,不影响程序的执行的。)
      4、暴力(如果漏洞不会造成程序崩溃,可以暴力测试256种模块基地址来测试,只到有满足的)最LOW
  • Self-Protection Project(KSPP)

  • 内核代码段和常量数据只读保护

    1
    2
    3
    4
    5
    6
    7
    mark_rodata_ro
    写保护的实现是通过set_memory_ro函数内部调用实现set_page_attributes来实现的。
    攻击方法:

    针对这种页保护的防御,较常用的方法是,从物理页表中取相应的页表条目,找到页表描述符,修改相应的权限。我们可以通过利用内核中现成的代码来完成 页表属性的修改。我们发现可以通过内核导出函数set_memory_rw来打开内核页表的读写权限。set_memory_rw函数的定义如下:

    int set_memory_rw(unsigned long virt, int numpages)
  • PXN( PrivilegedExecute-Never ) “特权执行从不”
    PXN的绕过方法:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    利用ROP技术绕过PXN
    ROP主要原理是通过控制内存中的一段数据,通过控制数据来控制代码执行流,如组合执行内核中特定的代码片段,从而达到修改内核中的关键数据,达到提权限的目的。这种攻击方式是需要进行不同机型中查找到多段代码片段,如果需要root的机型较多,则需要攻击者投入较多精力去做适配。

    利用RET2DIR技术
    利用原理是,Linux内核在设计的时候,在用户空间映射内存的时候,为了提高内存的操作效率,内核也相应地在内核的低端内存区地址映射一段影子内存。

    者利用该缺陷,将用户空间的攻击代码映射到内核的低端内存可执行区或者将特定数据进行喷射到内核的低端内存,进行内存布局,然后利用发现的漏洞,让内核执行攻击代码,从而达到提权的作用。这项技术在32位arm设备上有65%以上的成功率,而在64位arm中有96%的成功率。
    与ROP不同,RET2DIR这项技术不需要对内核代码进行重利用和组合,就可以直接将攻击代码或数据映射到内核的低端内存。
    由于64位ARM内核的设备都已经开启了PXN防护,这项技术成为通用root工具绕过64位ARM内核的PXN必备技术。在KingRoot的cve-2015-3636和cve-2016-1805漏洞利用中都使用到了该技术绕过PXN防护。

    通过内核特定函数完成PXN绕过。
    该技术在2016年MOSEC大会上由360团队公开,该技术巧妙地利用kernel_setsockopt函数的特性,通过控制r0, 让内核执行set_fs(KERNEL_DS),实现任意地址读写权限的效果。
  • KNOX绕过

    1
    2
    3
    4
    三星KNOX里对内核保护主要由TIMA完成。TIMA 使用 ARM TrustZone硬件,持续的监控linux内核的完整性。
    Linux内核采用的CRC完整性认证机制不同,TIMA采用了数字证书签名技术对加载的内核模块进行合法性验证,以确保每个加载的模块都是合法的。

    在2014年SyScan360大会上360团队的陈章琪和申迪介绍了TIMA LKM验证机制的绕过方法。他们的思路是通过Patch内核的代码,绕过TIMA验证。具体的攻击方法如下:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    if(memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0
    || hdr->e_type != ET_REL || elf_check_arch(hdr)
    || hdr->e_shentsize != sizeof(Elf_shdr)){
    err = -ENOEXEC;
    goto free_hdr;
    }

    if(len < hdr->e_snoff + hdr->e_shnum * sizeof(Elf_shdr)){
    err = -ENOEXEC;
    goto free_hdr;
    }

    #ifdef TIMA_LKM_AUTH_ENABLED
    if(lkmauth_bootmode != BOOTMODE_RECOVERY &&
    lkmauth(hdr, len) != RET_LKMAUTH_SUSSESS){
    pr_err
    ("TIMA:lkmauth--unable to load kernel module;module len is %1u,\n",len);
    err = -ENOEXEC;
    goto free_hdr;
    }
    #endif
    info->hdr = hdr;
    info->len = len;
    return 0;
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    X2.0,TIMA引入了实时内核保护(RKP)技术。RKP可在TrustZone内对操作系统进行持续不断且富有策略性的实时监控,以防止篡改内核。

    RKP可对内核内部发生的重要事件进行审计(可在ARM中进行检查)。如果确定某个事件对 OS 内核的完整性具有影响,则 RKP 将会停止该事件,或记录怀疑存在篡改行为的认证结论,并将其发送至 MDM。这可以防止恶意修改和注入内核代码,包括强制内核破坏自身的数据。

    在2.0版本的RKP除了保护页表之外,还保护一些关键的内核对象(如cred,real_cred)。RKP将存储关键安全信息对象的kmem_cache里所有的页都设为只读,只能在TIMA里面对kmem_cache里的页进行写操作。

    在MOSEC2016大会上,科恩实验室的方家弘介绍了KingRoot产品中修改这些关键安全数据,实现DKOM的方法。KingRoot的方法是利用cve-2015-1805的任意地址写的漏洞,修改file_operations里的int (*check_flags)(int) 函数指针,使得函数指针指向override_creds函数。

    通过控制check_flags函数输入参数,使得TIMA主动修改cred的值,从而绕过RKP防护,达到提权的效果。

    除了防止运行时修改关键的安全数据结构之外,RKP还对一些系统调用进行监控,如execve系统调用。

    对于任何的ROOT进程,sec_restrict_fork函数将判断是否该进程的路径是来自/data目录,正常情况下,该目录是存放用户程序的唯一路径。三星希望这样可以阻止类似SU这样的程序可以给/DATA/目录下的用户程序赋权限的情况发生。但是,我们可以依然可以修改一些关键数据来绕过sec_restrict_fork函数的判断
  • 分析漏洞

  • 写exp

PWNTOOLS的基本使用方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
from pwn import *

context.binary(./elf) #The recommended method is to use context.binary to automagically set all of the appropriate values.
context.arch = 'amd64' #Which sets up everything in the exploit for exploiting a 64-bit Intel binary.
context.update(arch='i386', os='linux')


>>> context.clear()
>>> context.update(os='linux')
>>> context.os == 'linux'
True
>>> context.arch = 'arm'
>>> vars(context) == {'arch': 'arm', 'bits': 32, 'endian': 'little', 'os': 'linux'}
True
>>> context.endian
'little'
>>> context.bits
32
>>> def nop():
... print pwnlib.asm.asm('nop').encode('hex')
>>> nop()
00f020e3
>>> with context.local(arch = 'i386'):
... nop()
90
>>> from pwnlib.context import Thread as PwnThread
>>> from threading import Thread as NormalThread
>>> with context.local(arch = 'mips'):
... pwnthread = PwnThread(target=nop)
... thread = NormalThread(target=nop)
>>> # Normal thread uses the default value for arch, 'i386'
>>> _=(thread.start(), thread.join())
90
>>> # Pwnthread uses the correct context from creation-time
>>> _=(pwnthread.start(), pwnthread.join())
00000000
>>> nop()
00f020e3
命令 功能
elf = ELF("./easypwn") 在本地静态加载可执行文件
mian = elf.symbols['main'] 获取本地加载的elf文件的某个函数的加载地址
io.process('./easypwn') 在本地加载可执行文件
io.recvuntil('elf_String\n') 运行程序后直到接收到字符串(elf_String)之后
io.sendline('string') 向进程发送一行数据结尾包含换行符(0x0a)
io.send('string') 向进程发送数据不包含换行符
p64(data)/p32(data) 将数据打包为64/32位运行环境字节码
u64(data)/u32(data) 将数据解包为64/32位环境字节
log.info(data) 将data显示为运行时调试信息

一些基础知识点

x64下前6个参数不是保存在栈中,而是通过寄存器传值

64位汇编

  • 当参数少于7个时, 参数从左到右放入寄存器: rdi, rsi, rdx, rcx, r8, r9。
    当参数为7个以上时, 前 6 个与前面一样, 但后面的依次从 “右向左” 放入栈中,即和32位汇编一样。

  • 参数个数大于 7 个的时候

    • H(a, b, c, d, e, f, g, h);
    • a->%rdi, b->%rsi, c->%rdx, d->%rcx, e->%r8, f->%r9
    • h->8(%esp)
    • g->(%esp)
    • call H

ELF文件加载到内存中的状态

  • BSS段:

    • BSS段(bss segment)通常是指用来存放程序中未初始化的全局变量的一块内存区域。
    • BSS是英文Block Started by Symbol的简称。
    • BSS段属于静态内存分配。
  • 数据段:

    • 数据段(data segment)通常是指用来存放程序中已初始化的全局变量的一块内存区域。
    • 数据段属于静态内存分配。
  • 代码段:

    • 代码段(code segment/text segment)通常是指用来存放程序执行代码的一块内存区域。
    • 这部分区域的大小在程序运行前就已经确定,并且内存区域通常属于只读, 某些架构也允许代码段为可写,即允许修改程序。
    • 在代码段中,也有可能包含一些只读的常数变量,例如字符串常量等。
  • 堆(heap):

    • 堆是用于存放进程运行中被动态分配的内存段,它的大小并不固定,可动态扩张或缩减。
    • 当进程调用malloc等函数分配内存时,新分配的内存就被动态添加到堆上(堆被扩张);当利用free等函数释放内存时,被释放的内存从堆中被剔除(堆被缩减)
  • 栈(stack):

    • 栈又称堆栈, 是用户存放程序临时创建的局部变量,也就是说我们函数括弧“{}”中定义的变量(但不包括static声明的变量,static意味着在数据段中存放变量)。
    • 除此以外,在函数被调用时,其参数也会被压入发起调用的进程栈中,并且待到调用结束后,函数的返回值也会被存放回栈中。
    • 由于栈的先进先出特点,所以栈特别方便用来保存/恢复调用现场。从这个意义上讲,我们可以把堆栈看成一个寄存、交换临时数据的内存区。

确定缓冲区大小的peda方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
gdb-peda$ pattern_create 60
'AAA%AAsAABAA$AAnAACAA-AA(AADAA;AA)AAEAAaAA0AAFAAbAA1AAGAAcAA'
gdb-peda$ run
Starting program: /root/Desktop/ret2resolve/babystack

Program received signal SIGALRM, Alarm clock.
AAA%AAsAABAA$AAnAACAA-AA(AADAA;AA)AAEAAaAA0AAFAAbAA1AAGAAcAA

Program received signal SIGSEGV, Segmentation fault.

[----------------------------------registers-----------------------------------]
EAX: 0x3d ('=')
EBX: 0x0
ECX: 0xffffd190 ("AAA%AAsAABAA$AAnAACAA-AA(AADAA;AA)AAEAAaAA0AAFAAbAA1AAGAAcAA\n\271\336", <incomplete sequence \367>)
EDX: 0x40 ('@')
ESI: 0xf7fa8000 --> 0x1d5d8c
EDI: 0x0
EBP: 0x41304141 ('AA0A')
ESP: 0xffffd1c0 ("bAA1AAGAAcAA\n\271\336", <incomplete sequence \367>)
EIP: 0x41414641 ('AFAA')
EFLAGS: 0x10286 (carry PARITY adjust zero SIGN trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
Invalid $PC address: 0x41414641
[------------------------------------stack-------------------------------------]
0000| 0xffffd1c0 ("bAA1AAGAAcAA\n\271\336", <incomplete sequence \367>)
0004| 0xffffd1c4 ("AAGAAcAA\n\271\336", <incomplete sequence \367>)
0008| 0xffffd1c8 ("AcAA\n\271\336", <incomplete sequence \367>)
0012| 0xffffd1cc --> 0xf7deb90a (<__libc_start_main+90>: and ebx,0x2)
0016| 0xffffd1d0 --> 0xf7fa8000 --> 0x1d5d8c
0020| 0xffffd1d4 --> 0xf7fa8000 --> 0x1d5d8c
0024| 0xffffd1d8 --> 0x0
0028| 0xffffd1dc --> 0xf7deb9a1 (<__libc_start_main+241>: add esp,0x10)
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x41414641 in ?? ()


gdb-peda$ pattern_offset AFAA
AFAA found at offset: 44
gdb-peda$

确定缓冲区大小的gef方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
gef➤  pattern create 200
[+] Generating a pattern of 200 bytes
aaaabaaacaaadaaaeaaafaaagaaahaaaiaaajaaakaaalaaamaaanaaaoaaapaaaqaaaraaasaaataaauaaavaaawaaaxaaayaaazaabbaabcaabdaabeaabfaabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqaabraabsaabtaabuaabvaabwaabxaabyaab
[+] Saved as '$_gef0'
gef➤ r
Starting program: /root/Desktop/PWN/ret2_dl_runtime_resolve/main
Welcome to XDCTF2015~!
aaaabaaacaaadaaaeaaafaaagaaahaaaiaaajaaakaaalaaamaaanaaaoaaapaaaqaaaraaasaaataaauaaavaaawaaaxaaayaaazaabbaabcaabdaabeaabfaabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqaabraabsaabtaabuaabvaabwaabxaabyaab

Program received signal SIGSEGV, Segmentation fault.
[ Legend: Modified register | Code | Heap | Stack | String ]
────────────────────────────────────────────────────────────────────────────[ registers ]────
$eax : 0xc9
$ebx : 0x0
$ecx : 0xffffd0ac → "aaaabaaacaaadaaaeaaafaaagaaahaaaiaaajaaakaaalaaama[...]"
$edx : 0x100
$esp : 0xffffd120 → "eaabfaabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqa[...]"
$ebp : 0x62616163 ("caab"?)
$esi : 0xf7fa8000 → 0x001d5d8c
$edi : 0xffffd190 → 0xffffd1b0 → 0x00000001
$eip : 0x62616164 ("daab"?)
$eflags: [zero carry PARITY adjust SIGN trap INTERRUPT direction overflow RESUME virtualx86 identification]
$gs: 0x0063 $ds: 0x002b $fs: 0x0000 $ss: 0x002b $es: 0x002b $cs: 0x0023
────────────────────────────────────────────────────────────────────────────────[ stack ]────
0xffffd120│+0x00: "eaabfaabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqa[...]" ← $esp
0xffffd124│+0x04: "faabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqaabra[...]"
0xffffd128│+0x08: "gaabhaabiaabjaabkaablaabmaabnaaboaabpaabqaabraabsa[...]"
0xffffd12c│+0x0c: "haabiaabjaabkaablaabmaabnaaboaabpaabqaabraabsaabta[...]"
0xffffd130│+0x10: "iaabjaabkaablaabmaabnaaboaabpaabqaabraabsaabtaabua[...]"
0xffffd134│+0x14: "jaabkaablaabmaabnaaboaabpaabqaabraabsaabtaabuaabva[...]"
0xffffd138│+0x18: "kaablaabmaabnaaboaabpaabqaabraabsaabtaabuaabvaabwa[...]"
0xffffd13c│+0x1c: "laabmaabnaaboaabpaabqaabraabsaabtaabuaabvaabwaabxa[...]"
────────────────────────────────────────────────────────────────────────────[ code:i386 ]────
[!] Cannot disassemble from $PC
[!] Cannot access memory at address 0x62616164
──────────────────────────────────────────────────────────────────────────────[ threads ]────
[#0] Id 1, Name: "main", stopped, reason: SIGSEGV
────────────────────────────────────────────────────────────────────────────────[ trace ]────
─────────────────────────────────────────────────────────────────────────────────────────────
[ Legend: Modified register | Code | Heap | Stack | String ]
────────────────────────────────────────────────────────────────────────────[ registers ]────
$eax : 0xc9
$ebx : 0x0
$ecx : 0xffffd0ac → "aaaabaaacaaadaaaeaaafaaagaaahaaaiaaajaaakaaalaaama[...]"
$edx : 0x100
$esp : 0xffffd120 → "eaabfaabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqa[...]"
$ebp : 0x62616163 ("caab"?)
$esi : 0xf7fa8000 → 0x001d5d8c
$edi : 0xffffd190 → 0xffffd1b0 → 0x00000001
$eip : 0x62616164 ("daab"?)
$eflags: [zero carry PARITY adjust SIGN trap INTERRUPT direction overflow RESUME virtualx86 identification]
$gs: 0x0063 $ds: 0x002b $fs: 0x0000 $ss: 0x002b $es: 0x002b $cs: 0x0023
────────────────────────────────────────────────────────────────────────────────[ stack ]────
0xffffd120│+0x00: "eaabfaabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqa[...]" ← $esp
0xffffd124│+0x04: "faabgaabhaabiaabjaabkaablaabmaabnaaboaabpaabqaabra[...]"
0xffffd128│+0x08: "gaabhaabiaabjaabkaablaabmaabnaaboaabpaabqaabraabsa[...]"
0xffffd12c│+0x0c: "haabiaabjaabkaablaabmaabnaaboaabpaabqaabraabsaabta[...]"
0xffffd130│+0x10: "iaabjaabkaablaabmaabnaaboaabpaabqaabraabsaabtaabua[...]"
0xffffd134│+0x14: "jaabkaablaabmaabnaaboaabpaabqaabraabsaabtaabuaabva[...]"
0xffffd138│+0x18: "kaablaabmaabnaaboaabpaabqaabraabsaabtaabuaabvaabwa[...]"
0xffffd13c│+0x1c: "laabmaabnaaboaabpaabqaabraabsaabtaabuaabvaabwaabxa[...]"
────────────────────────────────────────────────────────────────────────────[ code:i386 ]────
[!] Cannot disassemble from $PC
[!] Cannot access memory at address 0x62616164
──────────────────────────────────────────────────────────────────────────────[ threads ]────
[#0] Id 1, Name: "main", stopped, reason: SIGSEGV
────────────────────────────────────────────────────────────────────────────────[ trace ]────
─────────────────────────────────────────────────────────────────────────────────────────────
0x62616164 in ?? ()

gef➤ pattern search 0x62616164
[+] Searching '0x62616164'
[+] Found at offset 112 (little-endian search) likely

使gef的调试信息输出到不同的终端窗口

1
2
3
4
$ tty       #这个命令查看当前打开的终端数量
/dev/pts/0 #这个结果表示有一个终端窗口
gef➤ gef config context.redirect /dev/pts/0 #命令设置将运行结果输出到0号终端窗口
gef➤ gef config context.redirect "" #恢复设置

objdump使用相关技巧

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
objdump -f test  显示test的文件头信息

objdump -d test 反汇编test中的需要执行指令的那些section

objdump -D test 与-d类似,但反汇编test中的所有section

objdump -h test 显示test的Section Header信息

objdump -x test 显示test的全部Header信息

objdump -s test 除了显示test的全部Header信息,还显示他们对应的十六进制文件代码

输出到txt文件objdump -s test.so>test.txt

同时可以用命nm,strace,gdb.

常用的查找偏移的办法

  • strings工具

    1
    2
    root@kali:~/Desktop/PWN/guess# strings -a -tx /lib/x86_64-linux-gnu/libc.so.6 | grep "environ"
    142be __environ
  • ROPgadget工具

    1
    2
    3
    4
    5
    6
    7
    8
    9
    root@kali:~/Desktop/PWN/guess# ROPgadget --binary /lib/x86_64-linux-gnu/libc.so.6 --only "__environ"
    Gadgets information
    ============================================================

    Unique gadgets found: 0
    root@kali:~/Desktop/PWN/guess# ROPgadget --binary easypwn --only 'pop|ret'
    ...
    root@kali:~/Desktop/PWN/guess# ROPgadget --binary easypwn --only 'pop|ret' | grep 'ebx'
    ...
  • 目前感觉上面的两种工具都有自己的优点:

    • strings工具更好的锁定libc文件中的字符串的位置,搜索速度更快
    • ROPgadget工具能够更好的锁定汇编代码的片段提供的信息更加详细,但搜索速度较慢

gef工具与pwndbg调试工具区别

  • 最近刚刚发现的这两个工具的一个不同之处,具体原因解释的可能不对,但这个现象是存在的。
  • 遇到程序fork()或者其他什么能够产生另一个进程的程序的时候,gef不会直接跳转到这个进程去让你调试,如果你所下的断点包含在fork()子进程的代码部分里面,gef会直接执行,并不会在该位置停下,总结一下就是你的这个断点的执行效果不在当前进程的时候gef不能够帮你断下来,他会直接开了子进程,然后执行到该断点处继续执行,切记不会停下来,此时对于父进程而言,是gef正在调试的进程则会处在等待子进程相应返回的状态,待到子进程返回之后,父进程继续执行。换句话说,就是你的断点不在当前进程时,gef不会帮你断下来。如果父进程有wait() 函数等待子进程状态,而你在调试的时候是单步步过的call wait这句命令,那么gef会陷入阻塞状态等待子进程返回,而此时子进程又断了下来(因为单步执行),gef就会一直等这个暂停的进程,使用gdb,attach到该子进程后使其继续执行,父进程的gef等待状态在收到子进程结束的信息后会结束等待状态。
  • 然而pwndbg则会直接帮你跳转到子进程去,在断点的位置停下,并且结束后自动返回父进程进行调试

GDB调试技巧

汇编语言ret后带一个参数的执行方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
pwndbg> si
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd07c —▸ 0xf7eb8470 (read) ◂— push esi
EIP 0xf7fea35b (_dl_runtime_resolve+27) ◂— ret 0xc
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>

0xf7fea350 <_dl_runtime_resolve+16> pop edx
0xf7fea351 <_dl_runtime_resolve+17> mov ecx, dword ptr [esp]
0xf7fea354 <_dl_runtime_resolve+20> mov dword ptr [esp], eax
0xf7fea357 <_dl_runtime_resolve+23> mov eax, dword ptr [esp + 4]
► 0xf7fea35b <_dl_runtime_resolve+27> ret 0xc

0xf7eb8470 <read> push esi
0xf7eb8471 <read+1> push ebx
0xf7eb8472 <read+2> sub esp, 0x14
0xf7eb8475 <read+5> mov ebx, dword ptr [esp + 0x20]
0xf7eb8479 <read+9> mov ecx, dword ptr [esp + 0x24]
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd07c —▸ 0xf7eb8470 (read) ◂— push esi
01:0004│ 0xffffd080 —▸ 0xffffd0ac ◂— 0x1
02:0008│ 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
03:000c│ 0xffffd088 ◂— 0x8
04:0010│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
05:0014│ 0xffffd090 ◂— 0x0
06:0018│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
07:001c│ 0xffffd098 ◂— 0x100
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7eb8470 read
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
__GI___libc_read (fd=0x0, buf=0xffffd0ac, nbytes=0x100) at ../sysdeps/unix/sysv/linux/read.c:26
26 ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
EIP 0xf7eb8470 (read) ◂— push esi
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
► 0xf7eb8470 <read> push esi
0xf7eb8471 <read+1> push ebx
0xf7eb8472 <read+2> sub esp, 0x14
0xf7eb8475 <read+5> mov ebx, dword ptr [esp + 0x20]
0xf7eb8479 <read+9> mov ecx, dword ptr [esp + 0x24]
0xf7eb847d <read+13> mov edx, dword ptr [esp + 0x28]
0xf7eb8481 <read+17> mov eax, dword ptr gs:[0xc]
0xf7eb8487 <read+23> test eax, eax
0xf7eb8489 <read+25> jne read+56 <0xf7eb84a8>

0xf7eb84a8 <read+56> mov dword ptr [esp + 0xc], edx
0xf7eb84ac <read+60> mov dword ptr [esp + 8], ecx
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
01:0004│ 0xffffd090 ◂— 0x0
02:0008│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
03:000c│ 0xffffd098 ◂— 0x100
04:0010│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
05:0014│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
06:0018│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
07:001c│ 0xffffd0a8 —▸ 0xf7fce410 —▸ 0x80482d9 ◂— inc edi /* 'GLIBC_2.0' */
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7eb8470 read
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
  • 上面的内容是一个简单的例子,ret 0xc 的执行效果,首先从栈顶弹出一个值最为返回地址,去相应的位置执行,然后从栈顶弹出偏移0xc的内容,或者理解为 esp - 0xc,此程序为32位系统,则效果为从栈顶弹出三个值
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
pwndbg> b main
pwndbg> si
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd090 ◂— 0x0
EIP 0x8048514 (vuln+41) —▸ 0xfffe87e8 ◂— 0x0
─────────────────────────────────────────[ DISASM ]──────────────────────────────────────────
0x8048509 <vuln+30> push 0x100
0x804850e <vuln+35> lea eax, [ebp - 0x6c]
0x8048511 <vuln+38> push eax
0x8048512 <vuln+39> push 0
► 0x8048514 <vuln+41> call read@plt <0x80483a0>
fd: 0x0
buf: 0xffffd0ac ◂— 0x1
nbytes: 0x100

0x8048519 <vuln+46> add esp, 0x10
0x804851c <vuln+49> nop
0x804851d <vuln+50> leave
0x804851e <vuln+51> ret

0x804851f <main> lea ecx, [esp + 4]
0x8048523 <main+4> and esp, 0xfffffff0
──────────────────────────────────────────[ STACK ]──────────────────────────────────────────
00:0000│ esp 0xffffd090 ◂— 0x0
01:0004│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
02:0008│ 0xffffd098 ◂— 0x100
03:000c│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
04:0010│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
05:0014│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
06:0018│ 0xffffd0a8 —▸ 0xf7fce410 —▸ 0x80482d9 ◂— inc edi /* 'GLIBC_2.0' */
07:001c│ eax ecx 0xffffd0ac ◂— 0x1
────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────
► f 0 80483a0 read@plt
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
0x080483a0 in read@plt ()
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
EIP 0x80483a0 (read@plt) ◂— jmp dword ptr [0x804a010]
─────────────────────────────────────────[ DISASM ]──────────────────────────────────────────
► 0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
──────────────────────────────────────────[ STACK ]──────────────────────────────────────────
00:0000│ esp 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
01:0004│ 0xffffd090 ◂— 0x0
02:0008│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
03:000c│ 0xffffd098 ◂— 0x100
04:0010│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
05:0014│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
06:0018│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
07:001c│ 0xffffd0a8 —▸ 0xf7fce410 —▸ 0x80482d9 ◂— inc edi /* 'GLIBC_2.0' */
────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────
► f 0 80483a0 read@plt
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
pwndbg> si
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
EIP 0x80483a0 (read@plt) ◂— jmp dword ptr [0x804a010]
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
► 0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
01:0004│ 0xffffd090 ◂— 0x0
02:0008│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
03:000c│ 0xffffd098 ◂— 0x100
04:0010│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
05:0014│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
06:0018│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
07:001c│ 0xffffd0a8 —▸ 0xf7fce410 —▸ 0x80482d9 ◂— inc edi /* 'GLIBC_2.0' */
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 80483a6 read@plt+6
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
0x080483a6 in read@plt ()
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
EIP 0x80483a6 (read@plt+6) ◂— push 8
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

► 0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
01:0004│ 0xffffd090 ◂— 0x0
02:0008│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
03:000c│ 0xffffd098 ◂— 0x100
04:0010│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
05:0014│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
06:0018│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
07:001c│ 0xffffd0a8 —▸ 0xf7fce410 —▸ 0x80482d9 ◂— inc edi /* 'GLIBC_2.0' */
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 80483a6 read@plt+6
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
pwndbg>
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
EIP 0x80483a6 (read@plt+6) ◂— push 8
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

► 0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
01:0004│ 0xffffd090 ◂— 0x0
02:0008│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
03:000c│ 0xffffd098 ◂— 0x100
04:0010│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
05:0014│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
06:0018│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
07:001c│ 0xffffd0a8 —▸ 0xf7fce410 —▸ 0x80482d9 ◂— inc edi /* 'GLIBC_2.0' */
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 80483ab read@plt+11
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
0x080483ab in read@plt ()
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd088 ◂— 0x8
EIP 0x80483ab (read@plt+11) —▸ 0xffffd0e9 ◂— 0x67ffffd1
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
► 0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd088 ◂— 0x8
01:0004│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
02:0008│ 0xffffd090 ◂— 0x0
03:000c│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
04:0010│ 0xffffd098 ◂— 0x100
05:0014│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
06:0018│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
07:001c│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 80483ab read@plt+11
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
pwndbg> x/10i 0x8048380
0x8048380: push DWORD PTR ds:0x804a004
0x8048386: jmp DWORD PTR ds:0x804a008
0x804838c: add BYTE PTR [eax],al
0x804838e: add BYTE PTR [eax],al
0x8048390 <setbuf@plt>: jmp DWORD PTR ds:0x804a00c
0x8048396 <setbuf@plt+6>: push 0x0
0x804839b <setbuf@plt+11>: jmp 0x8048380
0x80483a0 <read@plt>: jmp DWORD PTR ds:0x804a010
0x80483a6 <read@plt+6>: push 0x8
=> 0x80483ab <read@plt+11>: jmp 0x8048380
pwndbg> x/xw 0x804a004
0x804a004: 0xf7ffd940
pwndbg>
0x804a008: 0xf7fea340
pwndbg> si
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd088 ◂— 0x8
EIP 0x80483ab (read@plt+11) —▸ 0xffffd0e9 ◂— 0x67ffffd1
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
► 0x80483ab <read@plt+11> jmp 0x8048380

0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>

0xf7fea350 <_dl_runtime_resolve+16> pop edx
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd088 ◂— 0x8
01:0004│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
02:0008│ 0xffffd090 ◂— 0x0
03:000c│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
04:0010│ 0xffffd098 ◂— 0x100
05:0014│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
06:0018│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
07:001c│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 8048380
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
0x08048380 in ?? ()
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd088 ◂— 0x8
EIP 0x8048380 ◂— push dword ptr [0x804a004]
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

► 0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd088 ◂— 0x8
01:0004│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
02:0008│ 0xffffd090 ◂— 0x0
03:000c│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
04:0010│ 0xffffd098 ◂— 0x100
05:0014│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
06:0018│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
07:001c│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 8048380
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
pwndbg>
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd088 ◂— 0x8
EIP 0x8048380 ◂— push dword ptr [0x804a004]
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

► 0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd088 ◂— 0x8
01:0004│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
02:0008│ 0xffffd090 ◂— 0x0
03:000c│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
04:0010│ 0xffffd098 ◂— 0x100
05:0014│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
06:0018│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
07:001c│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 8048386
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
0x08048386 in ?? ()
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
EIP 0x8048386 ◂— jmp dword ptr [0x804a008]
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
► 0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
01:0004│ 0xffffd088 ◂— 0x8
02:0008│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
03:000c│ 0xffffd090 ◂— 0x0
04:0010│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
05:0014│ 0xffffd098 ◂— 0x100
06:0018│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
07:001c│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 8048386
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
pwndbg>
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
EIP 0x8048386 ◂— jmp dword ptr [0x804a008]
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
► 0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
01:0004│ 0xffffd088 ◂— 0x8
02:0008│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
03:000c│ 0xffffd090 ◂— 0x0
04:0010│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
05:0014│ 0xffffd098 ◂— 0x100
06:0018│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
07:001c│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7fea340 _dl_runtime_resolve
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
_dl_runtime_resolve () at ../sysdeps/i386/dl-trampoline.S:35
35 ../sysdeps/i386/dl-trampoline.S: No such file or directory.
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
EIP 0xf7fea340 (_dl_runtime_resolve) ◂— push eax
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0x80483a0 <read@plt> jmp dword ptr [_GLOBAL_OFFSET_TABLE_+16] <0x804a010>

0x80483a6 <read@plt+6> push 8
0x80483ab <read@plt+11> jmp 0x8048380

0x8048380 push dword ptr [_GLOBAL_OFFSET_TABLE_+4] <0x804a004>
0x8048386 jmp dword ptr [0x804a008] <0xf7fea340>

► 0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
01:0004│ 0xffffd088 ◂— 0x8
02:0008│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
03:000c│ 0xffffd090 ◂— 0x0
04:0010│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
05:0014│ 0xffffd098 ◂— 0x100
06:0018│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
07:001c│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7fea340 _dl_runtime_resolve
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241

pwndbg> b *0xf7fea350
Breakpoint 3 at 0xf7fea350: file ../sysdeps/i386/dl-trampoline.S, line 44.
pwndbg> c
Continuing.
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xf7ffd940 ◂— 0x0
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0x8
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd078 —▸ 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EIP 0xf7fea34b (_dl_runtime_resolve+11) —▸ 0xffa1a0e8 ◂— 0xffa1a0e8
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0xf7fea340 <_dl_runtime_resolve> push eax
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
► 0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>
arg[0]: 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
arg[1]: 0xffffd0ac ◂— 0x1

0xf7fea350 <_dl_runtime_resolve+16> pop edx
0xf7fea351 <_dl_runtime_resolve+17> mov ecx, dword ptr [esp]
0xf7fea354 <_dl_runtime_resolve+20> mov dword ptr [esp], eax
0xf7fea357 <_dl_runtime_resolve+23> mov eax, dword ptr [esp + 4]
0xf7fea35b <_dl_runtime_resolve+27> ret 0xc
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd078 —▸ 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
01:0004│ 0xffffd07c —▸ 0xffffd0ac ◂— 0x1
... ↓
03:000c│ 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
04:0010│ 0xffffd088 ◂— 0x8
05:0014│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
06:0018│ 0xffffd090 ◂— 0x0
07:001c│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7fea350 _dl_runtime_resolve+16
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241

Breakpoint 3, _dl_runtime_resolve () at ../sysdeps/i386/dl-trampoline.S:44
44 in ../sysdeps/i386/dl-trampoline.S
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xf7eb8470 (read) ◂— push esi
EBX 0x0
ECX 0xf7dd9eb8 ◂— 0x21b2
EDX 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd078 —▸ 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EIP 0xf7fea350 (_dl_runtime_resolve+16) ◂— pop edx
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0xf7fea341 <_dl_runtime_resolve+1> push ecx
0xf7fea342 <_dl_runtime_resolve+2> push edx
0xf7fea343 <_dl_runtime_resolve+3> mov edx, dword ptr [esp + 0x10]
0xf7fea347 <_dl_runtime_resolve+7> mov eax, dword ptr [esp + 0xc]
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>

► 0xf7fea350 <_dl_runtime_resolve+16> pop edx
0xf7fea351 <_dl_runtime_resolve+17> mov ecx, dword ptr [esp]
0xf7fea354 <_dl_runtime_resolve+20> mov dword ptr [esp], eax
0xf7fea357 <_dl_runtime_resolve+23> mov eax, dword ptr [esp + 4]
0xf7fea35b <_dl_runtime_resolve+27> ret 0xc

0xf7eb8470 <read> push esi
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd078 —▸ 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
01:0004│ 0xffffd07c —▸ 0xffffd0ac ◂— 0x1
... ↓
03:000c│ 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
04:0010│ 0xffffd088 ◂— 0x8
05:0014│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
06:0018│ 0xffffd090 ◂— 0x0
07:001c│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7fea350 _dl_runtime_resolve+16
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
Breakpoint *0xf7fea350
pwndbg> x/xw 0x8048a010
0x8048a010: Cannot access memory at address 0x8048a010
pwndbg> x/xw 0x804a010
0x804a010: 0xf7eb8470

pwndbg> c
......

pwndbg> si
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd07c —▸ 0xf7eb8470 (read) ◂— push esi
EIP 0xf7fea35b (_dl_runtime_resolve+27) ◂— ret 0xc
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
0xf7fea34b <_dl_runtime_resolve+11> call _dl_fixup <0xf7fe44f0>

0xf7fea350 <_dl_runtime_resolve+16> pop edx
0xf7fea351 <_dl_runtime_resolve+17> mov ecx, dword ptr [esp]
0xf7fea354 <_dl_runtime_resolve+20> mov dword ptr [esp], eax
0xf7fea357 <_dl_runtime_resolve+23> mov eax, dword ptr [esp + 4]
► 0xf7fea35b <_dl_runtime_resolve+27> ret 0xc

0xf7eb8470 <read> push esi
0xf7eb8471 <read+1> push ebx
0xf7eb8472 <read+2> sub esp, 0x14
0xf7eb8475 <read+5> mov ebx, dword ptr [esp + 0x20]
0xf7eb8479 <read+9> mov ecx, dword ptr [esp + 0x24]
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd07c —▸ 0xf7eb8470 (read) ◂— push esi
01:0004│ 0xffffd080 —▸ 0xffffd0ac ◂— 0x1
02:0008│ 0xffffd084 —▸ 0xf7ffd940 ◂— 0x0
03:000c│ 0xffffd088 ◂— 0x8
04:0010│ 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
05:0014│ 0xffffd090 ◂— 0x0
06:0018│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
07:001c│ 0xffffd098 ◂— 0x100
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7eb8470 read
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
__GI___libc_read (fd=0x0, buf=0xffffd0ac, nbytes=0x100) at ../sysdeps/unix/sysv/linux/read.c:26
26 ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
───────────────────────────────────────────────────────────────────────────────────────[ REGISTERS ]────────────────────────────────────────────────────────────────────────────────────────
EAX 0xffffd0ac ◂— 0x1
EBX 0x0
ECX 0xffffd0ac ◂— 0x1
EDX 0xf7fa989c (_IO_stdfile_0_lock) ◂— 0x0
EDI 0xffffd190 —▸ 0xffffd1b0 ◂— 0x1
ESI 0xf7fa8000 (_GLOBAL_OFFSET_TABLE_) ◂— 0x1d5d8c
EBP 0xffffd118 —▸ 0xffffd198 ◂— 0x0
ESP 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
EIP 0xf7eb8470 (read) ◂— push esi
─────────────────────────────────────────────────────────────────────────────────────────[ DISASM ]─────────────────────────────────────────────────────────────────────────────────────────
► 0xf7eb8470 <read> push esi
0xf7eb8471 <read+1> push ebx
0xf7eb8472 <read+2> sub esp, 0x14
0xf7eb8475 <read+5> mov ebx, dword ptr [esp + 0x20]
0xf7eb8479 <read+9> mov ecx, dword ptr [esp + 0x24]
0xf7eb847d <read+13> mov edx, dword ptr [esp + 0x28]
0xf7eb8481 <read+17> mov eax, dword ptr gs:[0xc]
0xf7eb8487 <read+23> test eax, eax
0xf7eb8489 <read+25> jne read+56 <0xf7eb84a8>

0xf7eb84a8 <read+56> mov dword ptr [esp + 0xc], edx
0xf7eb84ac <read+60> mov dword ptr [esp + 8], ecx
─────────────────────────────────────────────────────────────────────────────────────────[ STACK ]──────────────────────────────────────────────────────────────────────────────────────────
00:0000│ esp 0xffffd08c —▸ 0x8048519 (vuln+46) ◂— add esp, 0x10
01:0004│ 0xffffd090 ◂— 0x0
02:0008│ 0xffffd094 —▸ 0xffffd0ac ◂— 0x1
03:000c│ 0xffffd098 ◂— 0x100
04:0010│ 0xffffd09c —▸ 0xf7ffd940 ◂— 0x0
05:0014│ 0xffffd0a0 —▸ 0xffffd0d4 —▸ 0xf7ddf728 ◂— 0x147a
06:0018│ 0xffffd0a4 —▸ 0xf7ffdaf8 —▸ 0xf7ffda9c —▸ 0xf7fce3e0 —▸ 0xf7ffd940 ◂— ...
07:001c│ 0xffffd0a8 —▸ 0xf7fce410 —▸ 0x80482d9 ◂— inc edi /* 'GLIBC_2.0' */
───────────────────────────────────────────────────────────────────────────────────────[ BACKTRACE ]────────────────────────────────────────────────────────────────────────────────────────
► f 0 f7eb8470 read
f 1 8048519 vuln+46
f 2 80485a7 main+136
f 3 f7deb9a1 __libc_start_main+241
pwndbg>

ROP(Return Oriented Programming)

参考链接:https://ctf-wiki.github.io/ctf-wiki/pwn/stackoverflow/basic_rop/

按照ctf_wiki上的顺序,逐步深入的学习

基本ROP

  • ret2text,ret2syscall,ret2shellcode,ret2libc

  • ret2resolve

    使用readelf查看动态段 .dynamic 的信息

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    root@kali:~/Desktop/ret2resolve# readelf -d babystack

    Dynamic section at offset 0xf14 contains 24 entries:
    Tag Type Name/Value
    0x00000001 (NEEDED) Shared library: [libc.so.6]
    0x0000000c (INIT) 0x80482c8
    0x0000000d (FINI) 0x80484f4
    0x00000019 (INIT_ARRAY) 0x8049f08
    0x0000001b (INIT_ARRAYSZ) 4 (bytes)
    0x0000001a (FINI_ARRAY) 0x8049f0c
    0x0000001c (FINI_ARRAYSZ) 4 (bytes)
    0x6ffffef5 (GNU_HASH) 0x80481ac
    0x00000005 (STRTAB) 0x804822c
    0x00000006 (SYMTAB) 0x80481cc
    0x0000000a (STRSZ) 80 (bytes)
    0x0000000b (SYMENT) 16 (bytes)
    0x00000015 (DEBUG) 0x0
    0x00000003 (PLTGOT) 0x804a000
    0x00000002 (PLTRELSZ) 24 (bytes)
    0x00000014 (PLTREL) REL
    0x00000017 (JMPREL) 0x80482b0
    0x00000011 (REL) 0x80482a8
    0x00000012 (RELSZ) 8 (bytes)
    0x00000013 (RELENT) 8 (bytes)
    0x6ffffffe (VERNEED) 0x8048288
    0x6fffffff (VERNEEDNUM) 1
    0x6ffffff0 (VERSYM) 0x804827c
    0x00000000 (NULL) 0x0

    JMPREL中保存的是.rel.plt表中的信息

    1
    0x00000017 (JMPREL)                     0x80482b0

    PLTRELSZ是.rel.plt表的大小为24字节

    1
    0x00000002 (PLTRELSZ)                   24 (bytes)

    RELENT为每个.rel.plt表项的大小为8字节

    1
    0x00000013 (RELENT)                     8 (bytes)

    这些表项为ELF32_Rel类型的数据结构。其中r_offset是该函数在got表中的位置,r_info为其类型和符号序号。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    typedef uint32_t Elf32_Addr;
    typedef uint32_t Elf32_Word;
    typedef struct
    {
    Elf32_Addr r_offset; /* Address */
    Elf32_Word r_info; /* Relocation type and symbol index */
    } Elf32_Rel;
    #define ELF32_R_SYM(val) ((val) >> 8)
    #define ELF32_R_TYPE(val) ((val) & 0xff)

    查看 .rel.plt 表中的信息,使用命令readelf -r babystack

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    root@kali:~/Desktop/ret2resolve# readelf -r babystack

    Relocation section '.rel.dyn' at offset 0x2a8 contains 1 entry:
    Offset Info Type Sym.Value Sym. Name
    08049ffc 00000306 R_386_GLOB_DAT 00000000 __gmon_start__

    Relocation section '.rel.plt' at offset 0x2b0 contains 3 entries:
    Offset Info Type Sym.Value Sym. Name
    0804a00c 00000107 R_386_JUMP_SLOT 00000000 read@GLIBC_2.0
    0804a010 00000207 R_386_JUMP_SLOT 00000000 alarm@GLIBC_2.0
    0804a014 00000407 R_386_JUMP_SLOT 00000000 __libc_start_main@GLIBC_2.0

    r_info为0x107,其中1表示read在符号表SYMTAB中的偏移为1,7表示为R_386_JUMP_SLOT类型,这一项用于检查,保持为7即可。我们前面看到的函数字符串就是通过在SYMTAB中的偏移来找到的。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    gef➤  x/30i read
    0x8048300 <read@plt>: jmp DWORD PTR ds:0x804a00c
    0x8048306 <read@plt+6>: push 0x0
    0x804830b <read@plt+11>: jmp 0x80482f0
    0x8048310 <alarm@plt>: jmp DWORD PTR ds:0x804a010
    0x8048316 <alarm@plt+6>: push 0x8
    0x804831b <alarm@plt+11>: jmp 0x80482f0
    0x8048320 <__libc_start_main@plt>: jmp DWORD PTR ds:0x804a014
    0x8048326 <__libc_start_main@plt+6>: push 0x10
    0x804832b <__libc_start_main@plt+11>: jmp 0x80482f0
    0x8048330 <__gmon_start__@plt>: jmp DWORD PTR ds:0x8049ffc
    0x8048336 <__gmon_start__@plt+6>: xchg ax,ax
    0x8048338: Cannot access memory at address 0x8048338

中级ROP

高级ROP

堆溢出利用

  • 什么是堆:

    • 堆可以提供动态分配的内存,允许程序申请大小未知的内存。堆其实就是程序虚拟地址空间的一块连续的线性区域,它由低地址向高地址方向增长。
      对于不同的应用来说,由于内存的需求各不相同等特性,因此目前堆的实现有很多种,具体如下
  • 只有当真正访问一个地址的时候,系统才会建立虚拟页面与物理页面的映射关系。

1
2
3
4
5
dlmalloc  – General purpose allocator
ptmalloc2 – glibc
jemalloc – FreeBSD and Firefox
tcmalloc – Google
libumem – Solaris

系统函数调用号:

32位

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#ifndef _ASM_X86_UNISTD_32_H
#define _ASM_X86_UNISTD_32_H 1

#define __NR_restart_syscall 0
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
#define __NR_write 4
#define __NR_open 5
#define __NR_close 6
#define __NR_waitpid 7
#define __NR_creat 8
#define __NR_link 9
#define __NR_unlink 10
#define __NR_execve 11
#define __NR_chdir 12
#define __NR_time 13
#define __NR_mknod 14
#define __NR_chmod 15
#define __NR_lchown 16
#define __NR_break 17
#define __NR_oldstat 18
#define __NR_lseek 19
#define __NR_getpid 20
#define __NR_mount 21
#define __NR_umount 22
#define __NR_setuid 23
#define __NR_getuid 24
#define __NR_stime 25
#define __NR_ptrace 26
#define __NR_alarm 27
#define __NR_oldfstat 28
#define __NR_pause 29
#define __NR_utime 30
#define __NR_stty 31
#define __NR_gtty 32
#define __NR_access 33
#define __NR_nice 34
#define __NR_ftime 35
#define __NR_sync 36
#define __NR_kill 37
#define __NR_rename 38
#define __NR_mkdir 39
#define __NR_rmdir 40
#define __NR_dup 41
#define __NR_pipe 42
#define __NR_times 43
#define __NR_prof 44
#define __NR_brk 45
#define __NR_setgid 46
#define __NR_getgid 47
#define __NR_signal 48
#define __NR_geteuid 49
#define __NR_getegid 50
#define __NR_acct 51
#define __NR_umount2 52
#define __NR_lock 53
#define __NR_ioctl 54
#define __NR_fcntl 55
#define __NR_mpx 56
#define __NR_setpgid 57
#define __NR_ulimit 58
#define __NR_oldolduname 59
#define __NR_umask 60
#define __NR_chroot 61
#define __NR_ustat 62
#define __NR_dup2 63
#define __NR_getppid 64
#define __NR_getpgrp 65
#define __NR_setsid 66
#define __NR_sigaction 67
#define __NR_sgetmask 68
#define __NR_ssetmask 69
#define __NR_setreuid 70
#define __NR_setregid 71
#define __NR_sigsuspend 72
#define __NR_sigpending 73
#define __NR_sethostname 74
#define __NR_setrlimit 75
#define __NR_getrlimit 76
#define __NR_getrusage 77
#define __NR_gettimeofday 78
#define __NR_settimeofday 79
#define __NR_getgroups 80
#define __NR_setgroups 81
#define __NR_select 82
#define __NR_symlink 83
#define __NR_oldlstat 84
#define __NR_readlink 85
#define __NR_uselib 86
#define __NR_swapon 87
#define __NR_reboot 88
#define __NR_readdir 89
#define __NR_mmap 90
#define __NR_munmap 91
#define __NR_truncate 92
#define __NR_ftruncate 93
#define __NR_fchmod 94
#define __NR_fchown 95
#define __NR_getpriority 96
#define __NR_setpriority 97
#define __NR_profil 98
#define __NR_statfs 99
#define __NR_fstatfs 100
#define __NR_ioperm 101
#define __NR_socketcall 102
#define __NR_syslog 103
#define __NR_setitimer 104
#define __NR_getitimer 105
#define __NR_stat 106
#define __NR_lstat 107
#define __NR_fstat 108
#define __NR_olduname 109
#define __NR_iopl 110
#define __NR_vhangup 111
#define __NR_idle 112
#define __NR_vm86old 113
#define __NR_wait4 114
#define __NR_swapoff 115
#define __NR_sysinfo 116
#define __NR_ipc 117
#define __NR_fsync 118
#define __NR_sigreturn 119
#define __NR_clone 120
#define __NR_setdomainname 121
#define __NR_uname 122
#define __NR_modify_ldt 123
#define __NR_adjtimex 124
#define __NR_mprotect 125
#define __NR_sigprocmask 126
#define __NR_create_module 127
#define __NR_init_module 128
#define __NR_delete_module 129
#define __NR_get_kernel_syms 130
#define __NR_quotactl 131
#define __NR_getpgid 132
#define __NR_fchdir 133
#define __NR_bdflush 134
#define __NR_sysfs 135
#define __NR_personality 136
#define __NR_afs_syscall 137
#define __NR_setfsuid 138
#define __NR_setfsgid 139
#define __NR__llseek 140
#define __NR_getdents 141
#define __NR__newselect 142
#define __NR_flock 143
#define __NR_msync 144
#define __NR_readv 145
#define __NR_writev 146
#define __NR_getsid 147
#define __NR_fdatasync 148
#define __NR__sysctl 149
#define __NR_mlock 150
#define __NR_munlock 151
#define __NR_mlockall 152
#define __NR_munlockall 153
#define __NR_sched_setparam 154
#define __NR_sched_getparam 155
#define __NR_sched_setscheduler 156
#define __NR_sched_getscheduler 157
#define __NR_sched_yield 158
#define __NR_sched_get_priority_max 159
#define __NR_sched_get_priority_min 160
#define __NR_sched_rr_get_interval 161
#define __NR_nanosleep 162
#define __NR_mremap 163
#define __NR_setresuid 164
#define __NR_getresuid 165
#define __NR_vm86 166
#define __NR_query_module 167
#define __NR_poll 168
#define __NR_nfsservctl 169
#define __NR_setresgid 170
#define __NR_getresgid 171
#define __NR_prctl 172
#define __NR_rt_sigreturn 173
#define __NR_rt_sigaction 174
#define __NR_rt_sigprocmask 175
#define __NR_rt_sigpending 176
#define __NR_rt_sigtimedwait 177
#define __NR_rt_sigqueueinfo 178
#define __NR_rt_sigsuspend 179
#define __NR_pread64 180
#define __NR_pwrite64 181
#define __NR_chown 182
#define __NR_getcwd 183
#define __NR_capget 184
#define __NR_capset 185
#define __NR_sigaltstack 186
#define __NR_sendfile 187
#define __NR_getpmsg 188
#define __NR_putpmsg 189
#define __NR_vfork 190
#define __NR_ugetrlimit 191
#define __NR_mmap2 192
#define __NR_truncate64 193
#define __NR_ftruncate64 194
#define __NR_stat64 195
#define __NR_lstat64 196
#define __NR_fstat64 197
#define __NR_lchown32 198
#define __NR_getuid32 199
#define __NR_getgid32 200
#define __NR_geteuid32 201
#define __NR_getegid32 202
#define __NR_setreuid32 203
#define __NR_setregid32 204
#define __NR_getgroups32 205
#define __NR_setgroups32 206
#define __NR_fchown32 207
#define __NR_setresuid32 208
#define __NR_getresuid32 209
#define __NR_setresgid32 210
#define __NR_getresgid32 211
#define __NR_chown32 212
#define __NR_setuid32 213
#define __NR_setgid32 214
#define __NR_setfsuid32 215
#define __NR_setfsgid32 216
#define __NR_pivot_root 217
#define __NR_mincore 218
#define __NR_madvise 219
#define __NR_getdents64 220
#define __NR_fcntl64 221
#define __NR_gettid 224
#define __NR_readahead 225
#define __NR_setxattr 226
#define __NR_lsetxattr 227
#define __NR_fsetxattr 228
#define __NR_getxattr 229
#define __NR_lgetxattr 230
#define __NR_fgetxattr 231
#define __NR_listxattr 232
#define __NR_llistxattr 233
#define __NR_flistxattr 234
#define __NR_removexattr 235
#define __NR_lremovexattr 236
#define __NR_fremovexattr 237
#define __NR_tkill 238
#define __NR_sendfile64 239
#define __NR_futex 240
#define __NR_sched_setaffinity 241
#define __NR_sched_getaffinity 242
#define __NR_set_thread_area 243
#define __NR_get_thread_area 244
#define __NR_io_setup 245
#define __NR_io_destroy 246
#define __NR_io_getevents 247
#define __NR_io_submit 248
#define __NR_io_cancel 249
#define __NR_fadvise64 250
#define __NR_exit_group 252
#define __NR_lookup_dcookie 253
#define __NR_epoll_create 254
#define __NR_epoll_ctl 255
#define __NR_epoll_wait 256
#define __NR_remap_file_pages 257
#define __NR_set_tid_address 258
#define __NR_timer_create 259
#define __NR_timer_settime 260
#define __NR_timer_gettime 261
#define __NR_timer_getoverrun 262
#define __NR_timer_delete 263
#define __NR_clock_settime 264
#define __NR_clock_gettime 265
#define __NR_clock_getres 266
#define __NR_clock_nanosleep 267
#define __NR_statfs64 268
#define __NR_fstatfs64 269
#define __NR_tgkill 270
#define __NR_utimes 271
#define __NR_fadvise64_64 272
#define __NR_vserver 273
#define __NR_mbind 274
#define __NR_get_mempolicy 275
#define __NR_set_mempolicy 276
#define __NR_mq_open 277
#define __NR_mq_unlink 278
#define __NR_mq_timedsend 279
#define __NR_mq_timedreceive 280
#define __NR_mq_notify 281
#define __NR_mq_getsetattr 282
#define __NR_kexec_load 283
#define __NR_waitid 284
#define __NR_add_key 286
#define __NR_request_key 287
#define __NR_keyctl 288
#define __NR_ioprio_set 289
#define __NR_ioprio_get 290
#define __NR_inotify_init 291
#define __NR_inotify_add_watch 292
#define __NR_inotify_rm_watch 293
#define __NR_migrate_pages 294
#define __NR_openat 295
#define __NR_mkdirat 296
#define __NR_mknodat 297
#define __NR_fchownat 298
#define __NR_futimesat 299
#define __NR_fstatat64 300
#define __NR_unlinkat 301
#define __NR_renameat 302
#define __NR_linkat 303
#define __NR_symlinkat 304
#define __NR_readlinkat 305
#define __NR_fchmodat 306
#define __NR_faccessat 307
#define __NR_pselect6 308
#define __NR_ppoll 309
#define __NR_unshare 310
#define __NR_set_robust_list 311
#define __NR_get_robust_list 312
#define __NR_splice 313
#define __NR_sync_file_range 314
#define __NR_tee 315
#define __NR_vmsplice 316
#define __NR_move_pages 317
#define __NR_getcpu 318
#define __NR_epoll_pwait 319
#define __NR_utimensat 320
#define __NR_signalfd 321
#define __NR_timerfd_create 322
#define __NR_eventfd 323
#define __NR_fallocate 324
#define __NR_timerfd_settime 325
#define __NR_timerfd_gettime 326
#define __NR_signalfd4 327
#define __NR_eventfd2 328
#define __NR_epoll_create1 329
#define __NR_dup3 330
#define __NR_pipe2 331
#define __NR_inotify_init1 332
#define __NR_preadv 333
#define __NR_pwritev 334
#define __NR_rt_tgsigqueueinfo 335
#define __NR_perf_event_open 336
#define __NR_recvmmsg 337
#define __NR_fanotify_init 338
#define __NR_fanotify_mark 339
#define __NR_prlimit64 340
#define __NR_name_to_handle_at 341
#define __NR_open_by_handle_at 342
#define __NR_clock_adjtime 343
#define __NR_syncfs 344
#define __NR_sendmmsg 345
#define __NR_setns 346
#define __NR_process_vm_readv 347
#define __NR_process_vm_writev 348
#define __NR_kcmp 349
#define __NR_finit_module 350
#define __NR_sched_setattr 351
#define __NR_sched_getattr 352
#define __NR_renameat2 353
#define __NR_seccomp 354
#define __NR_getrandom 355
#define __NR_memfd_create 356
#define __NR_bpf 357
#define __NR_execveat 358
#define __NR_socket 359
#define __NR_socketpair 360
#define __NR_bind 361
#define __NR_connect 362
#define __NR_listen 363
#define __NR_accept4 364
#define __NR_getsockopt 365
#define __NR_setsockopt 366
#define __NR_getsockname 367
#define __NR_getpeername 368
#define __NR_sendto 369
#define __NR_sendmsg 370
#define __NR_recvfrom 371
#define __NR_recvmsg 372
#define __NR_shutdown 373
#define __NR_userfaultfd 374
#define __NR_membarrier 375
#define __NR_mlock2 376
#define __NR_copy_file_range 377
#define __NR_preadv2 378
#define __NR_pwritev2 379

#endif /* _ASM_X86_UNISTD_32_H */

64位

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#ifndef _ASM_X86_UNISTD_64_H
#define _ASM_X86_UNISTD_64_H 1

#define __NR_read 0
#define __NR_write 1
#define __NR_open 2
#define __NR_close 3
#define __NR_stat 4
#define __NR_fstat 5
#define __NR_lstat 6
#define __NR_poll 7
#define __NR_lseek 8
#define __NR_mmap 9
#define __NR_mprotect 10
#define __NR_munmap 11
#define __NR_brk 12
#define __NR_rt_sigaction 13
#define __NR_rt_sigprocmask 14
#define __NR_rt_sigreturn 15
#define __NR_ioctl 16
#define __NR_pread64 17
#define __NR_pwrite64 18
#define __NR_readv 19
#define __NR_writev 20
#define __NR_access 21
#define __NR_pipe 22
#define __NR_select 23
#define __NR_sched_yield 24
#define __NR_mremap 25
#define __NR_msync 26
#define __NR_mincore 27
#define __NR_madvise 28
#define __NR_shmget 29
#define __NR_shmat 30
#define __NR_shmctl 31
#define __NR_dup 32
#define __NR_dup2 33
#define __NR_pause 34
#define __NR_nanosleep 35
#define __NR_getitimer 36
#define __NR_alarm 37
#define __NR_setitimer 38
#define __NR_getpid 39
#define __NR_sendfile 40
#define __NR_socket 41
#define __NR_connect 42
#define __NR_accept 43
#define __NR_sendto 44
#define __NR_recvfrom 45
#define __NR_sendmsg 46
#define __NR_recvmsg 47
#define __NR_shutdown 48
#define __NR_bind 49
#define __NR_listen 50
#define __NR_getsockname 51
#define __NR_getpeername 52
#define __NR_socketpair 53
#define __NR_setsockopt 54
#define __NR_getsockopt 55
#define __NR_clone 56
#define __NR_fork 57
#define __NR_vfork 58
#define __NR_execve 59
#define __NR_exit 60
#define __NR_wait4 61
#define __NR_kill 62
#define __NR_uname 63
#define __NR_semget 64
#define __NR_semop 65
#define __NR_semctl 66
#define __NR_shmdt 67
#define __NR_msgget 68
#define __NR_msgsnd 69
#define __NR_msgrcv 70
#define __NR_msgctl 71
#define __NR_fcntl 72
#define __NR_flock 73
#define __NR_fsync 74
#define __NR_fdatasync 75
#define __NR_truncate 76
#define __NR_ftruncate 77
#define __NR_getdents 78
#define __NR_getcwd 79
#define __NR_chdir 80
#define __NR_fchdir 81
#define __NR_rename 82
#define __NR_mkdir 83
#define __NR_rmdir 84
#define __NR_creat 85
#define __NR_link 86
#define __NR_unlink 87
#define __NR_symlink 88
#define __NR_readlink 89
#define __NR_chmod 90
#define __NR_fchmod 91
#define __NR_chown 92
#define __NR_fchown 93
#define __NR_lchown 94
#define __NR_umask 95
#define __NR_gettimeofday 96
#define __NR_getrlimit 97
#define __NR_getrusage 98
#define __NR_sysinfo 99
#define __NR_times 100
#define __NR_ptrace 101
#define __NR_getuid 102
#define __NR_syslog 103
#define __NR_getgid 104
#define __NR_setuid 105
#define __NR_setgid 106
#define __NR_geteuid 107
#define __NR_getegid 108
#define __NR_setpgid 109
#define __NR_getppid 110
#define __NR_getpgrp 111
#define __NR_setsid 112
#define __NR_setreuid 113
#define __NR_setregid 114
#define __NR_getgroups 115
#define __NR_setgroups 116
#define __NR_setresuid 117
#define __NR_getresuid 118
#define __NR_setresgid 119
#define __NR_getresgid 120
#define __NR_getpgid 121
#define __NR_setfsuid 122
#define __NR_setfsgid 123
#define __NR_getsid 124
#define __NR_capget 125
#define __NR_capset 126
#define __NR_rt_sigpending 127
#define __NR_rt_sigtimedwait 128
#define __NR_rt_sigqueueinfo 129
#define __NR_rt_sigsuspend 130
#define __NR_sigaltstack 131
#define __NR_utime 132
#define __NR_mknod 133
#define __NR_uselib 134
#define __NR_personality 135
#define __NR_ustat 136
#define __NR_statfs 137
#define __NR_fstatfs 138
#define __NR_sysfs 139
#define __NR_getpriority 140
#define __NR_setpriority 141
#define __NR_sched_setparam 142
#define __NR_sched_getparam 143
#define __NR_sched_setscheduler 144
#define __NR_sched_getscheduler 145
#define __NR_sched_get_priority_max 146
#define __NR_sched_get_priority_min 147
#define __NR_sched_rr_get_interval 148
#define __NR_mlock 149
#define __NR_munlock 150
#define __NR_mlockall 151
#define __NR_munlockall 152
#define __NR_vhangup 153
#define __NR_modify_ldt 154
#define __NR_pivot_root 155
#define __NR__sysctl 156
#define __NR_prctl 157
#define __NR_arch_prctl 158
#define __NR_adjtimex 159
#define __NR_setrlimit 160
#define __NR_chroot 161
#define __NR_sync 162
#define __NR_acct 163
#define __NR_settimeofday 164
#define __NR_mount 165
#define __NR_umount2 166
#define __NR_swapon 167
#define __NR_swapoff 168
#define __NR_reboot 169
#define __NR_sethostname 170
#define __NR_setdomainname 171
#define __NR_iopl 172
#define __NR_ioperm 173
#define __NR_create_module 174
#define __NR_init_module 175
#define __NR_delete_module 176
#define __NR_get_kernel_syms 177
#define __NR_query_module 178
#define __NR_quotactl 179
#define __NR_nfsservctl 180
#define __NR_getpmsg 181
#define __NR_putpmsg 182
#define __NR_afs_syscall 183
#define __NR_tuxcall 184
#define __NR_security 185
#define __NR_gettid 186
#define __NR_readahead 187
#define __NR_setxattr 188
#define __NR_lsetxattr 189
#define __NR_fsetxattr 190
#define __NR_getxattr 191
#define __NR_lgetxattr 192
#define __NR_fgetxattr 193
#define __NR_listxattr 194
#define __NR_llistxattr 195
#define __NR_flistxattr 196
#define __NR_removexattr 197
#define __NR_lremovexattr 198
#define __NR_fremovexattr 199
#define __NR_tkill 200
#define __NR_time 201
#define __NR_futex 202
#define __NR_sched_setaffinity 203
#define __NR_sched_getaffinity 204
#define __NR_set_thread_area 205
#define __NR_io_setup 206
#define __NR_io_destroy 207
#define __NR_io_getevents 208
#define __NR_io_submit 209
#define __NR_io_cancel 210
#define __NR_get_thread_area 211
#define __NR_lookup_dcookie 212
#define __NR_epoll_create 213
#define __NR_epoll_ctl_old 214
#define __NR_epoll_wait_old 215
#define __NR_remap_file_pages 216
#define __NR_getdents64 217
#define __NR_set_tid_address 218
#define __NR_restart_syscall 219
#define __NR_semtimedop 220
#define __NR_fadvise64 221
#define __NR_timer_create 222
#define __NR_timer_settime 223
#define __NR_timer_gettime 224
#define __NR_timer_getoverrun 225
#define __NR_timer_delete 226
#define __NR_clock_settime 227
#define __NR_clock_gettime 228
#define __NR_clock_getres 229
#define __NR_clock_nanosleep 230
#define __NR_exit_group 231
#define __NR_epoll_wait 232
#define __NR_epoll_ctl 233
#define __NR_tgkill 234
#define __NR_utimes 235
#define __NR_vserver 236
#define __NR_mbind 237
#define __NR_set_mempolicy 238
#define __NR_get_mempolicy 239
#define __NR_mq_open 240
#define __NR_mq_unlink 241
#define __NR_mq_timedsend 242
#define __NR_mq_timedreceive 243
#define __NR_mq_notify 244
#define __NR_mq_getsetattr 245
#define __NR_kexec_load 246
#define __NR_waitid 247
#define __NR_add_key 248
#define __NR_request_key 249
#define __NR_keyctl 250
#define __NR_ioprio_set 251
#define __NR_ioprio_get 252
#define __NR_inotify_init 253
#define __NR_inotify_add_watch 254
#define __NR_inotify_rm_watch 255
#define __NR_migrate_pages 256
#define __NR_openat 257
#define __NR_mkdirat 258
#define __NR_mknodat 259
#define __NR_fchownat 260
#define __NR_futimesat 261
#define __NR_newfstatat 262
#define __NR_unlinkat 263
#define __NR_renameat 264
#define __NR_linkat 265
#define __NR_symlinkat 266
#define __NR_readlinkat 267
#define __NR_fchmodat 268
#define __NR_faccessat 269
#define __NR_pselect6 270
#define __NR_ppoll 271
#define __NR_unshare 272
#define __NR_set_robust_list 273
#define __NR_get_robust_list 274
#define __NR_splice 275
#define __NR_tee 276
#define __NR_sync_file_range 277
#define __NR_vmsplice 278
#define __NR_move_pages 279
#define __NR_utimensat 280
#define __NR_epoll_pwait 281
#define __NR_signalfd 282
#define __NR_timerfd_create 283
#define __NR_eventfd 284
#define __NR_fallocate 285
#define __NR_timerfd_settime 286
#define __NR_timerfd_gettime 287
#define __NR_accept4 288
#define __NR_signalfd4 289
#define __NR_eventfd2 290
#define __NR_epoll_create1 291
#define __NR_dup3 292
#define __NR_pipe2 293
#define __NR_inotify_init1 294
#define __NR_preadv 295
#define __NR_pwritev 296
#define __NR_rt_tgsigqueueinfo 297
#define __NR_perf_event_open 298
#define __NR_recvmmsg 299
#define __NR_fanotify_init 300
#define __NR_fanotify_mark 301
#define __NR_prlimit64 302
#define __NR_name_to_handle_at 303
#define __NR_open_by_handle_at 304
#define __NR_clock_adjtime 305
#define __NR_syncfs 306
#define __NR_sendmmsg 307
#define __NR_setns 308
#define __NR_getcpu 309
#define __NR_process_vm_readv 310
#define __NR_process_vm_writev 311
#define __NR_kcmp 312
#define __NR_finit_module 313
#define __NR_sched_setattr 314
#define __NR_sched_getattr 315
#define __NR_renameat2 316
#define __NR_seccomp 317
#define __NR_getrandom 318
#define __NR_memfd_create 319
#define __NR_kexec_file_load 320
#define __NR_bpf 321
#define __NR_execveat 322
#define __NR_userfaultfd 323
#define __NR_membarrier 324
#define __NR_mlock2 325
#define __NR_copy_file_range 326
#define __NR_preadv2 327
#define __NR_pwritev2 328

#endif /* _ASM_X86_UNISTD_64_H */
-------------本文结束感谢您的阅读-------------
0%