IT/Wargame 6

[System Hacking] fho ㅡ Hook overwrite

Hook Overwrite란 malloc, free, realloc 함수는 각각 훅 변수가 존재하며,이 함수들은 시작할 때 해당 훅 변수가 존재하는지 검사하고, 존재하면 이를 호출한다.이때, 이 변수들은 libc의 bss 섹션에 위치하여 쓰기 가능하므로, 실행 중에 덮어쓰는 것이 가능하며,이에 성공하면, malloc/free/realloc 함수를 호출할 때 조작되어버린 훅을 호출하여, 조작된 주소로 jump하게 되므로, 실행 흐름이 조작되는 것이다.게다가, 훅을 실행할 때는 기존 malloc/free/realloc 함수에 전달한 인자를 같이 전달해 주기 때문에,   예를 들어 __malloc_hook를 system 함수의 주소로 덮고, malloc(“/bin/sh”) 을 호출하면,"/bin/sh"이 sy..

IT/Wargame 2024.05.17

[System Hacking] basic_rop_x64

스택 프레임 분석 Return address (0x8) SFP (0x8) buf [rbp-0x40] (0x40) 공격 계획 최종 목표: system("/bin/sh") 수행할 것. * system() 주소 구하기 = lib_base + system_offset ** lib_base 구하기 = read() 주소 - read_offset *** read() 주소 구하기 ROP를 통해, write(1, read@got, ...) * "/bin/sh" 주소 구하기 = lib_base + binsh_offset ** system_offset, read_offset, binsh_offset 구하기 libc를 이용 * Return address를 system("/bin/sh")로 Overwrite ROP를 이용 ex..

IT/Wargame 2024.03.19

[System Hacking] ssp_001

Description Stack Smashing Protector 기법을 우회하여 익스플로잇해 셸을 획득한 후, "flag" 파일을 읽으세요. 소스코드: ssp_001.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 id..

IT/Wargame 2024.03.07

[System Hacking] basic_exploitation_000

Description 프로그램의 취약점을 통해 셸을 획득한 후, "flag" 파일을 읽어야 한다. 공격 대상의 코드 #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]; // 128바이트 initialize(); printf("buf = (%p)\n", buf); scanf("%..

IT/Wargame 2024.03.02

[System Hacking] shell_basic: orw를 통해 flag 파일 얻기

1. mycode 어셈블리 작성하기 이 문제에서 orw를 하기 위해서는 아래와 같은 syscall이 필요하다. 1. open("/home/shell_basic/flag_name_is_loooooong", RD_ONLY, NULL) 2. read(fd, buf, 0x30) 3. write(1, buf, 0x30) 따라서 위를 수행하는 어셈블리를 아래와 같이 작성했다. "/home/shell_basic/flag_name_is_loooooong"의 hex를 stack에 push하기 xor rax, rax push rax mov rax, 0x676e6f6f6f6f6f6f push rax mov rax, 0x6c5f73695f656d61 push rax mov rax, 0x6e5f67616c662f63 push ..

IT/Wargame 2024.02.29