Pwnable/Dreamhack(5)
-
Dreamhack Rao -Stack Buffer Over Flow-
문제의 소스코드는 다음과 같다. #include #include void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); } void get_shell() { char *cmd = "/bin/sh"; char *args[] = {cmd, NULL}; execve(cmd, args, NULL); } int main() { char buf[0x28]; init(); printf("Input: "); scanf("%s", buf); return 0; } scanf 에서 버퍼오버플로우를 일으킬 수 있고 ret 주소를 get_shell 주소로 덮는다면 플래그를 획들 할 수 있게 만든 문제인거 같다. 바로 gef를 통해 패턴을 생성하고 offset 을 구한..
2023.03.24 -
Dreamhack -off_by_one_001-
#include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void read_str(char *ptr, int size) { int len; len = read(0, ptr, size); printf("%d", len); ptr[len] = '\0'; } void get_shell() { system("/bin/sh"); } int main() { char name[20];..
2023.03.05 -
Basic_exploitation_003
이번문제는 참 운빨로 푼 거 같다.. 문제의 소스코드는 아래와 같다. #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void get_shell() { system("/bin/sh"); } int main(int argc, char *argv[]) { char *heap_buf = (char *)malloc(0x80); char stack_buf[0x90] = {..
2023.02.26 -
basic_exploitation_001
#include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void read_flag() { system("cat /flag"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); gets(buf); return 0; } 문제의 소스코드다. 먼저 buf의 크기는 80으로 제한을 해놨지만 gets 함수를 통..
2023.02.19 -
basic_exploitation_000 -Dreamhack-
#include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); printf("buf = (%p)\n", buf); scanf("%141s", buf); return 0; } 문제의 소스코드다. 취약점을 찾을 수 있는 곳은 scanf 부분이다. buf을 0x80 크..
2023.02.19