본문 바로가기

Gadget

(3)
[Wargame] oneshot 1. 실습 코드 // gcc -o oneshot1 oneshot1.c -fno-stack-protector -fPIC -pie #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(60); } int main(int argc, char *argv[]) { char msg[16]; size_t check = 0; initialize(); printf("stdout: %p\n", st..
RTC (Return To CSU) 1. 정의 _ _libc_csu_init() 함수의 일부 코드를 Gadget으로 사용하는 기법이다. gadget이 모자라거나 없는 경우, RTC기법을 사용한다. 2. _ _libc_csu_init() 함수 정의 프로그램 실행 시, _init() 함수와 _ _preint_array, _ _init_array에 설정된 포인터를 읽어서 함수를 호출한다. 3. _ _libc_csu_init에 존재하는 Gadget _ _libc_csu_init()에서 가젯으로 사용하는 부분이다. ① Gadget 1 RBX, RBP, R12, R13, R14, R15 레지스터에 값을 저장할 수 있다. ② Gadget 2 Gadget 1에서 저장한 레지스터를 이용해서 함수의 인자값으로 전달한다. R13, R14, R15 레지스터에 ..
[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..