Stack Buffer OverFlow

Discussion in 'C' started by micsom_micsom, Oct 28, 2009.

  1. micsom_micsom

    micsom_micsom New Member

    Joined:
    Mar 23, 2009
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Embedded C Programmer
    Location:
    India,Hybd
    i was just going through one of the articles and i thought about trying this

    char *pEvil="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

    int main(){
    char Good[2];
    strcpy(Good,pEvil);
    return 1;
    }

    this will crash saying that it is unable to access the memory whose location is "zzzz" in hexa(This is the expected)..i was just trying to figure out how the ESP and EBP is getting Corrupted here...

    can any1 plzz explain..:charming:
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Compile to assembly and you'll see exactly what is going on.
     
  3. micsom_micsom

    micsom_micsom New Member

    Joined:
    Mar 23, 2009
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Embedded C Programmer
    Location:
    India,Hybd
    i am Using Dev c++, i can't find any option to see the assembly Code ...
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    "-o source.s" might do the trick. I don't know, I use Visual Studio.
    Alternatively if you build the program, start it in debug mode and put a breakpoint on the first line of code, is there a "view assembler" option in the debugger?
     
  5. micsom_micsom

    micsom_micsom New Member

    Joined:
    Mar 23, 2009
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Embedded C Programmer
    Location:
    India,Hybd
    No such options ...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice