Thread: buffer overflow

Results 1 to 6 of 6
  1. #1
    42trojan42's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Location
    127.0.0.1
    Posts
    81
    Reputation
    10
    Thanks
    16
    My Mood
    Devilish

    Unhappy buffer overflow

    can anyone explain what's a buffer overflow attack!?!?

  2. #2
    Frought's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    In the dark island
    Posts
    3,403
    Reputation
    156
    Thanks
    5,980
    My Mood
    Cool
    Well, let's say you have a buffer that is the according:
    Code:
    char Buffer[5];
    strcpy(Buffer, "More than 5 chars is a buffer overflow");
    That is an example of how buffer overflow occurs, basically it is when you try to make the buffer hold that it's size.

  3. The Following User Says Thank You to Frought For This Useful Post:

    42trojan42 (04-11-2015)

  4. #3
    殺す必要がある唯一のものは殺されるために準備され人 々である。
    Premium Member
    Hitokiri~'s Avatar
    Join Date
    Oct 2012
    Gender
    female
    Location
    Cancer.
    Posts
    1,201
    Reputation
    24
    Thanks
    937
    My Mood
    Bitchy
    Since the above explanation sucks...

    A buffer overflow attempts to write data outside of a specific memory region allocated.
    It is commonly used as an attack ( or exploit ) to allow a program to execute things that it isn't supposed to normally execute.

    Consider the following C code:

    Code:
    const char* myFunc( int myNum ){
       static char num2Str[5];
    
       sprintf( num2Str, "%i", myNum );
       return num2Str;
    }
    What happens if we pass the number "99999" to it?
    A buffer overflow occurs. Why?

    Let's look at it:
    - 5 characters of '9'
    - 1 null terminator

    But the buffer is only 5 bytes in size. So what happens? It overwrites the adjacent memory.
    Assume the memory looks like this:

    Code:
    num2Str  anotherVariable
    
    xxxxx     xxxxxxxxxxxxx
    Assuming we write the memory with the above "99999" integer passed, it will now look like this:

    Code:
    num2Str  anotherVariable
    
    99999     0xxxxxxxxxxx
    As you can see, the highest byte of "anotherVariable" gets overwritten with the null terminator ( 0 ).

    That's essentially what static memory buffer overflows are.
    Stack based buffer overflows occur when the same thing above happens, but on the stack.

    This can be used to redirect your RIP/EIP register to perform code execution that shouldn't normally happen.

  5. The Following User Says Thank You to Hitokiri~ For This Useful Post:

    42trojan42 (04-11-2015)

  6. #4
    42trojan42's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Location
    127.0.0.1
    Posts
    81
    Reputation
    10
    Thanks
    16
    My Mood
    Devilish
    Quote Originally Posted by Hitokiri~ View Post
    Since the above explanation sucks...

    A buffer overflow attempts to write data outside of a specific memory region allocated.
    It is commonly used as an attack ( or exploit ) to allow a program to execute things that it isn't supposed to normally execute.

    Consider the following C code:

    Code:
    const char* myFunc( int myNum ){
       static char num2Str[5];
    
       sprintf( num2Str, "%i", myNum );
       return num2Str;
    }
    What happens if we pass the number "99999" to it?
    A buffer overflow occurs. Why?

    Let's look at it:
    - 5 characters of '9'
    - 1 null terminator

    But the buffer is only 5 bytes in size. So what happens? It overwrites the adjacent memory.
    Assume the memory looks like this:

    Code:
    num2Str  anotherVariable
    
    xxxxx     xxxxxxxxxxxxx
    Assuming we write the memory with the above "99999" integer passed, it will now look like this:

    Code:
    num2Str  anotherVariable
    
    99999     0xxxxxxxxxxx
    As you can see, the highest byte of "anotherVariable" gets overwritten with the null terminator ( 0 ).

    That's essentially what static memory buffer overflows are.
    Stack based buffer overflows occur when the same thing above happens, but on the stack.

    This can be used to redirect your RIP/EIP register to perform code execution that shouldn't normally happen.
    thank you very much ! but maybe you should change your font for the next time

  7. #5
    Frought's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    In the dark island
    Posts
    3,403
    Reputation
    156
    Thanks
    5,980
    My Mood
    Cool
    Quote Originally Posted by Hitokiri~ View Post
    Since the above explanation sucks...

    A buffer overflow attempts to write data outside of a specific memory region allocated.
    It is commonly used as an attack ( or exploit ) to allow a program to execute things that it isn't supposed to normally execute.

    Consider the following C code:

    Code:
    const char* myFunc( int myNum ){
       static char num2Str[5];
    
       sprintf( num2Str, "%i", myNum );
       return num2Str;
    }
    What happens if we pass the number "99999" to it?
    A buffer overflow occurs. Why?

    Let's look at it:
    - 5 characters of '9'
    - 1 null terminator

    But the buffer is only 5 bytes in size. So what happens? It overwrites the adjacent memory.
    Assume the memory looks like this:

    Code:
    num2Str  anotherVariable
    
    xxxxx     xxxxxxxxxxxxx
    Assuming we write the memory with the above "99999" integer passed, it will now look like this:

    Code:
    num2Str  anotherVariable
    
    99999     0xxxxxxxxxxx
    As you can see, the highest byte of "anotherVariable" gets overwritten with the null terminator ( 0 ).

    That's essentially what static memory buffer overflows are.
    Stack based buffer overflows occur when the same thing above happens, but on the stack.

    This can be used to redirect your RIP/EIP register to perform code execution that shouldn't normally happen.
    It is the same explanation but you have just added some small extra..

  8. #6
    殺す必要がある唯一のものは殺されるために準備され人 々である。
    Premium Member
    Hitokiri~'s Avatar
    Join Date
    Oct 2012
    Gender
    female
    Location
    Cancer.
    Posts
    1,201
    Reputation
    24
    Thanks
    937
    My Mood
    Bitchy
    Quote Originally Posted by Frought View Post
    small extra
    "small".
    Actually, I didn't quite understand your post so I decided to elaborate.

Similar Threads

  1. Replies: 4
    Last Post: 02-18-2014, 06:51 PM
  2. buffer overflow
    By kibbles18 in forum General Game Hacking
    Replies: 3
    Last Post: 01-10-2012, 01:01 AM
  3. Replies: 4
    Last Post: 05-07-2010, 01:59 AM
  4. KWR CrashRoom Buffer Overflow Exploit !!!!
    By xawery15 in forum WarRock Korea Hacks
    Replies: 2
    Last Post: 05-06-2009, 05:15 AM
  5. Replies: 0
    Last Post: 03-25-2008, 12:31 PM

Tags for this Thread