1 / 7

Simple Buffer Overflow Example

Simple Buffer Overflow Example. Dan Fleck CS469 Security Engineering Reference: http:// www.thegeekstuff.com /2013/06/buffer-overflow/ . 1. 1. Buffer Overflows. Buffer overflows occur when some sized portion of memory is overwritten with something bigger. For example:

chas
Download Presentation

Simple Buffer Overflow Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Simple Buffer Overflow Example Dan Fleck CS469 Security Engineering Reference: http://www.thegeekstuff.com/2013/06/buffer-overflow/ 1 1 Coming up: Buffer Overflows

  2. Buffer Overflows • Buffer overflows occur when some sized portion of memory is overwritten with something bigger. • For example: • char buff[10]; // Min index is 0, max index is ???? • Overflow: • buff[10] =‘d’; 2 Coming up: Why care?

  3. Why care? • Minimally buffer overflows can cause program crashes or unexpected results • char *ptr = (char *) malloc (10); // Allocate 10 bytes on heap ptr[10] = ‘d’ ; // Crash! • However because buffer overflows corrupt memory nearby the variable being over-filled, an informed hacker can use this to write data into other protected areas of the program (i.e. stack and heap) • char buff[10] = {0}; strcpy(buff, “Lets overflow that buffer!”); // Stack overflow! 3 Coming up: An attack

  4. An attack intmain(void) { char buff[15]; int pass = 0; printf("\n Enter the password : \n"); gets(buff); // Get the password from the user if(strcmp(buff, "thegeekstuff")) { // Check the password printf ("\n Wrong Password \n"); } else { printf ("\n Correct Password \n"); pass = 1; // Set a flag denoting correct pass } if(pass) { /* Now Give root or admin rights to user*/ printf("\n Root privileges given to the user \n"); } return 0; } 4 Lets test it! Coming up: Lets look inside…

  5. Lets look inside… • GDB is a common debugger for C programs. • gcc –g myFile.c // -g option enables debug symbols and thus debugging • DDD is a graphical front-end to GDB. Typically GDB is used from a command line interface 5 Coming up: Lessons

  6. Lessons • Buffer overflows occur when memory bounds of a variable are exceeded • They can occur on the heap or the stack • Buffer overflows have unintended consequences. • There are protections against unsafe operations however they may not always be used (or known) 35 6 Coming up: References

  7. References • http://blog.zynamics.com/2010/03/12/a-gentle-introduction-to-return-oriented-programming/ • http://cseweb.ucsd.edu/~hovav/dist/geometry.pdf • Stealth: http://www.suse.de/~krahmer/no-nx.pdf • Nergel, http://www.phrack.com/issues.html?issue=58&id=4#article • http://cseweb.ucsd.edu/~hovav/dist/rop.pdf 36 36 7 End of presentation

More Related