본문 바로가기

system

2019 hack.lu chat hack.lu 2019 chatubuntu@ubuntu:~/pwn/hack.lu/chat$ ./chat Command Channel: > /h Command Commands: /nc - New Chat Channel - Create and join a new Chat Channel. /jc x - Join Chat Channel - Join the Chat Channel number x. /lc - List Chat Channels - Lists the Chat Channels. /q - Quit - Quit this awesome chat program. /h - Help - Print this help message. > /nc Chat Channel 1: > /h Chat Commands: /e -.. 더보기
peda special instruction 보호되어 있는 글입니다. 더보기
linux kernel module 작성해보기 linux kernel module 작성해보기맥커널을 공부하기에 앞서 겸사겸사 리눅스 커널부터 공부를 시작한다.Linux ubuntu 4.15.0-66-generic #75~16.04.1-Ubuntu SMP Tue Oct 1 14:01:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux 환경에서 테스트를 진행하였다.모든 것의 시작은 hello_world이다라고 생각하니 이러한 기능을 하는 모듈을 하나 만들어보도록 하자! #include #include #include static int __init hello_init(void) { printk("hello_init() hello world!\n"); return 0; } static void __exit hello_exit(vo.. 더보기
return-to-dynamic-linker return-to-dl-resolve return-to-dynamic-linkerx86Elf32_Rel (8 byte)typedef uint32_t Elf32_Addr;typedef uint32_t Elf32_Word;typedef struct{ Elf32_Addr r_offset; /* Address */ Elf32_Word r_info; /* Relocation type and symbol index */} Elf32_Rel;Elf32_Sym (16 byte)xxxxxxxxxxtypedef struct{ Elf32_Word st_name; /* Symbol name (string tbl index) */ Elf32_Addr st_value; /* Symbol value */ Elf32_Word st_.. 더보기
2019 hitcon lazyhouse lazyhouse hitcon 2019 lazyhouse정말.. 어려운 문제였다일단 전체적으로 흘러가는 흐름은 다음과 같다. mmap 셋팅 후 calloc으로 heap, libc leakunsafe unlink로 overlapping chunkhouse of lore로 tcache_pertheread_struct 공격__malloc_hook에 leave;retorw 이용해서 print flag (mprotect 이용해서 shellcode도 가능) 근데, 이 위 과정이 진짜 미쳤다..일단 이 exploit은 balsn의 writeup을 설명해 놓은 https://syedfarazabrar.com/2019-10-24-hitconctf-lazyhouse-balsn-exploit-analysis/ 이 블로그를 .. 더보기
unsortedbinbin_attck died.. unsortedbin_attack unsortedbin_attack died아직 모르고 있었는데 glibc > 2.28부터는 unsortedbin의 binning code checks가 생겼다.. 이것 때문에 정말 삽질을 많이해서 안까먹게 블로그에 올린다. --- a/malloc/malloc.c+++ b/malloc/malloc.c@@ -3716,11 +3716,22 @@ _int_malloc (mstate av, size_t bytes) while ((victim = unsorted_chunks (av)->bk) != unsorted_chunks (av)) { bck = victim->bk;- if (__builtin_expect (chunksize_nomask (victim) av->system_me.. 더보기
2019 hitcon trick_or_treat trick_or_treat hitcon 2019 trick_or_treat굉장히 간단한 프로그램이다. 맨 처음에 입력받은 Size로 malloc을 해주고, 2번의 arbitrary write를 제공해준다. 여기서, chunk의 주소를 출력해주니 mmap으로 chunk를 할당받아서 libc를 leak할 수 있다. 그 후, __free_hook을 system으로 덮고, system("ed")를 실행시켜주면 된다. scanf에 큰 입력을 주면 malloc 후 입력을 chunk에 담고 free시키는데, 예를 들어 "A"를 0x500개, ed를 넣으면 chunk는 다음과 같은 형태를 갖는다. free 코드는 vfscanf의 errout LABEL이다. errout: /* Unlock stream. */ UNLOC.. 더보기
2019 codegate maris_shop maris_shop codegate 2019 maris_shop파일포인터에 익숙해질겸 다시 풀어본 문제다. 메뉴로 구성되어있는 heap 문제로 보인다. add를 하면 item과 amount를 입력받고 우리의 chunk를 하나 만들어주는데 다음과 같은 형태이다. xxxxxxxxxx00000000 struc_1 struc ; (sizeof=0x20, mappedto_6)00000000 item_price dq ?00000008 item_amount dq ?00000010 item_name dq 4 dup(?)00000030 struc_1 ends(item_name이 아무리 길어도 4바이트를 안넘으므로 그냥 이렇게 정의했다. 실제론 0x80바이트) 일단 add에서 cart_chunk를 17번째 인덱스까지 입력.. 더보기