본문 바로가기

Dreamhack

(22)
[Wargame] basic_rop_x64 1. 실습 코드 #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[0x40] = {}; initialize(); read(0, buf, 0x400); write(1, buf, sizeof(buf)); return 0; } 2. 풀이 ① checksec을 이용하여, 메모리 보호기법을 확인한..
[Wargame] rop 해당 문제는 강의에 기반한 문제로, 자세한 풀이는 아래 주소를 참고하세요. 2022.07.02 - [Dreamhack/Lecture & Practice] - [Practice] ROP - GOT Overwrite 1. 실습 코드 // Name: rop.c // Compile: gcc -o rop rop.c -fno-PIE -no-pie #include #include int main() { char buf[0x30]; setvbuf(stdin, 0, _IONBF, 0); setvbuf(stdout, 0, _IONBF, 0); // Leak canary puts("[1] Leak Canary"); printf("Buf: "); read(0, buf, 0x100); printf("Buf: %s\n", buf..
[Practice] ROP - GOT Overwrite Ⅰ. ROP(Return Oriented Programming) 정의 리턴 가젯을 사용하여, 복잡한 실행 흐름을 구현하는 기법이다. 공격자는 이를 이용하여, 문제 상황에 맞춰 return to library, return to dl-resolve, GOT overwrite 등의 페이로드를 구성할 수 있다. ROP 페이로드는 리턴 가젯으로 구성되는데, RET단위로 여러 코드가 연쇄적으로 실행되는 모습에서 "ROP Chain"이라고도 부른다. Ⅱ. 실습 1. 실습 코드 // Name: rop.c // Compile: gcc -o rop rop.c -fno-PIE -no-pie #include #include int main() { char buf[0x30]; setvbuf(stdin, 0, _IONBF, 0..
[Wargame] Return to Library 해당 문제는 강의에 기반한 문제로, 자세한 풀이는 아래 주소를 참고하세요. 2022.07.01 - [Dreamhack/Lecture & Practice] - [Practice] Return to Library 1. 실습 코드 // Name: rtl.c // Compile: gcc -o rtl rtl.c -fno-PIE -no-pie #include #include const char* binsh = "/bin/sh"; int main() { char buf[0x30]; setvbuf(stdin, 0, _IONBF, 0); setvbuf(stdout, 0, _IONBF, 0); // Add system function to plt's entry system("echo 'system@plt"); // Lea..
[Practice] Return to Library 1. 실습 코드 // Name: rtl.c // Compile: gcc -o rtl rtl.c -fno-PIE -no-pie #include #include const char* binsh = "/bin/sh"; int main() { char buf[0x30]; setvbuf(stdin, 0, _IONBF, 0); setvbuf(stdout, 0, _IONBF, 0); // Add system function to plt's entry system("echo 'system@plt'"); // Leak canary printf("[1] Leak Canary\n"); printf("Buf: "); read(0, buf, 0x100); printf("Buf: %s\n", buf); // Overwrite r..
[Wargame] ssp_001 1. 문제 C 코드와 실행파일이 주어진다. #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"); } void print_box(unsigned char *box, int idx) { printf("Element of index %d is : %02x\n", idx, box[idx]); } void me..