Running a Buffer Overflow Attack - Computerphile
Why Information Security Stack Exchange recommends it
Security Stack Exchange answerers point people to it as a clear, approachable introduction to how buffer overflow attacks actually work, including when the question is only loosely related to the topic.
Recommended by 2 people across 2 different months, 2016 to 2019.
Why Stack Overflow recommends it
Stack Overflow users link it when explaining what stack smashing and buffer overflows are, and as the tutorial beginners try to reproduce, often asking why their compiler or gdb setup behaves differently.
Recommended by 0 people across 0 different months, 2019 to 2024.
What it is
Computerphile video in which Dr Mike Pound of the University of Nottingham walks through a buffer overflow attack, showing how overwriting memory beyond a buffer can let an attacker run code and gain root privileges. It is a whiteboard-and-terminal explainer filmed and edited by Sean Riley, building on the channel's earlier video about the stack.
What people said
Strong rec Mister Amen · 2019-09 · Information Security Stack Exchange · on “Global variables and information security”
Buffer Overflow Attacks While fairly language-specific ( C/C++ come to mind ), and difficult to pull off, they are a potential attack. Computerphile has a great video [this video] about it, that I wholeheartedly recommend, but here's a short version of the mechanics of this attacks and how it interacts with global variables. A buffer overflow occurs when data written to a buffer also corrupts data values in memory addresses adjacent to the destination buffer due to insufficient bounds checking. This can occur when copying data from one buffer to another without first checking that the data fits within the destination buffer. ( Wikipedia [LINK] ) In the case of global variables, your program's mem
Recommends Tobi Nary · 2016-03 · Information Security Stack Exchange · on “How to exploit a Use-After-Free vulnerability?”
However unrelated this may be from the topic, Computerphile [this video] does a good job simplifying problems in CS in general. The linked video might help you nontheless the apparent off-topic-ness.
Cites Kris Molinari · 2017-03 · Information Security Stack Exchange · on “Is it possible for unprivileged user to modify/inject into other user's (root) process?”
Yes, but it depends on the OS. One way of doing this is known as a Buffer Overflow attack. These attacks are results of vulnerabilities at the Kernel level, so they are relatively rare. There is an entire video on the subject by Computerphile: [this video]
Cites gstukelj · 2019-09 · Stack Overflow · on “What is stack smashing and how do I fix it?”
Stack smashing error is returned because of the memory protection mechanisms [LINK] used by the compiler. You could disable this feature but this would lead to vulnerabilities that are exploited by the so called stack buffer overflow attack (see this computerfile's video on youtube [this video] ). You're not declaring your character array with a specific size, but because you're initializing it with a string literal [LINK] the size of the divStatement character array is set to 18 bytes (17 for the characters in " is divisible by " and 1 for the "\0" , the so-called null character [LINK] used for string termination). From the C99 standard 6.4.5/5 "String Literals - Semantics" (as quoted in an answ
Cites user1424739 · 2021-01 · Stack Overflow · on “Show segment addresses in gdb”
This [this video] shows the layout of the virtual memory of a program, which includes the following segments from a high memory address to a low memory address. kernel stack (grows from high addresses to low addresses) heap (grows from low addresses to high addresses) data text Is the arrangement of these segments always so? Are they independent of what computer architecture a computer uses? To inspect the address of each segment in gdb, could anybody show me how to do it? Take the following C program as an example: #include <stdio.h> int main() { printf("Hello World!\n"); }
Cites Lucas · 2022-02 · Stack Overflow · on “In which cases is scanf safe in terms of overflow? And in which cases must it necessarily be replaced by another function such as fgets?”
Functions scanf and gets for string processing The scanf [LINK] function is safe for string processing [LINK] because there is a specific field to delimit the length of the string. This is shown in the following example. // Example 01 #include <stdio.h> #define SIZE 7 int main(void) { char city[SIZE]; printf("Insert the name of your city: "); // Columbus scanf("%6s", city); printf("The city is: %s", city); // Columb return 0; } /* ## Output ## * Insert the name of your city: Columbus * The city is: Columb */ If the user enters for the name of the city Columbus , a buffer overflow [LINK] will not occur, since scanf will limit itself to trying to store only the first 6 characters of the string
Cites Mattia Suffredini · 2022-06 · Stack Overflow · on “Can't getting a segmentation fault”
I've seen from a Numberphile video ( [this video] ) a way to run a buffer overflow, and I wanted to try it out. I have written a piece of code, which is identical to the one shown in the video except for the size of "buffer", but, if I give in input a string bigger than the size of "buffer", I am not getting a segmentation fault, as it was shown in the video; can someone explain why? #include <stdio.h> #include <string.h> int main(int argc, char** argv){ char buffer[50]; strcpy(buffer, argv[1]); return 0; } Edit: By the way, as I've seen in the comments that this is a determinating thing, I am using th GCC compiler.
Cites r3k0j · 2024-02 · Stack Overflow · on “EIP doesn't get overwritten when perfoming a buffer overflow attack”
I was watching this video on youtube: [this video] and i was trying to do the same steps shown in the video, but i can't seem to overwrite the EIP. I don't know if it's because the gdb may have changed during the years, or if anything else has. What i get when i try to overflow is the following Program received signal SIGSEGV, Segmentation fault. 0x080491ac in main ( argc=<error reading variable: Cannot access memory at address 0x41414141>, argv=<error reading variable: Cannot access memory at address 0x41414145>) at example.c:9 9 } I can't seem to overwrite the eip, no matter how large my input is. The code is the same as shown in the video with a smaller buffer size. #include <stdio.h> #include
Cites r3k0j · 2024-02 · Stack Overflow · on “Buffer overflow attack not going as intended”
I was watching this video on youtube: [this video] and i was trying to do the same steps shown in the video, but i can't seem to overwrite the EIP. I don't know if it's because the gdb may have changed during the years, or if anything else has. What i get when i try to overflow is the following Program received signal SIGSEGV, Segmentation fault. 0x080491ac in main ( argc=<error reading variable: Cannot access memory at address 0x41414141>, argv=<error reading variable: Cannot access memory at address 0x41414145>) at example.c:9 9 } and not what you normally see in these buffer overflow exploit videos Program received signal SIGSEGV, Segmentation fault. 0x0000414141414141 in ?? () I can't seem to