Disclaimer: This post only for education only ! not to cause any destruction on any living system. Be smart!
The last post in "breaking code" series we are talking about how to bypass SEH protection in windows program but I think that's not quite satisfied me yet because I only doing it once and I want to make sure I get the concept right
Ok so in this post again we are going to take over a program equipped with SEH protection, this time I picked "Free MP3 CD Ripper 2.8" software and again this is not originally come from me I only recreated the exploit and documented in detail manner.
But at the end of the post, I will show you something interesting that will make you more careful when designing software. Stay tuned until the end :)
This post is inspired by this thread in "packetstorm" security (https://packetstormsecurity.com/files/155440/Free-MP3-CD-Ripper-2.8-Buffer-Overflow.html)
Ok first we need to install the software in our windows virtual machine, note: you need an internet connection to complete the setup of the installation.
The program itself is just a converter for a music file. Alright! after you done with the installation open the software in the immunity debugger
After this, you can check the SEH check location with an immunity debugger. Go to the "view" > "SEH chain"
Like from the previous post, we need to craft an "evil" payload to crash the program.I'm skipping the whole creating padding with "A" shenanigans and just straight to creating a pattern so I don't waste my time
So here using python pattern exploit script I generate 5000 random patterns and feed it into "evil.mp3" file
Download the evil.mp3 file and load it inside the program by choosing the "convert" button that has a gear logo on it (in order for the panel to notice your file you need to change the file of type to "Any file")
Once you loaded it go to your immunity debugger again and as you can see we successfully overwrite the EIP
Now we need to find how many offsets we need to overwrite the SEH chain and redirect it to our shellcode. Type "!mona findmsp"
"0x46326846" => "0x46683246" => "Fh2f"
and we got 4116 bytes of offset to need to overwrite the SEH check.
next, you can create script to check the offset right or not like below:
cool we overwrite the SEH check and now all we have to is to use the immunity debugger to find a Ropgadget to be used as a replacement for our SEH chain. Type "!mona seh"
So we got a bunch of results that we can use for the replacement, my tips for you guys is to choose the ROPgadget that have a connection with known .dll this is advantageous to your exploit since it can be used in many versions of windows.
You can check the rest of the SEH entry in "seh" file in immunity debugger folder inside your computer c:/ directory
combine with our script like below and we are able to take control of the program SEH chain.
next, we just need to update the next_seh variable to be "\xeb\x06\x90\x90" since this equivalent to jump 8 bytes and with this instruction, it can reach our payload.
Note: in the middle of analysis I try to use shellcode that open reverse shell connection to my host but due to the problem of the bad character I could not execute my shell and addition I still don't have necessary knowledge to build my own shellcode so I just use shellcode that open a calculator for the POC
update our code to be like this:
run the python script and load the generated file to the program and as you can see it open a calculator program
Here is the catch:
as I promised in the introduction I will show you something that makes you think twice when implementing secure coding. Ok ! so take a look again at the mona log when show EIP, SEH offsetmona log for FREE MP3 CD ripper:
can you spot something wrong?
yeah the EIP is located before the SEH chain not after the SEH chain different from the previous post where SEH chain is located before EIP (DVD X player)
mona log for DVD X player:
so what this is means? the SEH is completely useless lol since we already able to overwrite the EIP before SEH catch exception we can just redirect the program execution to the shellcode
if we try to generate the file using this script:
note: I got the EIP variable value from executing "mona jmp -r esp" like in the first tutorial of breaking code
and load it into the program and also check the stack we can see it is true:
Update the previous script like this and we got the program to call the calculator :D
Lol :D I hope you enjoy this post
the last part is entirely based on my analysis if you think there is a mistake let me know
thank you
hello sir, can you provide the link for Free MP3 CD Ripper 2.8 you tested? Many thanks.
ReplyDeletehttps://www.exploit-db.com/apps/64215b82be8bb2e749f95fec5b51d3e4-FMCRSetup-2.6.exe
Delete