본문 바로가기

RTL

(3)
[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..
RTL (Return to Library) 1. NX 우회방법 NX로 인해 공격자가 버퍼에 주입한 쉘코드 실행은 어렵지만, 스택 버퍼 오버플로우 취약점으로 반환주소를 덮는 것은 여전히 가능하다. 공격자는 실행 권한이 남아있는 코드 영역으로 반환주소를 덮는 공격기법으로 NX를 우회할 수 있다. 2. 프로세스에 실행권한이 있는 메모리영역 ① 바이너리의 코드 영역 ② 바이너리가 참조하는 라이브러리의 코드 영역 3. 정의 NX를 우회하는 공격기법이다. libc 함수들로 NX를 우회하고 쉘을 획득하는 공격기법을 "Retrun To Libc"라고 한다. 다른 라이브러리로 공격에 활용될 수도 있으므로 "Return To Library"라고도 한다. 4. Return to PLT 정의 ASLR이 걸려 있어도 PIE가 적용되어 있지 않다면, PLT의 주소는 고정..