Introduction to Windows User Mode Exploitation pt. 2
Introduction to Windows User Mode Exploitation pt. 2
Exploiting Stack Overflows: In this module, we will focus on a CTF to learn how to do memory corruption vulnerability to control the execution flow of an application:
Enter [VulnServer](https://github.com/stephenbradshaw/vulnserver)!
But first, an introduction to Stack Buffer Overflows
`#include <stdio.h>`
`#include <string.h`
`int main(int argc, char *argv[])
`{
`char buffer[64];
`if (argc < 2)
`{
`printf("Error - You must supply at least one argument\n");
`return 1;
`}
strcpy(buffer, argv[1]);
return 0;
`}
The code shown above contains a buffer overflow by the fact that the argv[1] which is supplied by the user as a string can be passed (using `strcpy`) overflowing the variable buffer which can only hold 64 bytes, since this input is unchecked on size we can crash or exploit the application by entering data to overwrite the return address.
Back to [Vulnserver](https://github.com/stephenbradshaw/vulnserver)
About VulnServer :
*Vulnserver is a multithreaded Windows based TCP server that listens for client connections on port 9999 (by default) and allows the user to run a number of different commands that are vulnerable to various types of exploitable buffer overflows.*
*This software is intended mainly as a tool for learning how to find and exploit buffer overflow bugs, and each of the bugs it contains is subtly different from the others, requiring a slightly different approach to be taken when writing the exploit.*
*Though it does make an attempt to mimic a (simple) legitimate server program this software has no functional use beyond that of acting as an exploit target, and this software should not generally be run by anyone who is not using it as a learning tool.*
Approach
- White Box , Black Box or Gray Box
- Static and Dynamic
- Reverse Engineering
- Obfuscation implemented?
Lets have a mix of Black Box , Static and Dynamic just for the fun (*and learning process*) of it.
Vulnserver has two binaries, vulnserver.exe and essfunc.dll, running vulnserver on command prompt provides the following response :
As per description vulnserver runs default on port 9999 , however we can confirm this with `nmap` by running a simple command
We connect with netcat on port 9999 (`nc 192.168.160.37 9999`) to establish connection and pass our arguments,
After we enter the HELP argument
This is mostly how we would proceed on a black box analysis,
however due to time constraints and not covering fuzzing (for now) we subject ourselves to reverse engineering to figure the logic of the application.
Enter IDA Pro :
There's many ways (which we wont cover : for now) to access the commands seen above and understand their logic, for now we will simply check on the strings values on IDA PRO (`Shift + F12`)
which points us to :
Our first command that we will interact with is the TRUN command , this offers a classic vanilla stack buffer overflow.
Onwards to part 3 : Analyzing the application
Comments
Post a Comment