드림핵/시스템해킹2 드림핵 RTL 풀이 (노.복) RTL (Return to Library)// Name: rtl.c// Compile: gcc -o rtl rtl.c -fno-PIE -no-pie#include #include #include const char* binsh = "/bin/sh"; // 코드 영역에 /bin/sh를 코드 섹션에 추가하기 위함 // ASLR 이 적용돼도 PIE가 적용되지 않으면 코드 세그먼트와 데이터 세그먼트의 주소는 고정되므로 // "/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.. 2024. 9. 8. 드림핵 Return to Shell 풀이 취약점 확인// Name: r2s.c// Compile: gcc -o r2s r2s.c -zexecstack#include #include void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0);}int main() { char buf[0x50]; init(); printf("Address of the buf: %p\\n", buf); printf("Distance between buf and $rbp: %ld\\n", (char*)__builtin_frame_address(0) - buf); printf("[1] Leak the canary\\n"); printf("Input: "); fflush(stdout); .. 2024. 9. 3. 이전 1 다음