전체 글(333)
-
[3] bof
소스코드12345678910111213141516171819#include #include #include void func(int key){ char overflowme[32]; printf("overflow me : "); gets(overflowme); // smash me! if(key == 0xcafebabe){ system("/bin/sh"); } else{ printf("Nah..\n"); }}int main(int argc, char* argv[]){ func(0xdeadbeef); return 0;} Colored by Color Scriptercs 가상서버에서 #wget http://pwnable.kr/bin/bof 명령어를 이용해서 bof 파일을 다운받은 후 디버깅 해보자func함수0..
2017.12.05 -
[1] fd
파일 디스크립터 ( File Discriptor ) 0 : 표준 입력1 : 표준 출력2 : 표준 에러 12345678910111213141516171819202122 #include #include #include char buf[32];int main(int argc, char* argv[], char* envp[]){ if(argc 표준입력을 받아서 32길이만큼의 데이터를 buf에 저장 strcmp( str1 , str2 )str1 과 str2 를 비교해서 같으면 0 , str1 > str2 : 양수 , str1 < str2 : 음수 반환 atoi() 함수입력받은 문자열을 long 정수형으로 변환한다* fd = atoi( argv[1] ) - 0x1234* 0x1234 == 4660
2017.12.05 -
[5] evil_wizard -> dark_stone ( GOT Overwriting & Remote BOF )
evil_wizard / get down like that이전 문제와 푸는 방법은 같지만 Remote 라는 점만 다르다 ( cat 과 nc를 이용한 풀이 ) [ dark_stone.c ]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 /* The Lord of the BOF : The Fellowship of the BOF - dark_stone - Remote BOF on Fedora Core 3 - hint : GOT overwriting again - port : TCP 8888*/ #include // magic potion for youvoid pop_pop_ret(vo..
2017.12.01 -
[4] hell_fire -> evil_wizard ( GOT Overwriting )
GOT Overwriting을 사용하기 위해서는 pop_pop_ret 코드가 필요하다해당 서버 버전에서는 pop_pop_ret 코드가 없어서 문제의 소스코드에 직접 입력 해두고 있다 1> RTL 의 주소가 0x00 으로 시작되어 한 개 이상의 함수를 호출 할 수 없다 & 인자를 사용하면 함수를 최대 두개 호출 할 수 있다=> pop_pop_ret 를 사용하여 해결 / NULL 값을 입력할 수 없기 때문에 함수들의 PLT 주소를 이용한다 2> 호출함수 주소 변조=> strcpy 이용 [ 형식 ]char *strcpy(char *dest, const char *src);payload : ( strcpy'plt + pop_pop_ret + dst + src + strcpy'plt + pop_pop_ret + ..
2017.11.30 -
[3] dark_eyes -> hell_fire ( Fake EBP & fgets Cache memory / mprotect)
dark_eyes / because of you [ hellfire.c ]12345678910111213141516171819202122232425262728 #include int main(){ char buffer[256]; char saved_sfp[4]; char temp[1024]; printf("hell_fire : What's this smell?\n"); printf("you : "); fflush(stdout); // give me a food fgets(temp, 1024, stdin); // save sfp memcpy(saved_sfp, buffer+264, 4); // overflow!! strcpy(buffer, temp); // restore sfp memcpy(buffer+2..
2017.11.28 -
[2] iron_golem -> dark_eyes ( RET Sleding )
iron_golem / blood on the fedora [ dark_eyes.c ]1234567891011121314151617181920212223242526/* - hint : RET sleding*/ int main(int argc, char *argv[]){ char buffer[256]; char saved_sfp[4]; if(argc 다음 실행할 명령어를 EIP 레지스터에 넣고 해당 명령어의 주소로 이동하여 실행한다 [ Stack 구조 ]saved ebp 0xfeea51e8saved eip &ret&ret&ret&execl ret가 3번 수행되고 마지막에는 pop &execl , jmp &execl 에 의해서 execl()함수가 실행되어진다 [ Shellcode 작성 ]12345678910..
2017.11.28 -
[1] gate -> iron_golem ( Fake EBP )
FC3 ( Fedora Catle )FTZ나 LOB와는 다르게 여기에는 메모리 보호 기법이 적용되어 있고, 이를 우회해야합니다메모리 보호기법 종류1> DEP ( Data Excution Prevention )스택메모리에서의 실행권한을 제거하여 스택에 Shellcode를 올려서 실행시킬 수 없습니다2> 아스키 아머모든 라이브러리 주소가 0x00 으로 시작하게 됩니다 => 0x00 값으로 인해 함수를 연속적으로 호출할 수 없게 되었다(gdb) p system$4 = {} 0x007507c0 (gdb) p strcpy$5 = {} 0x00783880 3> 랜덤 메모리 ( Address Space Layout Randomization )스택 메모리의 주소들이 실행 할 때마다 랜덤하게 바뀐다Data Section..
2017.11.28 -
[20] xavius -> death_knight ( Remote BOF )
xavius / throw me away [xavius@localhost xavius]$ /bin/bash2[xavius@localhost xavius]$ export SHELL=/bin/bash2 [ death_knight.c ]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 #include #include #include #include #include #include #include #include #include main(){ char buffer[40]; int server_fd, client_fd; struct sockaddr_in se..
2017.11.25 -
[19] nightmare -> xavius
nightmare / beg for me[nightmare@localhost nightmare]$ /bin/bash2[nightmare@localhost nightmare]$ export SHELL=/bin/bash2 [ xavius.c ] 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#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 ret..
2017.11.25 -
[17] zombie_assassin -> succubus ( Calling Function Continuously )
zombie_assassin / no place to hide/bin/bash2export SHELL=/bin/bash2 [ succubus.c ]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 /* The Lord of the BOF : The Fellowship of the BOF - succubus - calling functions continuously*/ #include #include #include // the ins..
2017.11.25