z3v2cicidi / Invoke-Obfuscation

PowerShell Obfuscator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invoke-Obfuscation v1.3

Introduction

Invoke-Obfuscation is a PowerShell v2.0+ compatible PowerShell command and script obfuscator.

Background

In the Fall of 2015 I decided to begin researching the flexibility of PowerShell's language and began cataloguing the various ways to accomplish a handful of common techniques that most attackers use on a regular basis.

Initially focusing on encoded command and remote download cradle syntaxes, I discovered that various escape characters that did not hinder the execution of the command persisted in the command line arguments, both in the running process as well as what is logged in Security EID 4688 and Sysmon EID 1 event logs. This led me to systematically explore ways of obfuscating each kind of "token" found in any PowerShell command or script.

I then explored more obscure ways to perform string-level obfuscation, various encoding/encrypting techniques (like ASCII/hex/octal/binary and even SecureString), and finally PowerShell launch techniques to abstract the command line arguments from powershell.exe and to push it back to the parent and even grandparent process.

Purpose

Attackers and commodity malware have started using extremely basic obfuscation techniques to hide the majority of the command from the command line arguments of powershell.exe. I developed this tool to aid the Blue Team in simulating obfuscated commands based on what I currently know to be syntactically possible in PowerShell 2.0-5.0 so that they can test their detection capabilities of these techniques.

The tool's sole purpose is to break any assumptions that we as defenders may have concerning how PowerShell commands can appear on the command line. My hope is that it will encourage the Blue Team to shift to looking for Indicators of Obfuscation on the command line in addition to updating PowerShell logging to include Module, ScriptBlock and Transcription logging as these sources simplify most aspects of the obfuscation techniques generated by this tool.

Usage

While all of the layers of obfuscation have been built out into separate scripts, most users will find the Invoke-Obfuscation function to be the easiest way to explorer and visualize the obfuscation techniques that this framework currently supports.

Installation

The source code for Invoke-Obfuscation is hosted at Github, and you may download, fork and review it from this repository (https://github.com/danielbohannon/Invoke-Obfuscation). Please report issues or feature requests through Github's bug tracker associated with this project.

To install:

Import-Module ./Invoke-Obfuscation.psm1
Invoke-Obfuscation

License

Invoke-Obfuscation is released under the Apache 2.0 license.

Release Notes

v1.0 - 2016-09-25 DerbyCon 6.0, Louisville: PUBLIC Release of Invoke-Obfuscation

v1.1 - 2016-10-09 SANS DFIR Summit, Prague: Added -f format operator re-ordering functionality to all applicable Token obfuscation functions. Also added additional syntax options for setting variable values.

v1.2 - 2016-10-20 Code Blue, Tokyo: Added Type token obfuscation (direct type casting with string obfuscation options for type name).

v1.3 - 2016-10-22 Hacktivity, Budapest: Added two new LAUNCHER techniques: CLIP+ and CLIP++. Also added additional (and simpler) array char conversion syntax for all ENCODING functions that does not require For-EachObject/%.

About

PowerShell Obfuscator

License:Apache License 2.0


Languages

Language:PowerShell 100.0%