Patching your operating system isn’t enough. You need to patch your third-party applications too as they can contain vulnerabilities such as buffer overflows that allow a system to be exploited.
Enumeration
First step as always, is to see what we can discover with an nmap scan
| |
No hits in the top 1000 ports.
Since I’m scanning such a large range of ports, I want to do it quickly. I change the nmap command to skip the thoroughness (-sV & -sC) in favour of speed. I add the sS switch to perform a SYN (or half-open) scan. This helps, as the scan will send the SYN packet and wait for the ACK response to see if the port is open. It won’t complete the second half of the three-way handshake, which saves us time. At this stage, we just want to know what ports respond. We’ll dig into more detail once we can run targeted scans on a specific list of listening ports. I also add Pn (treat all hosts as up), -p- to scan all ports, and finally T5 to use a higher timing template (higher number is faster).
| |
Hmm .. nmap is timing out. This could either be because my connection sucks, the box is being hammered by other hackers, or it could possibly be intentional. So knowing my phat pipes are a little less phat to this box, I decided to break down the nmap scan to 2000 port chunks. It took a little while, but I finally got some results when scanning the 8000-10000 port range.
| |
Nmap shows that ports 9255 and 9256 relate to something called AChat, so I do a quick search for exploits.
| |
Look like I’m dealing with a buffer overflow vulnerability.
Exploitation
A grab a copy of the buffer overflow exploit to my local directory and open it up in VSCode to take a look
| |

Within the comments of the code, it shows that it’s an msfvenom generated payload used to execute calc.exe. It’s also worth noting everything after the -b switch, as this indicates the bad characters I need to make sure I exclude from my payload.
| |
I just copy and paste the example in the script file and substitute the values I need.
The example uses msfvenom to generate the shell code to execute on the remote system once the buffer has been overflowed.
I specify windows/shell/reverse_tcp as the payload, the encoding type, and also the bad characters to exclude as noted before. Finally, I punch in the IP address and port of my local machine in the LHOST and LPORT parameters so the reverse shell will reach back to me once executed on the remote system.
| |
Back in vscode, I replace the buffer shell code with what was generated by msfvenom I also update the value of the remote server to the IP address of Chatterbox.

Next, I fire up metasploit and configure a listener to receive the connection for when I execute the payload.
| |
Finally, I fire the exploit.

User flag obtained!
Privilege escalation
As the Alfred user, I perform some enumeration of the system. After a little bit of time, I figure out that I can to browse to the desktop of the Administrator user, however, I’m unable to read the contents of the flag.
| |
In normal circumstances, the access control list (ACL) on the Administrator’s home folder should prevent any other user from accessing the directory. Considering I’m able to browse there, something has been changed.
Using the icacls command, I check the ACLs on the Administrator’s home folder and confirm that the Alfred user has been granted access.
| |
Looking at the Microsoft documentation for icals I confirm that Alfred has full control (F) to the directory, and these permissions will be inherited by both objects (files) and containers (directories) within that folder, indicated by OI and CI respectively.
So what’s that mean? Alfred has full read/write permissions to all files/folders within the Administrator directory. So why can’t I read the root flag? Let’s see…
| |
For this one specific file, the inherited permissions have been overwritten by explicit ones. This means any permissions set on the parent folder will be ignored for this file.
Nice try sysadmin, but no cigar. Since we own the parent folder, we can simply change the permissions. Using icalcs again, I grant Alfred read permissions to root.txt
| |
Now I try reading the file again
| |
Deconstructing the hack
The vulnerability that was exploited in this challenge was a buffer overflow vulnerability that existed in the AChat application.
The concept of buffer overflow is a very complicated topic and even more difficult to explain, but I’ll do my best.
Basically, buffers are areas of memory set aside to hold data. They are most often used by applications to move data from one section of a program to another, or even between programs. Buffer overflows are usually triggered by inputting data into the application that exceeds the size of the buffer that was set aside in memory. The parts of the input that exceeds the buffer size will overflow into adjacent parts of memory, hence the term buffer overflow.
So let’s say for the sake of simplicity, you’re an application developer that’s writing an app that accepts credit card information. You create an input field on your form for the user to input a credit card, and you define your buffer to hold 16 digits of data - the length of a credit card number. Credit card numbers aren’t variable in length, they’re always 16 digits, so this makes sense in order to conserve system resources. But what if I enter 17 digits? Or 100 digits? If the developer doesn’t handle the invalid input correctly, I’ve overflowed the buffer by the extra digits into an adjacent area of memory, and the program will most likely crash.
So why is this important? Because on many systems, the memory layout of a program, or the system as a whole, is well defined. By sending data designed to cause a buffer overflow, it is possible to write into areas known to hold executable code and replace it with malicious code. This is what happened with the vulnerability in the AChat application.
The python script did all the hard work. The creator of the script has identified the location in memory where the buffer for AChat was stored, and also all the additional bytes of adjacent read only memory. By overflowing the buffer with just the right amount of data, we can skip over all the read-only memory, and end up in executable memory. This is where our payload lands and is then executed by the system.
Conclusion
The important thing to take away here is that it not just an operating system that can contain a vulnerability that allows a bad actor access to your system. Applications too can have a vulnerability that leads to a system being compromised. This is why it is important to listen to your system administrators when they tell you that you need to patch third-party applications like java or flash.
Patching your operating system simply isn’t enough. You can have an excellent patching regime for your systems, however, if you’re not patching third-party apps too, then the job is only half done.
