본문 바로가기

[Exploit-Exercises | protostar] Stack 4 :: RET 조작을 통한 Standard Buffer Overflow Stack 4의 소스코드는 다음과 같습니다. 12345678910111213141516#include #include #include #include void win(){ printf("code flow successfully changed\n");} int main(int argc, char **argv){ char buffer[64]; gets(buffer);}Colored by Color Scriptercs buffer 변수만이 선언되어 있고, 입력 크기를 지정하지 않는 gets() 함수의 취약점으로 인해 BOF가 발생합니다. win() 함수를 호출하면 문제가 풀리게 되는데, Stack 3과 같이 Function Pointer도 없고 함수를 호출할 코드가 존재하지 않습니다. 따라서 함수의 리턴 주소.. 더보기
[Exploit-Exercises | protostar] Stack 3 :: Fucntion Pointer를 이용한 Buffer Overflow Stack 3의 소스코드는 다음과 같습니다. 123456789101112131415161718192021222324#include #include #include #include void win(){ printf("code flow successfully changed\n");} int main(int argc, char **argv){ volatile int (*fp)(); char buffer[64]; fp = 0; gets(buffer); // Vurnerability!!! if(fp) { printf("calling function pointer, jumping to 0x%08x\n", fp); fp(); }}Colored by Color Scriptercs fp라는 function pointer.. 더보기
[Exploit-Exercises | protostar] Stack 2 :: 환경변수를 이용한 Buffer Overflow Stack 2의 소스코드는 다음과 같습니다. 12345678910111213141516171819202122232425262728#include #include #include #include int main(int argc, char **argv){ volatile int modified; char buffer[64]; char *variable; variable = getenv("GREENIE"); if(variable == NULL) { errx(1, "please set the GREENIE environment variable\n"); } modified = 0; strcpy(buffer, variable); // Vulnerability!!! if(modified == 0x0d0a0d0a) {.. 더보기