목록전체 글 (243)
CIDY

#include #include #include #include #include char name[16]; char *command[10] = { "cat", "ls", "id", "ps", "file ./oob" }; 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 idx; initialize(); printf("Admin name: "); read(0, name, sizeof(name)); p..

// gcc -o init_fini_array init_fini_array.c -Wl,-z,norelro #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[]) { long *ptr; size_t size; initialize(); printf("stdout: %p\n", stdout); printf("Size:..

// gcc -o oneshot1 oneshot1.c -fno-stack-protector -fPIC -pie // 64-bit, pie, nx, partial relro #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(); ..

진짜 서버랑 로컬 환경다른거 너무 화난다... 조만간 꼭 도커파일로 환경구축하는거 배워야지 // Name: fho.c // Compile: gcc -o fho fho.c #include #include #include int main() { char buf[0x30]; unsigned long long *addr; unsigned long long value; setvbuf(stdin, 0, _IONBF, 0); setvbuf(stdout, 0, _IONBF, 0); puts("[1] Stack buffer overflow"); printf("Buf: "); read(0, buf, 0x100); printf("Buf: %s\n", buf); puts("[2] Arbitary-Address-Write");..
훅 오버라이트는 full relro우회 기법이다. 일단 relro는 쓰기 권한을 조정하는 보호기법인데, 안 걸려있으면 뭐 아무데나 쓸 수 있는거고, partial relro면 .init_array랑 .fini_array 못 쓰고, full relro면 거기에다 got영역까지 못 쓰게 된다. 즉 got overwrite를 할 길이 막히게 되는건데, 이를 우회하는 방법이 Hook overwrite이다. malloc, free, realloc을 통해 훅 오버라이트를 할 수 있는데...얘네 함수들은 각각 __malloc_hook. __free_hook, __realloc_hook이라는 훅 변수를 가진다. 각 함수들은 자기 훅 변수의 값이 NULL인지 검사 후 널이 아니면 malloc이나 free등 함수를 실행하..

//32-bit, nx, partial relro #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; } 흠 x64랑 너무 똑같은데? 얘도..
어제 자기전에 풀고잤던건데 로드맵에 있던거였네.. 그럼 어제랑은 다른 방법으로 풀어봐야겠다. //64-bit, nx, partial relro #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(..

간단한 문젠데 이것저것 하다보니 풀이를 3개나 써버렸다ㅋㅋ다들 비슷비슷한 인자세팅이긴 함. // Name: rop.c // Compile: gcc -o rop rop.c -fno-PIE -no-pie // 64-bit, canary, nx, partial relro #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); // Do ROP puts("[2] Input ROP payload..