Forwarded from ReverseEngineering
Part 6 Buffer Overflow
Understanding the Crash and the Structure of the Function Frame on the Stack
In this part, we are going to see what exactly happens behind the scenes when a buffer overflow causes a crash. After this part, we should
understand why overwriting data on the stack changes the return address.
What are the components of a function frame?
And how can these components be viewed and analyzed with gdb.
When a function is called in C, the system creates a space on the stack for that function. We call this space the function frame. Each frame contains these parts.
Local variables of the function
Parameter values
Saved RBP or base pointer
for return
Saved return address
which the function returns to after the function completes
If more data is written to the local buffer than the limit, these important values are overwritten in the frame
And as a result, the program crashes on return or jumps to the wrong address
This code helps us see the function frame and crash and analyze it in gdb
#include <stdio.h>
#include <string.h>
void crash(char *input) {
char buffer[16];
printf("address of buffer: %p\n", buffer);
strcpy(buffer, input);
printf("done copying\n");
}
int main(int argc, char **argv) {
if (argc < 2) {
printf("usage: %s input\n", argv[0]);
return 1;
}
crash(argv[1]);
printf("returned safely\n");
return 0;
}
Execution and analysis commands
gcc -g file4.c -o file4
gdb --args ./file4 $(python3 -c "print('A'*40)")
After running the program in gdb, perform these steps
break crash
run
info frame
x/32x $rbp
x/32x $rsp
Here you can see that the buffer is below the saved RBP
Every byte you write out of the buffer will eventually reach the saved RBP and then the return address
To view the crash
continue
The program crashes with a segmentation fault error
See the return path with the following command
backtrace
And check the last return address with this command
info registers rip
Full explanation
When executing the crash function, the system first saves the current RBP
Then it moves the RSP down to provide the necessary space for local variables
In this new buffer space, Yes
When we write data larger than the buffer size, first the data is written to local variables, then to RBP, and then to the return address
At the moment the function wants to return, the wrong value is read from the stack and RIP jumps to the wrong address, which causes a segmentation fault
Interesting part
You can see the difference before and after the overflow in gdb with this command
Before strcpy
x/32x $rbp-32
After strcpy
x/32x $rbp-32
You can see that the A bytes have filled all the space between the buffer and the return address
This is the reason for the program crash
@reverseengine
Rowhammer Attacks on DDR5 with Self-Correcting Synchronization
https://comsec-files.ethz.ch/papers/phoenix_sp26.pdf
https://comsec-files.ethz.ch/papers/phoenix_sp26.pdf
👍1
Critical Android 0-Click Vulnerability in System Component Allows RCE Attacks https://cybersecuritynews.com/android-0-click-rce-vulnerability/
Cyber Security News
Critical Android 0-Click Vulnerability in System Component Allows Remote Code Execution Attacks
Google has issued a critical security alert for Android devices, highlighting a severe zero-click vulnerability in the system's core components that could allow attackers to execute malicious code remotely without any user interaction.
👍3
ARM64 Reversing and Exploitation Part 2 – Use After Free | 8kSec Blogs
https://8ksec.io/arm64-reversing-and-exploitation-part-2-use-after-free/
https://8ksec.io/arm64-reversing-and-exploitation-part-2-use-after-free/
👍4
RCE via type confusion vulnerability on Lasso SAML Library
https://www.talosintelligence.com/vulnerability_reports/TALOS-2025-2193
https://www.talosintelligence.com/vulnerability_reports/TALOS-2025-2193
👍2
Windows Heap Exploitation - From Heap Overflow to Arbitrary R/W
https://mrt4ntr4.github.io/Windows-Heap-Exploitation-dadadb/
https://mrt4ntr4.github.io/Windows-Heap-Exploitation-dadadb/
mrT4ntr4's Blog
Windows Heap Exploitation - From Heap Overflow to Arbitrary R/W
TLDR I was unable to find some good writeups/blogposts on Windows user mode heap exploitation which inspired me to write an introductory but practical post on Windows heap internals and exploitati
👍1
HydraPWK Penetration Testing OS With Necessary Hacking Tools and Simplified Interface https://share.google/ot3QjPEaGXlIeTcyY
Cyber Security News
HydraPWK Penetration Testing OS With Necessary Hacking Tools and Simplified Interface
The HydraPWK project's latest Apes-T1 snapshot refines its penetration-testing Linux distribution by replacing Elasticsearch with the open-source OpenSearch, resolving licensing issues and enhancing tools for industrial security assessments.