background/linux

    ROP tips?

    ROP tips?

    pwn college의 rop 문제들을 풀면서 배운 점들을 적어본다.pwn college의 libc 버전인 2.31으로 봤는데 다른 버전일 땐 해당 libc 파일을 gdb로 보면 되겠다.  1. 리턴 주소가 __libc_start_main인데 leak이 전혀 안된 상태에서 main으로 리턴이 필요한 경우glibc 2.31에서 main 함수의 리턴 주소는 이다.여기서 최하위 바이트를 변조시켜 으로 변조시킨다면 다시 main으로 갈 수 있다. 0x24060 : mov QWORD PTR fs:0x300,rax 0x24069 : mov rax,QWORD PTR [rip+0x1c7e40] # 0x1ebeb0 0x24070 : mov rsi,QWORD P..

    FSOP(File Stream Oriented Programming)

    Source code (bootlin)_IO_FILE_plus & _IO_FILE_complete_plusstruct _IO_FILE_plus{ FILE file; const struct _IO_jump_t *vtable;};#ifdef _IO_USE_OLD_IO_FILE/* This structure is used by the compatibility code as if it were an _IO_FILE_plus, but has enough space to initialize the _mode argument of an _IO_FILE_complete. */struct _IO_FILE_complete_plus{ struct _IO_FILE_complete file; const stru..

    [how2heap] Tcache Poisoning (glibc 2.31/2.35)

    glibc 2.31 https://github.com/shellphish/how2heap/blob/master/glibc_2.31/tcache_poisoning.c #include #include #include #include int main() { // 버퍼링 비활성화 setbuf(stdin, NULL); setbuf(stdout, NULL); printf("이 파일은 malloc을 속여 임의의 위치(이 경우 스택)를 가리키는 포인터를 반환하도록 하는 간단한 tcache 독립성 공격을 보여줍니다.\n" "이 공격은 fastbin 손상 공격과 매우 유사합니다.\n"); printf("패치 후 https://sourceware.org/git/?p=glibc.git;a=commit;h=77dc0d8643a..

    [how2heap] House of Botcake (glibc 2.31)

    [how2heap] House of Botcake (glibc 2.31)

    https://github.com/shellphish/how2heap/blob/master/glibc_2.31/house_of_botcake.c (이 코드는 2.35에선 작동하지 않는다) #include #include #include #include int main() { /* * 이 공격은 https://sourceware.org/git/?p=glibc.git;a=commit;h=bcdaad21d4635931d1bd3b54a7894276925d081d * 에 도입된 제한을 우회해야합니다. * 만약 libc에 제한이 포함되어 있지 않다면, 단순히 victim를 두 번 해제하고 * 간단한 tcache poisoning을 수행할 수 있습니다. * 이 기술의 이상한 이름에 대해 @anton00b와 @subw..

    [how2heap] fastbin dup into stack (glibc 2.35)

    https://github.com/shellphish/how2heap/blob/master/glibc_2.35/fastbin_dup_into_stack.c #include #include #include int main() { fprintf(stderr, "이 파일은 calloc을 속이는 방법으로 fastbin_dup.c를 확장합니다.\n" "(이 경우 스택에 제어된 위치를 가리키는 포인터를 반환합니다).\n"); fprintf(stderr,"먼저 tcache를 채웁니다.\n"); void *ptrs[7]; for (int i=0; i 12) ^ ptr; /*취약점*/ fprintf(stderr, "3번째 calloc(1,8): %p, 스택 주소를 free list에 넣음\n", calloc(1,8));..