보안 74

[RELRO] RELRO의 개념, RELRO의 우회

RELRO란ELF는 data segment에 있는 GOT를 활용하여 반복되는 라이브러리 함수의 호출 비용을 줄이며,이 GOT에 값을 채우는 방식 중 Lazy Binding은   함수가 처음 호출될 때 함수의 주소를 구하고, 이를 GOT에 적는 방식이다.그런데 이 방식의 바이너리는 실행 중에 GOT 테이블을 업데이트할 수 있어야 하기에, GOT에 쓰기 권한이 부여가 되므로 취약하다.한편, ELF의 data segment에는 프로세스의 초기화 및 종료에 실행할 함수들의 주소가 저장된 .init_array, .fini_array가 있는데,여기가 조작이 가능하다면 이또한 취약하다.이러한 문제들을 해결하고자,데이터 세그먼트 중, 쓰기 권한이 불필요한 영역의 쓰기 권한을 제거함으로써, 해당 영역을 보호하는 RELR..

[PIE] PIC와 PIE의 개념, 상대 참조, PIE의 우회

PIC와 PIE의 개념 PIC(Position-Independent Code): 재배치(Relocation)가 가능하여, 메모리의 어느 주소에 적재(매핑)되어도 코드의 의미가 훼손되지 않고 제대로 실행될 수 있는 코드  - rip를 기준으로 데이터를 상대 참조(Relative Addressing)하기 때문  PIE(Position-Independent Executable): 메모리의 어느 주소에 적재(매핑)되어도 실행 가능한 실행 파일   - PIE의 모든 코드는 PIC이다.- ASLR이 적용되면, 바이너리가 실행될 때마다 스택, 힙, 공유 라이브러리 뿐만 아니라 코드 영역까지도 무작위 주소에 적재됨 (↔ PIE가 아니면, 코드 영역은 랜덤이 아님)- 다만 ASLR이 안 적용되면, 무작위 주소에 적재되지..

[DirtyCOW] memory mapping, mmap(), Copy on Write

memory mapping memory mapping이 뭔가요? 일반적으로 file에 access(open, read, write, ...)하는 방식은 두 가지가 있다. 1) by I/O Operation파일에 접근할 때마다 매번 system call을 통해 kernel을 깨워야 함-> overhead가 발생해버린다. 2) by memory mapping처음에 파일의 내용을 프로세스의 메모리에 한번 mapping해 두면,이후에 파일 내용에 접근할 때는, system call이 아니라, 메모리 주소를 통해 직접 접근  -> overhead 최소화! memory mapping by mmap() system callvoid *mmap(void addr[.length],  시작 주소: 어디에다가부터 mappin..

[논문] Machine learning을 이용한 Windows malware classification

💡A Survey of Machine Learning Methods and Challenges for Windows Malware ClassificationMachine learning을 이용해 malware를 multi-classification하는 경우, 일반적으로 아래와 같은 것들이 feature로서 선택된다.   또한 분석 method은 아래와 같다. ▶ N-gram ▶ Linear model ▶ Kernel method ▶ Decision tree ▶ Neural network ▶ sequences에 대한 method:      hidden markov model      byte similiarty measure      CNN, RNN      Haar Wavelet Transform 💡..

[Security란] Security vs Protection, Authentication vs Authorization

✅Security: keeping unauthorized entities from doing things you don’t want them to do: protecting systems from deliberate attacks - Confidentiality, Integrity, Availability  OS의 역할privileged mode, memory protection, file access permissions, ... ✅Protection: protecting files and other resources from accidental misuse ✅Authentication: proving that someone is who they say they are ✅Authorization: Ve..

[Heap overflow] Heap overflow의 과정, Exploit, Countermeasures

💡Heap overflow의 과정 ✅예시 프로그램 코드   ✅after strcpy(c, ...)   ✅after free(b)chunk B에 fd, bk 포인터가 생기며,이것이 bin_forward, bin_back과 연결됨으로써, free된 chunk B는 bin에 들어간다.  ✅after strcpy(a, ...) chunk A에, 이것의 크기에 비해 과분한 양의 string이 들어간다.🚩따라서 string은 chunk A의 data 공간을 다 채우고 나서 higher address 방향으로 흘러넘쳐 chunk B를 corrupt시킨다.  ✅after free(a) chunk A도 free되어 fd, bk 포인터가 생겼고,이 포인터들이 기존의 bin (free chunk list)과 연결됨으로써..

[Format String Bug] with Variable length arguments

💡Format String Bug (FSB)란?위와 같이,format functions에서,format string 내의 format specifier의 개수 != format string을 제외한 argument의 개수인 경우,짝이 없는 format specifier는 메모리 내의 임의의 데이터를 출력해낸다.즉 memory disclosure 취약점이 발생하는 것이다.   ※ format function의 종류 ※ format specifier란? ※ format string란?format specifier가 포함된 string  💡배경 지식: Variable length arguments를 이용하는 함수는 어떻게 구현돼있을까? ✅Variable length arguments를 이용하는 함수의 아주..