분류 전체보기
system call table & calling conventions
ROP 시 참고할 자료로 system call number와 인자 참조 순서. Chromium OS Docs - Linux System Call Table (googlesource.com) Chromium OS Docs - Linux System Call Table Linux System Call Table These are the system call numbers (NR) and their corresponding symbolic names. These vary significantly across architectures/ABIs, both in mappings and in actual name. This is a quick reference for people debugging things (e...
bss 영역 찾기
bss 영역을 찾는 이유는 고정된 위치에 데이터를 넣을 필요가 있을때 bss영역을 사용한다. 여러 이유로, 특히 특정 주소의 위치를 찾기 힘들때 코드 영역과 맞닿아있는 고정된 주소를 가지는 bss 영역을 사용하는게 좋다. bss 영역을 찾는 방법은 아래와 같다. ┌──(kali㉿kali)-[~/Downloads] └─$ objdump -h ./validator_dist ./validator_dist: file format elf64-x86-64 Sections: Idx Name Size VMA LMA File off Algn 0 .interp 0000001c 0000000000400238 0000000000400238 00000238 2**0 CONTENTS, ALLOC, LOAD, READONLY, D..
validator
드디어 마지막 문제! 오랜만에 코드 없는 문제를 본다. 문제 파일을 다운로드 및 압축을 해제하면 두개의 파일이 나온다. 사실 코드가 없기에 ida와 같이 디스어셈블러 프로그램 사용법을 먼저 익힌 후 푸는 것이 맞는 것 같다. 사실 디스어셈블러 프로그램은 코드를 해석하기 편하게 만들어놓은 것이라 어셈블리어를 알고 있다면 굳이 사용할 필요는 없다. 개인적으로 어셈블리어 실력이 그렇게 좋지 않기 때문에, 핸드레이까지는 어렵고, 어느정도 해석만 가능한 수준이라 시간이 너무 오래 걸려 ida를 쓰기로 했다. 우선 varidator_dist 파일의 보안 기법을 확인. ┌──(kali㉿kali)-[~/Downloads] └─$ checksec validator_dist [*] '/home/kali/Downloads/..
cmd_center
앞선 문제도 그렇고, 조금 쉬어가는 코너 같은 느낌이다. (사실, 문제 파일이 있다는 것을 망각하고 무작정 서버에 접속해서 아무 명령어나 넣어보고 있었음... 근데 아무런 반응이 없어서 이런식으로 문제 만들면 어떻게 풀라고 하는거지라는 생각을 하며...) 우선 코드를 보자. #include #include #include #include void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); } int main() { char cmd_ip[256] = "ifconfig"; int dummy; char center_name[24]; init(); printf("Center name: "); read(0, center_name, 100); if( ..
sint
#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() { char buf[256]; int size; initialize(); signal(SIGSEGV, get_shell); printf("Size: "); scanf("%d", &size); if (size > 256 || s..
tcache_dup2
문제 파일 압축을 풀어보면 이번에는 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..
patchelf 사용법.
딱 두개 명령어만 기억하자 ┌──(kali㉿kali)-[~/Downloads] └─$ patchelf --set-interpreter ./ld-50390b2ae8aaa73c47745040f54e602f.so.2 tcache_dup ┌──(kali㉿kali)-[~/Downloads] └─$ ldd tcache_dup linux-vdso.so.1 (0x00007ffcde7ea000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f60a2022000) ./ld-50390b2ae8aaa73c47745040f54e602f.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f60a2211000) ┌──(kali㉿kali)-[~/Downl..
tcache_dup
// 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]) {..
함수의 offset은 왜 strings로 찾아지지 않는가?
공부 초기에 offset을 찾는 방법이 너무 헷갈렸다. 왜 /bin/sh 문자열의 offset은 strings -tx filename | grep /bin/sh 로 찾아지고 system 함수는 strings -tx filename | grep system 으로 찾아지긴 하지만 실제 offset과 왜 다른가? 요약하자면 그 이유는 "함수명"은 함수 초기에 무조건 나오는 것이 아니기 때문이다. strings 명령어는 말 그대로 파일 내에 string을 찾아 출력해준다. 그 말인 즉슨, 파일 내에는 hex 값으로된 수 많은 데이터들이 있다. 이 값들 중 string으로 저장된 값들만 출력해주는 역할을 한다. 예를 들어보자. /bin/sh는 파일 내에 문자열로 들어있을 것 같지만 실제로는 ascii code에 ..