A Quick Guide to Defining Malware with $0, Python3, and Windows
To be blunt: if you've got a bunch of binaries that you know is malware, or suspect is malware, and want to label it appropriately but don't have the ability to get an expensive VirusTotal license (or they don't want to lend you a researcher API key), don't have the ability (or skillset) to setup something like Polish CERT MWDB or Canadian CCCS AssembyLine, or any other reason not listed here, then this tutorial will show you how to ball out on a budget.
Requirements: - Windows (yes, you read that correctly) - Python3 - Malware
Windows Defender comes equipt with a command line interface designed for Enterprise Users (maybe? no idea, just making that up) that allows anyone to do a quick custom scan on a file. The binary is (usually) located in:
C:\Program Files\Windows Defender\MpCmdRun.exeMSDN offers a pretty good guide on how to use the command line interface. If you don't want to read, the tl;dr is the the following command line is absolute gold:
MpCmdRun.exe -Scan -ScanType 3 -File "{full_file_path}" -DisableRemediationThis will scan a file, print the results onto the console, and do nothing thanks to the DisableRemediation flag. It looks like this:

The caveat to this command line argument is the -File flag requires the full path to the file you want to scan.
Anyway, here is some Python 3 code that accepts a directory as an argument. It will programmatically loop through a directory, scan the file, get the output from MpCmdRun.exe, then display the result on the console using a file path friendly definition (more on that later).
When you run it against a directory containing malware, the output will look like this:

Cool beans! If you want it to rename the files using the path friendly output you can use the following code:
Before the script is ran, this is a picture of a directory named "rename_this_malware"

This is the output on the console from the script:

Here is the new file contents in the directory:

Now we ballin' on a budget.
-smelly
Last updated