분류 전체보기

    pwntools - elf, symbol을 가져올때

    symbol을 가져오기 위해서는 프로그램 내에서 적어도 한번은 사용되는 함수여야 한다. 이외의 값은 libc offset을 통해 주소를 찾아내서 사용해야한다.

    8월의 초입에 쓰는 7월의 일기.

    자체 평가 : ★★☆☆☆ 티스토리를 개설한지도 한 달째. 자체 평가를 해보자면 별 다섯 개 중 두 개다. 가장 큰 이유는 7월에 세운 올해의 목표 중 달성한 것이 하나도 없음 ㅋㅋㅋㅋㅋㅋ 다시 보는 올해의 목표. 지금까지 푼 문제들 write up. 쓴다고 썼는데 다시 읽어보니 무슨 말인지 이해가 안 된다... 기본만 안다면 누가 봐도 이해할 수 있도록 정리하자. 문제를 풀며 배운 이론들 재 정리. 마찬가지. 누가 봐도 이해할 수 있도록 정리하자. 그냥 문제를 풀기 위한 방법 정도로 보지 말고 다시 한번 이해하고 넘어가자. Root-Me App-system ELF x86 clear 가능하다면 이외 문제들도 풀어보기. 물론 dream hack이라는 새로운 도전(이라 쓰고 옆길로 빠졌다고 읽는다.)을 하고 ..

    Tcache Poisoning

    // Name: tcache_poison.c // Compile: gcc -o tcache_poison tcache_poison.c -no-pie -Wl,-z,relro,-z,now #include #include #include int main() { void *chunk = NULL; unsigned int size; int idx; setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); while (1) { printf("1. Allocate\n"); printf("2. Free\n"); printf("3. Print\n"); printf("4. Edit\n"); scanf("%d", &idx); switch (idx) { case 1: printf("Size: ..

    heap tcache poisoning & double free

    tcache libc > 2.25 이후부터 적용된 heap 관리 방법이며, 2.29부터는 패치 되었다. 사실 아래 내용 다 필요 없이 같은 공간에 free가 두번 들어가며, free 시 앞에 사용한 heap 영역의 주소를 가져오기 때문에 tcache 영역에 임의의 주소를 덮어씌울 수 있다. 우선 두번의 32 byte heap 영역 할당을 통해 아래와 같이 데이터가 들어있다고 가정하자. gef➤ heap chunks Chunk(addr=0x602010, size=0x290, flags=PREV_INUSE) [0x0000000000602010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................] Chunk(addr=0x6022a0, size=0..

    보호 기법 및 공격 시나리오 요약

    Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled ASLR 개념 흔히들 말하는 random stack. 즉, heap, stack 영역의 base address를 랜덤하게 바꾸는 방법. 공격 방법 최선은 memory leak이며, 특정 memory address를 알 수 있다면 각 변수나 함수의 address는 offset 만큼 떨어진 곳에 위치하기에 이를 통해 exploit이 가능해진다. brute force, 즉 될때까지 시도해보는 방법. 32bit던 64bit던 특정 함수나 변수의 위치가 어느정도 고정되어있기에 이를 기반으로 지속적으로 시도해보는 방법이며, nop sled와 함께 성공률..

    heap tcache & main_arena

    tcache(thread local cache) heap 관리를 빠르게 하기 위해 glibc 2.26 이상부터 적용되는 기술. fast bin과 유사하지만 다른 성격을 가짐. tcache는 heap 영역에 존재함. 32 bit 에서는 516 byte 이하의 사이즈, 64 bit 에서는 1032 byte 이하의 사이즈가 할당되었을때 tcache를 사용함. 예제로 256 byte로 4개를 할당하고 첫번째 영역을 free 해서 fd, bk 값을 보면 다시 heap 영역을 가르키고 있으며, gef➤ x/40gx 0x555555603000 0x555555603000: 0x0000000000000000 0x0000000000000291 0x555555603010: 0x0000000000000000 0x0000000..

    uaf_overwrite

    // Name: uaf_overwrite.c // Compile: gcc -o uaf_overwrite uaf_overwrite.c #include #include #include #include struct Human { char name[16]; int weight; long age; }; struct Robot { char name[16]; int weight; void (*fptr)(); }; struct Human *human; struct Robot *robot; char *custom[10]; int c_idx; void print_name() { printf("Name: %s\n", robot->name); } void menu() { printf("1. Human\n"); printf("..

    [dreamhack] basic_exploitation_003

    왜 4 byte의 더미가 필요한가? 왜 값이 순서대로 들어가지 않는가? https://wyv3rn.tistory.com/70 basic_exploitation_003 #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.. wyv3rn.tistory.com 2022-08-20 clear. 한동안 생각하지 못하고 있다가 다시 생각해서 해결함. 요약하면 %hhn != %1$hhn 이다. https://wyv3rn..

    basic_exploitation_003

    #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"); } int main(int argc, char *argv[]) { char *heap_buf = (char *)malloc(0x80); char stack_buf[0x90] = {}; initialize(); read(0, heap_buf, 0x80..

    basic_exploitation_002

    #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"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); read(0, buf, 0x80); printf(buf); exit(0); } 32 bit format string bug 문제이..