security

Total 112
Today 0
profile_image
운영자
01-02-06 09:28 0개 2,468회
Heap based Overflow --(5 )
Heap based overflow







이번 주는 Heap based overflow 강의 마지막 주입니다.





contents



0. Heap and Data/BSS section



1. Why Heap/BSS Overflows are Significant?



2. Exploiting Heap/BSS Overflows (source code)

2.1 Prelude of heap based overflow

2.2 Getting close

2.3 The First Chase

2.4 Playing with function pointers

2.5 Longjmp



3. The Preys

4. Possible Fix



--------------------------------------------------------------------------------



3 . The Preys



이제까지는 control된 상황에서의 overflow였다. heap에 sensetive한 정보를 담고 있어서 overflow가 가능한 함수들은 다음과 같다.



functions reason



1. *gets()/*printf(), *scanf() __iob (FILE) structure in heap



2. popen() __iob (FILE) structure in heap



3. *dir() (readdir, seekdir, ...) DIR entries (dir/heap buffers)



4. atexit() static/global function pointers



5. strdup() allocates dynamic data in the heap



7. getenv() stored data on heap



8. tmpnam() stored data on heap



9. malloc() chain pointers



10. rpc callback functions function pointers



11. windows callback functions / func pointers kept on heap



12. signal handler pointers function pointers (note: unix tracks in cygnus (gcc for win), these in the kernel, not in the heap)





이제 위 함수들의 용도를 알 수 있을 것이다.



printf()'s, fgets()'s, readdir()'s, seekdir()'s, etc. 의 FILE structure를 위한 공간역시 교묘하게(^^) 조작되어질 수 있다.



atexit()는 program이 종료될 때 호출되는 function pointer를 가지고 있다.



strdup() 은 heap에 string(filename, password)등을 저장한다.



malloc()의 chain pointers는 프로그래머가 의도하지 않은 메모리 영역을 조작할 수 있다.



getenv()는 heap에 data를 저장하며, $HOME 등을 조작할 수 있도록 해준다.



svc/rpc registration fuction들은(librpc, libnsl, etc..) 는 heap에 대기중인 함수들을 저장한다.







--------------------------------------------------------------------------------



4. The Possible Fix ?





최선의 해결책은 결점이 없이 coding을 하는 것이다. stack-based overflow와 같이 heap-based overflow를 막는 방법은 없다.



일단 다음의 compiler를 사용하는 것도 한 대책이 될 수 있으나, 약간 복잡한 프로그램일 경우 이 compiler를 사용해서 compile할 수는 없다.



the bound checking gcc/egcs .. http://www.annexia.demon.co.uk/



이 컴파일러는 다음과 같이 실수에 의한 overrun을 check해준다.



int array[10]; for (i=0; i<=10; i++) array[i] =1







Stack같이 다음 두가지 방법을 조합하게 되면 대부분의 공격을 막아낼 수 있으나, 지금 현재 구현이 되어있지는 않다.



non-excutable heap patch - like non-excutable stack patch by Solar Designer



HeapGuard - like StackGuard by Cowan

댓글목록

등록된 댓글이 없습니다.