What we will learn?
Everything tested on Windows7 Ultimate X86
In this writeup, we will use Mona.py to find addresses. Also, we will develop python exploit for PWNing the Castripper 2.50.70.
Fuzzing The Application
CastRipper is an application for audios. So when we run the application we can see that we can upload playlists. pls and .m3u files. When we try to upload playlist which playlist has 20.000 bytes for flowing the stack we could see it crashed. Let’s debug with Immunity Debugger and Going deeper! (I recommend you read the previous article which is mine).
Debugging The Application With Immunity Debugger
First of all, we know this application crashes with 20.000 bytes. But we don’t know that after how many bytes we can overwrite EIP. So we have to create payload. I will use mona.py for doing it.
Yes, we created the pattern with 20000 bytes. You can reach to that pattern at C:\mona\CastRipper\pattern.txt. Let’s take pattern from pattern.txt and paste it to another text file then change the extension as m3u so now we can upload it as a playlist. Let’s run it!
Now we’ve overwritten the EIP and crashed the stack. Now we will search for the pattern offset and then we will start to PWNing the application
Finding Pattern Offset
As you can see on the image our EIP value is
68573268. Let’s search it with Mona.py.
Now we’ve found the pattern offset as 17377 bytes. you can also use the pattern which is created by this python script:
#!/usr/bin/python offset = "\x41"*17377 offset += "\x42"*4 print offset
After using this script we can see 42424242 on the EIP. We have to think for executing our shellcode with buffer overflow. now we know that this application is an old application. So we can execute shellcode with jumping to ESP and then overwriting shellcode. We are jumping to ESP because ESP means Stack Pointer. So ESP means the head of the stack. If this application was a new application we must calculate the address of shellcode but for now no need to it. We will do it on another writeup.
Jumping To ESP (JMP ESP)
Now we need to find a JMP ESP address. But first, we have to find modules and select module which doesn’t contain ASLR or DEP. I will use mona.py for doing it. Let’s check the modules with this command:
Now we will find a JMP ESP instruction on that module (DLL). Let’s use the following command:
!mona jmp -r esp -m CRutility03.dll. This command looks for JMP ESP instruction on CRutility03.dll.
Okey, now we have everything except one thing. That thing is our shellcode. I will use this shellcode for PoC. But you can create your own shellcode with msfvenom or assembly :).
After adding hackme.m3u as playlist cmd.exe will be executed. 🙂