linked_list
·
Wargame/Dreamhack
보호되어 있는 글입니다.
House of force
·
Tips & theory
1. 서론 그 유명한 house of series다. libc 2.27 이하에서만 사용 가능하기에 사실 지금에 와서는 쓸 수 없는 기법임에도 불구하고 아직까지 많은 사랑을 받고 있는 듯. 원문은 아래 링크를 참조. https://dl.packetstormsecurity.net/papers/attack/MallocMaleficarum.txt 2. 원리 기본적으로 아래가 가능해야 이 기법을 사용할 수 있다. libc version이 2.27 이하일 것. top chunk size field를 수정할 수 있는 상황. (by overflow or etc) heap allocation size를 마음대로 설정할 수 있는 상황. (가능한 음수값, 물론 양수도 가능.) 공격 구조는 top chunk의 size를 최대..
house_of_force
·
Wargame/Dreamhack
보호되어 있는 글입니다.
tcache_dup2
·
Wargame/Dreamhack
문제 파일 압축을 풀어보면 이번에는 libc 버전이 2.30이다. 아래 링크에서 설명한 것과 같이 2.29 버전부터는 패치되어 다른 방법을 사용해야한다. https://wyv3rn.tistory.com/75 heap tcache poisoning & double free tcache libc > 2.25 이후부터 적용된 heap 관리 방법이며, 2.29부터는 패치 되었다. 사실 아래 내용 다 필요 없이 같은 공간에 free가 두번 들어가며, free 시 앞에 사용한 heap 영역의 주소를 가져오기 때문 wyv3rn.tistory.com 더불어 libc에 맞는 ld 파일을 찾아야하므로 아래 사이트에서 찾아보자. http://old-releases.ubuntu.com/ubuntu/pool/main/g/gli..
tcache_dup
·
Wargame/Dreamhack
// gcc -o tcache_dup tcache_dup.c -no-pie #include #include #include #include char *ptr[10]; void alarm_handler() { exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(60); } int create(int cnt) { int size; if(cnt > 10) { return -1; } printf("Size: "); scanf("%d", &size); ptr[cnt] = malloc(size); if(!ptr[cnt]) {..
heap tcache poisoning & double free
·
Tips & theory
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..
uaf_overwrite
·
Wargame/Dreamhack
// 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("..
[App-System] ELF x64 - Double free
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include struct Zombie { int hp; void (*hurt)(); void (*eatBody)(); void (*attack)(); int living; }; struct Human { int hp; void (*fire)(int); void (*prayChuckToGiveAMiracle)(); void (*suicide)(); int living; }; struct Zombie *zombies[3]; struct Human *human = NULL; void fire(int zombieIndex) { struct Zombie *zombie = zombies[zombieIndex..
[App-System] ELF x86 - Use After Free - basic
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include #define BUFLEN 64 struct Dog { char name[12]; void (*bark)(); void (*bringBackTheFlag)(); void (*death)(struct Dog*); }; struct DogHouse{ char address[16]; char name[8]; }; int eraseNl(char* line){ for(;*line != '\n'; line++); *line = 0; return 0; } void bark(){ int i; for(i = 3; i > 0; i--){ puts("UAF!!!"); sleep(1); } } void b..