Originally I wanted to talk about, and work on, building a solution to upload data from a Windows workstation if the only tools available were native to Windows. After an evening of coding I realized I didn’t solve the issue I wanted to, but I did build a fun way to exfiltrate information from a Windows system if that workstation has .NET and PowerShell available.
The original plan for getting data off of a Windows system was to use BITSAdmin to upload files to a web server on the Internet. Instead of looking into using a standard web server (i.e. Apache) to upload files to, I decided to make my own in Python. The rationale behind making my own server was, making a web server in Python sounds cool. After an evening of coding I had a lightweight Python web server for accepting POST requests. All I needed to do was implement the specific logic for reading a BITSAdmin upload request and saving the file. This is where the first problem set in.
I discovered quickly that there was a little more to a BITSAdmin upload request then just a simple POST request. I already developed my upload server to save simple POST requests, so I decided to put BITSAdmin on the back burner and jump into PowerShell/.NET where I knew I could create the HTTP traffic I wanted. Using the System.Net.WebClient package I was able to send a simple POST request that contains binary data to my upload server.
Using Wireshark as a guide for how the HTTP request were being formed and transmitted, I completed the POST handler in the server. The upload server is a simple Python script that accepts a multi-part/formdata POST request and saves it to a file.
Reaching the end of this weekend project I am left with two reflections. First, this was my first experience working with the BaseHTTPServer in Python and I enjoyed it. Second, when I work on a project in the future I need to do a better job at solving the problem I came to solve. Now that I have a better understanding of how to work with an HTTP request in Python I look forward to completing my original goal of creating a Python server for BITSAdmin to upload to.