본문 바로가기

wargame

level3 summary: simple bof level3@io:/levels$ cat level03.c//bla, based on work by beach #include #include void good(){ puts("Win."); execl("/bin/sh", "sh", NULL);}void bad(){ printf("I'm so sorry, you're at %p and you want to be at %p\n", bad, good);} int main(int argc, char **argv, char **envp){ void (*functionpointer)(void) = bad; char buffer[50]; if(argc != 2 || strlen(argv[1]) < 4) return 0; memcp.. 더보기
level2_alt summary: strtod도 NaN(Not a Number)을 지원하는 함수이다. NaN은 숫자가 아니기 때문에 어떠한 숫자와도 비교하면 거짓이된다. 처음에는 Float은 4바이트고 double은 8바이트라 부동소수점 계산을 통해 값을 비슷하게 맞추는 문제인줄 알앗다.그러나 코딩해서 돌려본 결과 정확하게 일치하게 마출수는 없엇다. 그래서 고민하던중 strtod의 man페이지 에서 다음과 같은것을 발견한다. A NAN is "NAN" (disregarding case) optionally followed by '(', a sequence of characters, followed by ')'. The character string speci†fies in an implementation-depende.. 더보기
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 | /.. 더보기