memory corruption
play

Memory Corruption The (almost) Complete History... haroon meer - - PowerPoint PPT Presentation

Memory Corruption The (almost) Complete History... haroon meer - 2010 @haroonmeer | haroon@thinkst.com Who ? haroon meer thinkst ? some papers, some books, some talks academic wannabe Why? Why? Why? Why? Why? twitter made me do it!


  1. Memory Corruption The (almost) Complete History... haroon meer - 2010 @haroonmeer | haroon@thinkst.com

  2. Who ? haroon meer thinkst ? some papers, some books, some talks academic wannabe

  3. Why?

  4. Why?

  5. Why?

  6. Why?

  7. Why? twitter made me do it!

  8. Why? de-mystify some of the otherwise mystical convince you that Solar Designer was skynet

  9. Why? (Some silly Stats) '!" &!" &#" %#" &!" %!" %#" %!" $#" $#" $!" $!" #" #" !" !" $(((" %!!!" %!!$" %!!%" %!!&" %!!'" %!!#" %!!)" %!!*" %!!+" %!!(" $'''" %!!!" %!!$" %!!%" %!!&" %!!(" %!!#" %!!)" %!!*" %!!+" %!!'" Stack : 140 Heap : 74

  10. Why? (Some silly Stats) '!" &!" &#" %#" &!" %!" %#" %!" $#" $#" $!" $!" #" #" !" !" $(((" %!!!" %!!$" %!!%" %!!&" %!!'" %!!#" %!!)" %!!*" %!!+" %!!(" $'''" %!!!" %!!$" %!!%" %!!&" %!!(" %!!#" %!!)" %!!*" %!!+" %!!'" Stack : 140 Heap : 74

  11. Caveats - Limits

  12. Caveats - Limits

  13. Caveats - Myopia

  14. Caveats - Myopia

  15. Caveats -Compression Ratio 332880 : 1

  16. Disclosure, Bugs and Counts VS.

  17. Disclosed Bugs

  18. Our Approach Clearly naive initially

  19. http://ilm.thinkst.com/folklore/

  20. http://ilm.thinkst.com/folklore/

  21. http://ilm.thinkst.com/folklore/

  22. the paper (read it)

  23. So at the end of this.. You wont be able to suddenly use free() to obtain a 4-byte write anything anywhere primitive. You will understand what that means. You will be able to see: When that was first used; What prevents it’s use/abuse today;

  24. Where did it start?

  25. Memory Basics

  26. Memory Basics

  27. Memory Basics { 0x00000000 User PageTable 4 gig Kernel

  28. Memory Basics { 0x00000000 User PageTable 4 gig Kernel

  29. Multiple Processes { 0x00000000 0x00000000 0x00000000 3 gig User User User Kernel Kernel Kernel

  30. Multiple Processes { 0x00000000 0x00000000 0x00000000 3 gig User User User Kernel Kernel Kernel Kernel

  31. Segments { 0x00000000 PageTable User 4 gig Kernel

  32. Segments { 0x00000000 User 4 gig Kernel

  33. Segments 0x00000000 { 0x00000000 User 4 gig Kernel

  34. Segments 0x00000000 Text { 0x00000000 User 4 gig Kernel

  35. Segments 0x00000000 Text Data { 0x00000000 User 4 gig Kernel

  36. Segments 0x00000000 Text Data ... { 0x00000000 User 4 gig Kernel

  37. Segments 0x00000000 Text Data ... { Grows Upwards Heap 0x00000000 User 4 gig Kernel

  38. Segments 0x00000000 Text Data ... { Grows Upwards Heap 0x00000000 mmap (Shared Memory) User 4 gig Kernel

  39. Segments 0x00000000 Text Data ... { Grows Upwards Heap 0x00000000 mmap (Shared Memory) User 4 gig Grows Stack Downwards Kernel

  40. So what is code?

  41. So what is code?

  42. So what is code?

  43. So what is code?

  44. Is this code?

  45. Is this code?

  46. Is this code?

  47. Is this code?

  48. Is this code?

  49. 0x00000000 Text Data ... { Grows Upwards Heap 0x00000000 mmap (Shared Memory) User 4 gig Grows Stack Downwards Kernel

  50. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 mmap Text Data ... Heap Stack (Shared Memory) Grows Grows Upwards Downwards

  51. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 mmap Text Data ... Heap Stack (Shared Memory) Grows Grows Upwards Downwards

  52. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 int argc char **argv char **envp Grows Downwards

  53. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 Saved Saved int argc char **argv char **envp EBP EIP Grows Downwards

  54. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 Saved Saved int argc char **argv char **envp EBP EIP Grows Downwards

  55. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 Saved Saved int i int argc char **argv char **envp EBP EIP Grows Downwards

  56. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 Saved Saved int i int argc char **argv char **envp EBP EIP Grows Downwards

  57. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 function_1 function_1 Saved Saved int i int argc char **argv char **envp argument_1 argument_2 EBP EIP (a) (b) Grows Downwards

  58. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 function_1 function_1 Saved Saved int i int argc char **argv char **envp argument_1 argument_2 EBP EIP (a) (b) Grows Downwards

  59. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 function_1 function_1 Saved Saved Saved Saved int i int argc char **argv char **envp argument_1 argument_2 EBP EIP EBP EIP (a) (b) Grows Downwards

  60. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 function_1 function_1 Saved Saved Saved Saved int i int argc char **argv char **envp argument_1 argument_2 EBP EIP EBP EIP (a) (b) Grows Downwards

  61. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 function_1 function_1 Saved Saved Saved Saved int i int argc char **argv char **envp int j argument_1 argument_2 EBP EIP EBP EIP (a) (b) Grows Downwards

  62. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 function_1 function_1 Saved Saved Saved Saved int i int argc char **argv char **envp argument_1 argument_2 EBP EIP EBP EIP (a) (b) Grows Downwards

  63. Stack Basics int function_1(int a, int b) { int j; // do stuff return j; } int main(int argc, char **argv, char **envp) { int i; i = function_1(1,2); printf(“answer is %d”, i) return i; } 0x00000000 function_1 function_1 Saved Saved int i int argc char **argv char **envp argument_1 argument_2 EBP EIP (a) (b) Grows Downwards

  64. Classic Overflow Where to go function_1 Saved Saved Saved Saved buff int j argument_1 int argc char **argv char **envp EBP EIP EBP EIP (a) Overflow Direction Stack Grows Downwards

  65. non-terminated strings strcpy(buf1, buf2);

  66. non-terminated strings strcpy(buf1, buf2);

  67. non-terminated strings char buf1[4]; strcpy(buf1, buf2); strncpy(buf1, buf2, 4);

  68. non-terminated strings char buf1[4]; strcpy(buf1, buf2); strncpy(buf1, buf2, 4);

  69. non-terminated strings char buf1[4]; strcpy(buf1, buf2); strncpy(buf1, buf2, 4); T E S T I N G \0 char buf1[4] char buf2[] = “TESTING”

  70. non-terminated strings char buf1[4]; strcpy(buf1, buf2); strncpy(buf1, buf2, 4); T E S T T E S T I N G \0 char buf1[4] char buf2[] = “TESTING”

Recommend


More recommend