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
- picoCTF
- FSB
- CTF
- 2018
- Read
- rev
- Toddler's Bottle
- anti
- Bottle
- pwnable.kr
- ASM
- pico
- reversing
- shellcode
- Bug
- pwn
- TUCTF
- BOF
- pwnable
- Rookiss
- writeup
- Reverse
- practicalmalwareanalysis
- PMA
- format
- toddler
- shellcraft
- CANARY
- Leak
- string
Archives
- Today
- Total
제리의 블로그
DefCamp CTF 2018 even more lucky Exploit 본문
요약
이 문제는 c 언어 라이브러리의 srand, rand 에 대한 문제로
seed 값을 알아낼 수 있다면 풀 수 있습니다.
바이너리를 리버싱해보면
현재 시간을 이용하여 seed 를 넣고 있다는 것을 알 수 있으므로
같은 seed 값을 넣고 난수 생성을 100번 해주면 되는 문제입니다.
writeup
evenMoreLucky_exploit# nc 167.99.143.206 65032
Hello, there!
What is your name?
j3rrry
I am glad to know you, j3rrry!
Server time: 153761
If you guess the next 100 random numbers I shall give you the flag!
What number am I thinking of? [0/100]
123
Wow that is wrong!
접속해보니 name 과 number 100 개를 입력하는 부분은
이전 문제였던 lucky 와 같은데
Server time 이 주어졌다.
v29 = time(0);
...
srand(v29 / 10);
...
sub_2033(&v26, v29 / 10000);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator=(&v25, &v26);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::~basic_string(&v26);
...
cout << "Server time: " << v25 << endl;
알고보니 현재 시간을 10000으로 나눈 값을 "Server time: " 으로 보여준 것이었고
srand 에 들어가는 seed 값은 현재 시간을 10으로 나눈 값이었다.
10으로 나눈 덕분에 시간지연을 크게 걱정하지 않아도 됬다.
from pwn import *
# init
c = elf.ctypes.CDLL('/lib/x86_64-linux-gnu/libc.so.6')
t = c.time(0)
r = remote('167.99.143.206', 65032)
log.info('local time: %d' % t)
c.srand(t / 10)
# name
r.recvuntil('?\r\n')
r.sendline('j3rrry')
r.recvuntil(': ')
serverTime = r.recvuntil('\r\n', True)
log.info('Server time: %s' % serverTime)
# rand() 100 times
p = log.progress('')
for i in range(100):
p.status(str(i))
r.recvuntil(']\r\n')
r.sendline(str(c.rand()))
p.success()
# flag
r.interactive()
'CTF > pwnable' 카테고리의 다른 글
picoCTF 2018 shellcode Binary Exploitation (0) | 2018.09.30 |
---|---|
picoCTF 2018 buffer overflow 0 (0) | 2018.09.30 |
DefCamp CTF 2018 lucky Exploit (0) | 2018.09.23 |
Nihwk CTF 2018 pwn6 (Frame Pointer Overflow) (0) | 2018.08.28 |
TJCTF 2018 Online Banking (0) | 2018.08.16 |
Comments