OSCE Exam Practice - Part I (Lab Setup)

May 13, 2020 | 9 minutes read

Tags: osce, windbg, exploit-dev, boofuzz

Other posts in the series:

Obligatory Intro

Howdy! This is the first post in a multi-part series detailing steps taken, and exploits written, as part of my OSCE exam preparation. I intend to use these practice sessions to refine my exploit development process while sharing any knowledge gained.

I originally wanted to take this course a few years ago, but could never quite lock it in. Recently, I was fortunate enough to have work fund the course. Since then, I’ve been spending my free time listening to Muts’ dulcet tones and working through the modules. I wrapped up the official course material yesterday and plan to work through some additional work recommended by some OSCE graduates.

What makes the timing awesome for me is that I just finished up CSC 748 - Software Exploitation for my graduate course work. The course dealt with Windows x86 exploitation, fuzzing, and shellcoding. Sound familiar? It dove into some topics that OSCE doesn’t cover such as using ROP to bypass DEP. I’m incredibly happy to have been able to do both of them one right after the other. I’ll be including some of the shellcoding tricks I learned from the course in this series at some point.

Exploit Development Environment

This post will cover setting up a lab environment. While this may not be the most interesting topic, we’ll cover some setup tips that may be helpful.

Don’t worry, we won’t go step by step through setting up all these things unless it’s warranted.

Operating System

For these practice sessions, we’ll attempt to stick reasonably close to an OSCE environment by using a 32bit Windows 7 VM. Unfortunately, Microsoft has taken down the IE/Edge Virtual Machine images from their site. You can only get the Windows 10 images nowadays. Fear not! If you find yourself in need of an older version, they’re archived and can still be downloaded at the link below.

  1. Windows VM Images

Scripting Language

We’ll be writing all proof of concepts using Python 3. Python 2 still gets a lot of use in PoCs for exploits and exploit-centric tooling, however, I strongly prefer 3 as a language overall and will stick to it throughout these posts.

The latest version of Python (3.8.2 at the time of this writing) can be found here.

Hex Editor

There are times we’ll need a hex editor. I prefer 010 when working on windows.


Part of creating shellcode is janking™ around with the instructions to find what works in the smallest amount of space without known bad characters. nasmshell makes it incredibly easy to check which opcodes are generated by which instructions. Of note, nasmshell requires python2.


For network fuzzing, we’ll be using boofuzz. It’s a fork of and the successor to the venerable Sulley fuzzing framework. Sulley has been the preeminent open source fuzzer for some time, but has fallen out of maintenance. Installation consists of a simple pip command.

1pip install boofuzz --user

Automatic Crash Detection & Process Restart

This part is totally optional. Boofuzz offers a utility called that detects crashes and restarts the target binary automatically. It requires a few additional libraries to run and must run on the target machine itself. As we’ll be doing all coding and fuzzing from the same windows environment, this is fine.

The install steps are located here. I won’t copy and paste them here, however I will note something that I was forced to do during installation. All of the libraries for are installed into my Python2.7 environment. Whereas boofuzz is installed into my Python3.8 environment. This is because pydasm requires Python2.7. The end result is that we’ll be scripting fuzzers in Python3, and executing with Python2.

Also, there is a note on the install page:

Building pydasm on Windows requires the Visual C++ Compiler for Python 2.7

I didn’t need to do anything to satisfy this requirement, as my flare-vm install script pulled it down for me.


The topic of which debugger to use seems to be pretty contentious in the OSCE forums/chats. We’ll be using WinDbg. The reason is that I spent 4 months using it for college and have come to like it.


To install WinDbg (and some other tools), I used the Flare-VM install script. Flare-VM will take a Windows 7-10 machine and install a plethora of RE tools. I modified the flare’s profile.json for a relatively light-weight installer.

  1. Flare-VM install instructions
  2. Customizing Installed Packages

And if you’re feeling lazy, here’s my profile.json.

 2    "env": {
 3        "TOOL_LIST_DIR": "%ProgramData%\\Microsoft\\Windows\\Start Menu\\Programs\\FLARE",
 4        "TOOL_LIST_SHORTCUT": "%UserProfile%\\Desktop\\FLARE.lnk",
 5        "RAW_TOOLS_DIR": "%SystemDrive%\\Tools",
 6        "TEMPLATE_DIR": "flarevm.installer.flare"
 7    },
 8    "packages": [
 9        {"name": "dotnetfx"},
10        {"name": "powershell"},
11        {"name": "vcbuildtools.fireeye"},
12        {"name": "vcpython27"},
13        {
14            "name": "python2.x86.nopath.flare",
15            "x64Only": true,
16            "args": "--package-parameters \'/InstallDir:C:\\Python27.x86\'"
17        },
18        {"name": "libraries.python2.fireeye"},
19        {"name": "libraries.python3.fireeye"},
21        {"name": "windbg.flare"},
22        {"name": "windbg.kenstheme.flare"},
23        {"name": "windbg.ollydumpex.flare"},
24        {"name": "windbg.pykd.flare"},
26        {"name": "ghidra.fireeye"},
27        {"name": "vbdecompiler.flare"},
28        {"name": "010editor.flare"},
29        {"name": "resourcehacker.flare"},
30        {"name": "processdump.fireeye"},
31        {"name": "7zip.flare"},
32        {"name": "putty"},
33        {"name": "wget"},
34        {"name": "processhacker.flare"},
35        {"name": "sysinternals.flare"},
36        {"name": "ncat.flare"},
37        {"name": "shellcode_launcher.flare"},
38        {"name": "xorsearch.flare"},
39        {"name": "xorstrings.flare"},
40        {"name": "lordpe.flare"},
41        {"name": "googlechrome.flare"},
42        {"name": "nasm.fireeye"}
43    ]

Even after using Flare-VM’s installer, we’re still missing a key tool, is an incredible tool; it’s bonkers how many facets of exploit dev on windows are made easier with mona.

To get mona up and running with WinDbg, we’ll just need to follow these steps.

We can confirm everything works by opening up WinDbg, attaching to some benign process, and running the following commands:

1.load pykd.pyd
4Processing initial command '.load pykd.pyd'
 1!py mona
 4[+] Command used:
 5!py C:\Program Files\Windows Kits\10\Debuggers\x86\
 6     'mona' - Exploit Development Swiss Army Knife - WinDBG (32bit)
 7     Plugin version : 2.0 r605
 8     Python version : 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:19:08) [MSC v.1500 32 bit (Intel)]
 9     PyKD version
10     Written by Corelan -
11     Project page :
12    |------------------------------------------------------------------|
13    |        _ __ ___    ___   _ __    __ _     _ __   _   _           |
14    |       | '_ ` _ \  / _ \ | '_ \  / _` |   | '_ \ | | | |          |
15    |       | | | | | || (_) || | | || (_| | _ | |_) || |_| |          |
16    |       |_| |_| |_| \___/ |_| |_| \__,_|(_)| .__/  \__, |          |
17    |                                          |_|     |___/           |
18    |                                                                  |
19    |------------------------------------------------------------------|

SQLite Browser

We’ll need a way to look at boofuzz’s results. They’re stored in a database, and the provided web interface leaves something to be desired. As we’ll be working on windows, we’ll need to grab a sqlite database browser. One can be found here.

WinDbg - Quality of Life Tweaks

We’re going to be spending a ton of time in the debugger, so it should be a debugger that sparks joy!

Automatically Load pykd.pyd

Typing .load pykd.pyd isn’t terribly hard, but doing it every time you restart your debugger can be irksome. We can automatically load the file with a pretty simple trick.

  • right-click on the windbg icon in the toolbar (assuming flare-vm put it there for you)
  • right-click on the windbg (x86) menu item
  • select properties


Once we’re in the properties menu, perform the following

  • click on the Shortcut tab
  • add the following command-line option to the Target field: -c ".load pykd.pyd"


This solution was something like the 7th comment to an unaccepted solution on stack overflow. I’m happy to think that my SO sleuthery will save others time and effort.

Sane Logging Location

Without any configuration, stores command results beside the debugger’s exe. The exe is stored six levels deep under Program Files and isn’t exactly accessible. The command below will get the logging location squared away for us.

1!py mona config -set workingfolder c:\monalogs\%p_%i

The %p will get populated with the debuggee’s name and the %i will be replaced by the debuggee’s pid. Ex. C:\monalogs\TFTPServerSP_1300

Personalized Workspace w/ Scratchpad

You can personalize WinDbg quite a bit. There are a few themes shipped with WinDbg, and some others can be found with google, though it’s not obvious how to work with them. WinDbg will read Workspace settings from the registry or a .wew file. If you’re loading a .reg file, you can simply double-click the file and it will load. However, we’ll be creating our own .wew file.

Create the Layout

We’ll take a look at my setup, which is pretty much default, with a slight modification. I like having WinDbg’s scratchpad open. It’s a convenient place for simple notes (usually addresses/offsets). It’s not open in the default configuration, so let’s fix that.

  1. Open WinDbg
  2. Press alt+8 to open the scratchpad
  3. Position it wherever you like

My setup looks like this, with the scratchpad positioned to the right of the assembly window.


Associate the Scratchpad

If the scratchpad isn’t associated to a file on disk, the information disappears when the debugger exits. Fortunately, making the scratchpad persistent is easy.

First, right-click the scratchpad’s top bar and select Associate with file.... After that, simply pick a location (I store mine in C:\monalogs)


Save the Workspace

With a new layout created, we need to save it to disk. There are four different options to save a workspace… We want to use the Save Workspace to File... option. Store it wherever you like.


Autoload the Workspace

With the scratchpad setup and the workspace file saved somewhere, we need to configure windbg to load the workspace on startup. The premise is the same as what we used to autoload pykd. We just need to add the following command-line option to the Target field in WinDbg’s properties.

-WF "C:\Users\vagrant\Desktop\with_scratchpad.WEW"


Further Configuration

In case you want to go further, you could use some of the themes listed below as a starting point and tweak until you’re content.

Obligatory Outro

The next post in this series will cover exploiting VulnServer’s TRUN command. Check it out here.

comments powered by Disqus