Pwnable/프로토스타_시스템해킹(7)
-
Protostar -stack7- ROP 공격기법
stack7 의 소스코드는 다음과 같다. #include #include #include #include char *getpath() { char buffer[64]; unsigned int ret; printf("input path please: "); fflush(stdout); gets(buffer); ret = __builtin_return_address(0); if((ret & 0xb0000000) == 0xb0000000) { printf("bzzzt (%p)\n", ret); _exit(1); } printf("got path %s\n", buffer); return strdup(buffer); } int main(int argc, char **argv) { getpath(); } 해당 문제..
2023.03.05 -
Protostar -stack 4 -
#include #include #include #include void win() { printf("code flow successfully changed\n"); } int main(int argc, char **argv) { char buffer[64]; gets(buffer); } 버퍼를 64 바이트로 받아온다. 문제는 gets 함수를 통해 받아오기에 취약점이 발견된다. 이를 통해 RTL 방식의 공격기법으로 ret 값을 win 함수주소로 변경하여 해당 문자열을 출력하게 만들면 될 것이다. 먼저 Buffer 와 Ret 간의 거리를 계산하기 위해 Pattern을 생성하고 Ret에 중단점을 걸어 거리를 구할 수 있을 것이다. Main + 22 에 중단점을 걸어 ret 함수에서 진입하기전 까지 길이를 구..
2023.02.13 -
Protostar stack-3 |실행 흐름 변조|
문제의 소스코드는 다음과 같다. #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); if(fp) { printf("calling function pointer, jumping to 0x%08x\n", fp); fp(); } } buffer을 get 방식으로 받아오고 if 문을 통해 fp 값이 0이 아닐때 문자열을 출력하고 win 값이 어쩌고 저쩌고 되면 성공 문자열을 출력시키는 거 같다. 먼저 buffer 값이 64바이트..
2023.02.03 -
Protostar stack-2
먼저 문제 소스코드는 다음과 같다. #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); if(modified == 0x0d0a0d0a) { printf("you have correctly modified the variable\n"); } else { printf(..
2023.02.01 -
Protostar-Stack1 (Buffer Over flow)
먼저 문제의 소스코드는 다음과 같다. #include #include #include #include int main(int argc, char **argv) { volatile int modified; char buffer[64]; if(argc == 1) { errx(1, "please specify an argument\n"); } modified = 0; strcpy(buffer, argv[1]); if(modified == 0x61626364) { printf("you have correctly got the variable to the right value\n"); } else { printf("Try again, you got 0x%08x\n", modified); } } 먼저 컴파일 시켜 ..
2023.01.23 -
Protostar-Stack0 (Buffer Over Flow 공격)
먼저 gdb를 통해 stack0 을 메인함수까지 디스어셈블을 해보았다. 다음과 같은 프로그램의 C 소스코드는 다음과 같다. #include #include #include int main(int argc, char **argv) { volatile int modified; char buffer[64]; modified = 0; gets(buffer); if(modified != 0) { printf("you have changed the 'modified' variable\n"); } else { printf("Try again?\n"); } } 위에 코드를 해석해보자면 64바이트의 크기로 변수 buffer을 선언하고 4바이트 크기의 modified 변수 또한 선언한다. if문을 통해 modified 변..
2023.01.21