Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/documentation/modules/exploit/windows/ftp/ayukov_nftp.md
Views: 11789
Vulnerable Application
Ayukov is an FTP client that was written by Sergey Ayukov back in 1994. Development stopped in 2011, and it is vulnerable to a stack-based buffer overflow vulnerability due to the way it handles the server input.
The exploit was tested on Windows XP SP3 (English).
The vulnerable copy can be downloaded from Exploit-DB.
PoC
A submission was made to Metasploit as PR #9360. Here's an example of how to crash the FTP client:
Root Cause Analysis
When serving the PoC against the vulnerable app, the client's command prompt shows:
The interesting part here is that when the client sends a SYST
request, the server responds with a long string of data attempting to cause a crash. This would be a good starting point to investigate the root cause.
With IDA Pro, we can tell that the SYST
string is at the following location:
When we cross reference, we can tell this is used by the OpenControlConnection
function. Although there is no symbol to identify the actual function name "OpenControlConnection", the debugging message at the beginning of the function is a big hint:
Anyway, inside the OpenControlConnection function, we can see that the SYST
command is requested here for SendFTPRequest (no symbol of clue of the name, I just decided to name it this way):
Inside the SendFTPRequest function, it looks like this:
We were able to tell the second argument for SendFTPRequest
is actually a buffer for receiving the server's response, because the way it is used:
In addition, this buffer is actually on the stack, and it's 4096 long:
This means that if the server responds with something longer than 4096 bytes for the SYST
request, the data may corrupt the stack, and cause a stack-based buffer overflow. At the end of OpenControlConnection
, the RETN
ends up loading the corrupt data, which may lead to arbitrary code execution:
Since whoever is using SendFTPRequest
is responsible for providing the buffer of the server response, and there are 47 other cross-references, it is possible there are different ways to trigger the same bug. And since it doesn't look like there is a patch (because the product is no longer in active development, from the exploit developer's perspective, it is not necessary to look for other ways to exploit it).