Gaining Remote Server Access: Buffer Overflows — Part 2/ 2
A CGI script written in C contained a stack-based buffer overflow that allowed an attacker to execute arbitrary commands. By sending a crafted request, the attacker could spawn a reverse shell and gain full access to the server.
Published on systemweakness.com
Depending on how secure a remote server is, some of the simplest attacks could give you access, like a buffer overflow. Continued…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
The attacker could gain full root access to the remote server, as demonstrated by running commands from the attacker's device.
What the attacker needed
Vulnerable CGI script on target; script has execute permissions; netcat on target listening on port 4444; firewalls allow port 4444
How it was found
- Place the vulnerable CGI script on the target server with execute permissions.
- Ensure netcat is running on the target server listening on port 4444.
- Send a crafted HTTP request to the CGI script that overflows the buffer and includes a command to spawn a reverse shell.
- The reverse shell connects back to the attacker's machine, giving full access.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, spilling into nearby memory. Here, the attacker sent a long input to a web script, which overwrote part of the program's memory and let the attacker run their own commands. This gave them a remote shell, meaning they could control the server as if they were sitting at its keyboard.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.