background/linux

    FSB tips

    FSB tips

    pwn college에서 fsb 문제들로 배운 점들을 정리한다.(fsb는 너무 어렵다..)  64비트를 기준으로 출력되는 순서는 다음과 같다.rsi, rdx, rcx, r8, r9, [rsp], [rsp+8], [rsp+0x10], [rsp+0x18], [rsp+0x20] ...rsp+0부터 쭉쭉 가다보면 buffer 주소가 나올 것이다.웬만하면 fsb가 터지는 출력 함수가 호출되기 직전에 브포를 걸고 하는 게 좋다. (레지스터 값을 보기 위해) 다음은 메모리의 값을 읽는데 사용되는 형식 지정자들이다. (AAR)%c, %hhx: 1 byte%hx: 2bytes%d, %i, %x: 4 bytes%lx, %p: 8 bytes%s: dereference a pointer '%' 문자와 '$' 문자를 같이 사용..

    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..