Today I will release information about a Supraclient kaillera buffer overflow 0 day vulnerability. I have decided it makes sense to disclose this vulnerability because Supraclient is very old and very obscure.
First of all we need the vulnerable version of Supraclient kaillera client.
Note: This exploit is probably has no practical attack vectors at all, this is mostly just an exploit for practice.
The target system is Windows XP SP3 running in a virtual machine (VMware Workstation 7 to be precise).
This is because Windows XP is easier to exploit (it lacks advanced protections such as DEP and ASLR that later versions of Windows have). Additionally, according to some statistics, 66% of users who have Windows still run XP.
In this particular example, the amount of bytes required to cause the buffer overflow remains the same on any virtual machine, but be aware sometimes they will change based on your environment, so experimenting yourself is important.
This post deals with information about buffer overflows; if you're not familiar with them, you can learn more at Corelan. This is an excellent site full of tutorials about buffer overflows and how to exploit them on a Windows environment. I recommend that you read a few tutorials (such as part 1 and 2 on stack overflows) on that website before you continue to fully understand what is happening.
As a brief overview, a buffer overflow is nothing but overflowing a region in memory with user input of some kind. Most if not all security vulnerabilites come from badly processed user input. Some vulnerable C/C++ functions such as the classic strcat and strcpy will copy a number of bytes from one memory location
to another without any kind of bounds checking. If these functions are used to process user input of some kind, a user can specify more bytes than the buffer has been declared to hold. For instance, if we supply 20 bytes of input to a 15 byte buffer, we have a buffer overflow. The EIP register, which is an area in memory that points to the next instruction to be processed, will be overwritten with our data, meaning we can specify
an arbitrary hexadecimal value that can point to any CPU assembly instructions we want, and therefore hijack
the program's execution to execute any code we desire in memory. Thus a buffer overflow is one of the most serious types of vulnerabilities as it allows for total control over a computer in most cases.
With that being said, let's begin. First, we will extract the Supraclient dll file we have downloaded into the emulator folder of Project64k, overwriting the existing kailleraclient.dll file with the Supraclient dll file.
Next, download two very useful tools: Immunity Debugger and Pvefindaddr plugin:. These will help us as we develop our exploit. The Pvefindaddr plugin needs to be copied into the Immunity Debugger Commands folder before it can be used (C:\Program Files\Immunity Inc\Immunity Debugger\PyCommands\pvefindaddr.py)
Open Immunity Debugger and type !pvefindaddr pattern_create 2200 in the text box area and hit enter.
This will create a cyclic pattern of 2200 bytes which we will feed into the program to see if it will crash.
This is useful because if we only used the same character, for example, 2200 "A's", we wouldnt know the specific 4 bytes that overwrote EIP (because they are all A's, so whats the difference). This is where the unique pattern comes in handy to quickly identify how many bytes it takes to overwrite the memory location EIP points to.
To copy the output of the cyclic pattern, open the directory Immunity was installed (usually C:\Program Files\Immunity Inc\Immunity Debugger\) and open the file called mspattern.txt. Then copy that string to the clipboard.
Next we launch Project64K. Go to Start>Net Play, and the Kaillera GUI window will open up. Paste the mspattern.txt string into the window in the lower left (the one which says IP Address in the screenshot):
Now go to Immunity Debugger and go to File>Attach, and pick the process which is running Kaillera (in our example its Project64k.exe) and click Attach. If you see any messages about "Entry Point Alert" just click past them by clicking OK. Now hit F9 (or click the red play button in Immunity) to start the debugging. Go back to Kaillera and click Login.
Boom. Immunity triggers an access violation when executing (part of your cyclic pattern):
As you can see, EIP is overwritten with 33714332, which is hexadecimal for the string "2cQ3", which is part of our mspattern.txt. How do we know how many bytes it takes before we reach 2cQ3? Type !pvefindaddr pattern_offset 0x33714332 in order to see how many bytes we need to hit the EIP overwrite. Once you hit enter, go to View> Log, and you will note that the pattern is reached after 2048 bytes. This means that we need to supply 2048 bytes of junk and then 4 bytes to overwrite EIP.
We need to overwrite EIP with a pointer which will allow us to jump to the stack, so that the rest of our user input will be executed as code (our shellcode). Which four bytes do we choose? We can either use an application-specific jump, which would only work on one emulator, or we can use an OS-specific jump, which only works on particular versions of Windows. For now I am going to use an OS-specific opcode, JMP ESP in hnetcfg.dll (ascii of O².f, hex of 662EB24F), which would work for any emulator on a specific Windows XP version. JMP ESP tells the computer to jump to the stack, which will then execute whatever code we place after those 4 bytes at EIP.
But wait a minute! This is a text box, we can't just put random binary characters in here. This is correct. We have to deal with character restrictions. In this case, as I have experimented to find out, we are dealing with mostly extended-ascii limitations, meaning we can use more characters than just a-z. Our bad characters in hex are the following: 00-1F,7F, and 81-9F. Any other characters in the 255 character extended-ascii set are fair game however.
Let's now generate an alphanumeric shellcode using Alpha3. This tool will require us to have a base register for the shellcode it needs to run in order to decode characters. In this case, we give it the register of ESP (the stack) since we know that our shellcode is directly at the beginning of the stack and doesn't seem to get mangled. This particular shellcode will be given to Alpha3 as a metasploit encoded calc.exe payload (as a simple demonstration). However, its easy enough to replace that with a payload that adds an admin account, or a remote shell, or a meterpreter payload...
So our entire exploit string ends up looking like this:
Once we paste this into the emulator, it goes boom:
Woot! Calc.exe has been executed! We have successfully executed a stack buffer overflow against kaillera Supraclient!