ProtectMyTooling | Multi-Packer Wrapper Letting Us Daisy-Chain Various Packers, Obfuscators And Other Red Team Oriented Weaponry

1.png

Don’t Detect Tools - Detect Techniques

Rationale behind releasing this software was outlined in an acompanying blog post:

Intro

Script that wraps around multitude of packers, protectors, obfuscators, shellcode loaders, encoders, generators to produce complex protected Red Team implants. Your perfect companion in Malware Development CI/CD pipeline, helping watermark your artifacts, collect IOCs, backdoor and more.

ProtectMyToolingGUI.py

3.png

With ProtectMyTooling you can quickly obfuscate your binaries without having to worry about clicking through all the Dialogs, interfaces, menus, creating projects to obfuscate a single binary, clicking through all the options available and wasting time about all that nonsense. It takes you straight to the point - to obfuscate your tool.

Aim is to offer the most convenient interface possible and allow to leverage a daisy-chain of multiple packers combined on a single binary.

That’s right - we can launch ProtectMyTooling with several packers at once:

C:\> py ProtectMyTooling.py hyperion,upx mimikatz.exe mimikatz-obf.exe

The above example will firstly pass mimikatz.exe to the Hyperion for obfuscation, and then the result will be provided to UPX for compression. Resulting with UPX(Hyperion(file))

Features

  • Supports multiple different PE Packers, .NET Obfuscators, Shellcode Loaders/Builders
  • Allows daisy-chaining packers where output from a packer is passed to the consecutive one: callobf,hyperion,upx will produce artifact UPX(Hyperion(CallObf(file)))
  • Collects IOCs at every obfuscation step so that auditing & Blue Team requests can be satisfied
  • Offers functionality to inject custom Watermarks to resulting PE artifacts - in DOS Stub, Checksum, as a standalone PE Section, to file’s Overlay
  • Comes up with a handy Cobalt Strike aggressor script bringing protected-upload and protected-execute-assembly commands
  • Straightforward command line usage

Installation

This tool was designed to work on Windows, as most packers natively target that platform.

Some features may work however on Linux just fine, nonetheless that support is not fully tested, please report bugs and issues.

  1. First, disable your AV and add contrib directory to exclusions. That directory contains obfuscators, protectors which will get flagged by AV and removed.
  2. Then clone this repository
PS C:\> git clone --recurse https://github.com/Binary-Offensive/ProtectMyTooling
  1. Actual installation is straightforward:

Windows

PS C:\ProtectMyTooling> .\install.ps1

Linux

bash# ./install.sh

Gimmicks

For ScareCrow packer to run on Windows 10, there needs to be WSL installed and bash.exe available (in %PATH%). Then, in WSL one needs to have golang installed in version at least 1.16:

cmd> bash
bash$ sudo apt update ; sudo apt upgrade -y ; sudo apt install golang=2:1.18~3 -y

Configuration

To plug-in supported obfuscators, change default options or point ProtectMyTooling to your obfuscator executable path, you will need to adjust config\ProtectMyTooling.yaml configuration file.

There is also config\sample-full-config.yaml file containing all the available options for all the supported packers, serving as reference point.

Friendly reminder

  • If your produced binary crashes or doesn’t run as expected - try using different packers chain.
  • Packers don’t guarantee stability of produced binaries, therefore ProtectMyTooling cannot as well.
  • While chaining, carefully match output->input payload formats according to what consecutive packer expects.

Usage

Before ProtectMyTooling’s first use, it is essential to adjust program’s YAML configuration file ProtectMyTooling.yaml. The order of parameters processal is following:

  • Firstly default parameters are used
  • Then they’re overwritten by values coming from YAML
  • Finally, whatever is provided in command line will overwrite corresponding values

There, supported packer paths and options shall be set to enable.

Scenario 1: Simple ConfuserEx obfuscation

Usage is very simple, all it takes is to pass the name of obfuscator to choose, input and output file paths:

C:\> py ProtectMyTooling.py confuserex Rubeus.exe Rubeus-obf.exe

    ::::::::::.:::::::..      ...  :::::::::::.,::::::  .,-::::::::::::::::
     `;;;```.;;;;;;``;;;;  .;;;;;;;;;;;;;;;\''';;;;\'\''',;;;'````;;;;;;;;\'\'''
      `]]nnn]]' [[[,/[[[' ,[[     \[[,  [[     [[cccc [[[           [[
       $$""    $$$c   $$,     $$  $     $"""" $$           $
       888o     888b "88bo"888,_ _,88P  88,    888oo,_`88bo,__,o,   88,
    .  YMMMb :.-:.MM   ::-. "YMMMMMP"   MMM    """"YUMMM"YUMMMMMP"  MMM
    ;;,.    ;;;';;.   ;;;;'
    [[[[, ,[[[[, '[[,[[['
    $$$$"$$   c$"
    888 Y88" 888o,8P"`
    ::::::::::::mM...        ...     :::    :::::.    :::. .,-:::::/
    ;;;;;;;;\'''.;;;;;;;.  .;;;;;;;.  ;;;    ;;`;;;;,  `;;,;;-'````'
         [[   ,[[     \[[,[[     \[[,[[[    [[[ [[[[[. '[[[[   [[[[[[/
         $   $$,     $$$,     $$

Scenario 2: Simple ConfuserEx obfuscation followed by artifact test

One can also obfuscate the file and immediately attempt to launch it (also with supplied optional parameters) to ensure it runs fine with options -r --cmdline CMDLINE:

C:\> py ProtectMyTooling.py confuserex Rubeus.exe Rubeus-obf.exe -r --cmdline "hash /password:foobar"

    [...]

[.] Processing x86 file: "\Rubeus.exe"
[.] Generating output of ConfuserEx(<file>)...

[+] SUCCEEDED. Original file size: 417280 bytes, new file size ConfuserEx(<file>): 758272, ratio: 181.72%


Running application to test it...

   ______        _
  (_____ \      | |
   _____) )_   _| |__  _____ _   _  ___
  |  __  /| | | |  _ \| ___ | | | |/___)
  | |  \ \| |_| | |_) ) ____| |_| |___ |
  |_|   |_|____/|____/|_____)____/(___/

  v2.0.0


[*] Action: Calculate Password Hash(es)

[*] Input password             : foobar
[*]       rc4_hmac             : BAAC3929FABC9E6DCD32421BA94A84D4

[!] /user:X and /domain:Y need to be supplied to calculate AES and DES hash types!

Scenario 3: Complex malware obfuscation with watermarking and IOCs collection

Below use case takes beacon.exe on input and feeds it consecutively into CallObfUPXHyperion packers.

Then it will inject specified fooobar watermark to the final generated output artifact’s DOS Stub as well as modify that artifact’s checksum with value 0xAABBCCDD.

Finally, ProtectMyTooling will capture all IOCs (md5, sha1, sha256, imphash, and other metadata) and save them in auxiliary CSV file. That file can be used for IOC matching as engagement unfolds.

PS> py .\ProtectMyTooling.py callobf,upx,hyperion beacon.exe beacon-obf.exe -i -I operation_chimera -w dos-stub=fooobar -w checksum=0xaabbccdd

    [...]

[.] Processing x64 file: "beacon.exe"
[>] Generating output of CallObf(<file>)...

[.] Before obfuscation file's PE IMPHASH:       17b461a082950fc6332228572138b80c
[.] After obfuscation file's PE IMPHASH:        378d9692fe91eb54206e98c224a25f43
[>] Generating output of UPX(CallObf(<file>))...

[>] Generating output of Hyperion(UPX(CallObf(<file>)))...

[+] Setting PE checksum to 2864434397 (0xaabbccdd)
[+] Successfully watermarked resulting artifact file.
[+] IOCs written to: beacon-obf-ioc.csv

[+] SUCCEEDED. Original file size: 288256 bytes, new file size Hyperion(UPX(CallObf(<file>))): 175616, ratio: 60.92%

Produced IOCs evidence CSV file will look as follows:

timestamp,filename,author,context,comment,md5,sha1,sha256,imphash
2022-06-10 03:15:52,beacon.exe,[email protected],Input File,test,dcd6e13754ee753928744e27e98abd16,298de19d4a987d87ac83f5d2d78338121ddb3cb7,0a64768c46831d98c5667d26dc731408a5871accefd38806b2709c66cd9d21e4,17b461a082950fc6332228572138b80c
2022-06-10 03:15:52,y49981l3.bin,[email protected],Obfuscation artifact: CallObf(<file>),test,50bbce4c3cc928e274ba15bff0795a8c,15bde0d7fbba1841f7433510fa9aa829f8441aeb,e216cd8205f13a5e3c5320ba7fb88a3dbb6f53ee8490aa8b4e1baf2c6684d27b,378d9692fe91eb54206e98c224a25f43
2022-06-10 03:15:53,nyu2rbyx.bin,[email protected],Obfuscation artifact: UPX(CallObf(<file>)),test,4d3584f10084cded5c6da7a63d42f758,e4966576bdb67e389ab1562e24079ba9bd565d32,97ba4b17c9bd9c12c06c7ac2dc17428d509b64fc8ca9e88ee2de02c36532be10,9aebf3da4677af9275c461261e5abde3
2022-06-10 03:15:53,beacon-obf.exe,[email protected],Obfuscation artifact: Hyperion(UPX(CallObf(<file>))),test,8b706ff39dd4c8f2b031c8fa6e3c25f5,c64aad468b1ecadada3557cb3f6371e899d59790,087c6353279eb5cf04715ef096a18f83ef8184aa52bc1d5884e33980028bc365,a46ea633057f9600559d5c6b328bf83d
2022-06-10 03:15:53,beacon-obf.exe,[email protected],Output obfuscated artifact,test,043318125c60d36e0b745fd38582c0b8,a7717d1c47cbcdf872101bd488e53b8482202f7f,b3cf4311d249d4a981eb17a33c9b89eff656fff239e0d7bb044074018ec00e20,a46ea633057f9600559d5c6b328bf83d

Supported Packers

ProtectMyTooling was designed to support not only Obfuscators/Packers but also all sort of builders/generators/shellcode loaders usable from the command line.

At the moment, program supports various Commercial and Open-Source packers/obfuscators. Those Open-Source ones are bundled within the project. Commercial ones will require user to purchase the product and configure its location in ProtectMyTooling.yaml file to point the script where to find them.

  1. Amber - Reflective PE Packer that takes EXE/DLL on input and produces EXE/PIC shellcode
  2. AtomPePacker - A Highly capable Pe Packer
  3. AsStrongAsFuck - A console obfuscator for .NET assemblies by Charterino
  4. CallObfuscator - Obfuscates specific windows apis with different apis.
  5. ConfuserEx - Popular .NET obfuscator, forked from Martin Karing
  6. Donut - Popular PE loader that takes EXE/DLL/.NET on input and produces a PIC shellcode
  7. Enigma - A powerful system designed for comprehensive protection of executable files
  8. Hyperion - runtime encrypter for 32-bit and 64-bit portable executables. It is a reference implementation and bases on the paper “Hyperion: Implementation of a PE-Crypter”
  9. IntelliLock - combines strong license security, highly adaptable licensing functionality/schema with reliable assembly protection
  10. InvObf - Obfuscates Powershell scripts with Invoke-Obfuscation (by Daniell Bohannon)
  11. LoGiC.NET - A more advanced free and open .NET obfuscator using dnlib by AnErrupTion
  12. Mangle - Takes input EXE/DLL file and produces output one with cloned certificate, removed Golang-specific IoCs and bloated size. By Matt Eidelberg (@Tyl0us).
  13. MPRESS - MPRESS compressor by Vitaly Evseenko. Takes input EXE/DLL/.NET/MAC-DARWIN (x86/x64) and compresses it.
  14. NetReactor - Unmatched .NET code protection system which completely stops anyone from decompiling your code
  15. NetShrink - an exe packer aka executable compressor, application password protector and virtual DLL binder for Windows & Linux .NET applications.
  16. Nimcrypt2 - Generates Nim loader running input .NET, PE or Raw Shellcode. Authored by (@icyguider)
  17. NimPackt-v1 - Takes Shellcode or .NET Executable on input, produces EXE or DLL loader. Brought to you by Cas van Cooten (@chvancooten)
  18. NimSyscallPacker - Takes PE/Shellcode/.NET executable and generates robust Nim+Syscalls EXE/DLL loader. Sponsorware authored by (@S3cur3Th1sSh1t)
  19. Packer64 - wrapper around John Adams’ Packer64
  20. pe2shc - Converts PE into a shellcode. By yours truly @hasherezade
  21. peCloak - A Multi-Pass Encoder & Heuristic Sandbox Bypass AV Evasion Tool
  22. peresed - Uses “peresed” from avast/pe_tools to remove all existing PE Resources and signature (think of Mimikatz icon).
  23. ScareCrow - EDR-evasive x64 shellcode loader that produces DLL/CPL/XLL/JScript/HTA artifact loader
  24. sgn - Shikata ga nai (仕方がない) encoder ported into go with several improvements. Takes shellcode, produces encoded shellcode
  25. SmartAssembly - obfuscator that helps protect your application against reverse-engineering or modification, by making it difficult for a third-party to access your source code
  26. sRDI - Convert DLLs to position independent shellcode. Authored by: Nick Landers, @monoxgas
  27. Themida - Advanced Windows software protection system
  28. UPX - a free, portable, extendable, high-performance executable packer for several executable formats.
  29. VMProtect - protects code by executing it on a virtual machine with non-standard architecture that makes it extremely difficult to analyze and crack the software

You can quickly list supported packers using -L option (table columns are chosen depending on Terminal width, the wider the more information revealed):

C:\> py ProtectMyTooling.py -L
    [...]

    Red Team implants protection swiss knife.

    Multi-Packer wrapping around multitude of packers, protectors, shellcode loaders, encoders.
    Mariusz Banach / mgeeky '20-'22, <[email protected]>
    v0.16

+----+----------------+-------------+-----------------------+-----------------------------+------------------------+--------------------------------------------------------+
| #  |      Name      |     Type    |       Licensing       |            Input            |         Output         |                         Author                         |
+----+----------------+-------------+-----------------------+-----------------------------+------------------------+--------------------------------------------------------+
| 1  |     amber      | open-source |    Shellcode Loader   |              PE             |     EXE, Shellcode     |                       Ege Balci                        |
| 2  | asstrongasfuck | open-source |    .NET Obfuscator    |             .NET            |          .NET          |                 Charterino, klezVirus                  |
| 3  |  atompepacker  | open-source |  PE EXE/DLL Protector |              PE             |        EXE, DLL        |            ORCA (@ORCx41, [email protected])            |
| 4  |    backdoor    | open-source |    Shellcode Loader   |          Shellcode          |           PE           |              Mariusz Banach, @mariuszbit               |
| 5  |    callobf     | open-source |  PE EXE/DLL Protector |              PE             |           PE           |                Mustafa Mahmoud, @d35ha                 |
| 6  |   confuserex   | open-source |    .NET Obfuscator    |             .NET            |          .NET          |                        mkaring                         |
| 7  |  donut-packer  | open-source |  Shellcode Converter  | PE, .NET, VBScript, JScript |       Shellcode        |                        TheWover                        |
| 8  |     enigma     |  commercial |  PE EXE/DLL Protector |              PE             |           PE           |          The Enigma Protector Developers Team          |
| 9  |    hyperion    | open-source |  PE EXE/DLL Protector |              PE             |           PE           |                   nullsecurity team                    |
| 10 |  intellilock   |  commercial |    .NET Obfuscator    |              PE             |           PE           |                         Eziriz                         |
| 11 |     invobf     | open-source | Powershell Obfuscator |          Powershell         |       Powershell       |                    Daniel Bohannon                     |
| 12 |    logicnet    | open-source |    .NET Obfuscator    |             .NET            |          .NET          |                 AnErrupTion, klezVirus                 |
| 13 |     mangle     | open-source |   Executable Signing  |              PE             |           PE           |                Matt Eidelberg (@Tyl0us)                |
| 14 |     mpress     |   freeware  | PE EXE/DLL Compressor |              PE             |           PE           |                    Vitaly Evseenko                     |
| 15 |   netreactor   |  commercial |    .NET Obfuscator    |             .NET            |          .NET          |                         Eziriz                         |
| 16 |   netshrink    | open-source |    .NET Obfuscator    |             .NET            |          .NET          |                     Bartosz Wójcik                     |
| 17 |   nimcrypt2    | open-source |    Shellcode Loader   |     PE, .NET, Shellcode     |           PE           |                       @icyguider                       |
| 18 |    nimpackt    | open-source |    Shellcode Loader   |       .NET, Shellcode       |           PE           |             Cas van Cooten (@chvancooten)              |
| 19 |   nimsyscall   | sponsorware |    Shellcode Loader   |     PE, .NET, Shellcode     |           PE           |                    @S3cur3Th1sSh1t                     |
| 20 |    packer64    | open-source | PE EXE/DLL Compressor |              PE             |           PE           |                  John Adams, @jadams                   |
| 21 |     pe2shc     | open-source |  Shellcode Converter  |              PE             |       Shellcode        |                      @hasherezade                      |
| 22 |    pecloak     | open-source |  PE EXE/DLL Protector |              PE             |           PE           |     Mike Czumak, @SecuritySift, buherator / v-p-b      |
| 23 |    peresed     | open-source |  PE EXE/DLL Protector |              PE             |           PE           |                  Martin Vejnár, Avast                  |
| 24 |   scarecrow    | open-source |    Shellcode Loader   |          Shellcode          | DLL, JScript, CPL, XLL |                Matt Eidelberg (@Tyl0us)                |
| 25 |      sgn       | open-source |   Shellcode Encoder   |          Shellcode          |       Shellcode        |                       Ege Balci                        |
| 26 | smartassembly  |  commercial |    .NET Obfuscator    |             .NET            |          .NET          |                        Red-Gate                        |
| 27 |      srdi      | open-source |   Shellcode Encoder   |             DLL             |       Shellcode        |                Nick Landers, @monoxgas                 |
| 28 |    themida     |  commercial |  PE EXE/DLL Protector |              PE             |           PE           |                         Oreans                         |
| 29 |      upx       | open-source | PE EXE/DLL Compressor |              PE             |           PE           | Markus F.X.J. Oberhumer, László Molnár, John F. Reiser |
| 30 |   vmprotect    |  commercial |  PE EXE/DLL Protector |              PE             |           PE           |                        vmpsoft                         |
+----+----------------+-------------+-----------------------+-----------------------------+------------------------+--------------------------------------------------------+

Above are the packers that are supported, but that doesn’t mean that you have them configured and ready to use. To prepare their usage, you must first supply necessary binaries to the contrib directory and then configure your YAML file accordingly.

RedWatermarker - built-in Artifact watermarking

Artifact watermarking & IOC collection

This program is intended for professional Red Teams and is perfect to be used in a typical implant-development CI/CD pipeline. As a red teamer I’m always expected to deliver decent quality list of IOCs matching back to all of my implants as well as I find it essential to watermark all my implants for bookkeeping, attribution and traceability purposes.

To accommodate these requirements, ProtectMyTooling brings basic support for them.

Artifact Watermarking

ProtectMyTooling can apply watermarks after obfuscation rounds simply by using --watermark option.:

py ProtectMyTooling [...] -w dos-stub=fooooobar -w checksum=0xaabbccdd -w section=.coco,ALLYOURBASEAREBELONG

There is also a standalone approach, included in RedWatermarker.py script.

It takes executable artifact on input and accepts few parameters denoting where to inject a watermark and what value shall be inserted.

Example run will set PE Checksum to 0xAABBCCDD, inserts foooobar to PE file’s DOS Stub (bytes containing This program cannot be run…), appends bazbazbaz to file’s overlay and then create a new PE section named .coco append it to the end of file and fill that section with preset marker.

py RedWatermarker.py beacon-obf.exe -c 0xaabbccdd -t fooooobar -e bazbazbaz -s .coco,ALLYOURBASEAREBELONG

Full watermarker usage:

cmd> py RedWatermarker.py --help

                      ;
                      ED.
                     ,E#Wi
  j.               f#iE###G.
  EW,            .E#t E#fD#W;
  E##j          i#W,  E#t t##L
  E###D.       L#D.   E#t  .E#K,
  E#jG#W;    :K#Wfff; E#t    j##f
  E#t t##f   i##WLLLLtE#t    :E#K:
  E#t  :K#E:  .E#L    E#t   t##L
  E#KDDDD###i   f#E:  E#t .D#W;                  ,;                                                      G:              ,;
  E#f,t#Wi,,,    ,WW; E#tiW#G.                 f#i j.                                          j.        E#,    :      f#i j.
  E#t  ;#W: ;     .D#;E#K##i .. GEEEEEEEL    .E#t  EW,                 ..       :           .. EW,       E#t  .GE    .E#t  EW,
  DWi   ,K.DL       ttE##D. ;W, ,;;L#K;;.   i#W,   E##j               ,W,     .Et          ;W, E##j      E#t j#K;   i#W,   E##j
  f.     :K#L     LWL E#t  j##,    t#E     L#D.    E###D.            t##,    ,W#t         j##, E###D.    E#GK#f    L#D.    E###D.
  EW:   ;W##L   .E#f  L:  G###,    t#E   :K#Wfff;  E#jG#W;          L###,   j###t        G###, E#jG#W;   E##D.   :K#Wfff;  E#jG#W;
  E#t  t#KE#L  ,W#;     :E####,    t#E   i##WLLLLt E#t t##f       .E#j##,  G#fE#t      :E####, E#t t##f  E##Wi   i##WLLLLt E#t t##f
  E#t f#D.L#L t#K:     ;W#DG##,    t#E    .E#L     E#t  :K#E:    ;WW; ##,:K#i E#t     ;W#DG##, E#t  :K#E:E#jL#D:  .E#L     E#t  :K#E:
  E#jG#f  L#LL#G      j###DW##,    t#E      f#E:   E#KDDDD###i  j#E.  ##f#W,  E#t    j###DW##, E#KDDDD###E#t ,K#j   f#E:   E#KDDDD###i
  E###;   L###j      G##i,,G##,    t#E       ,WW;  E#f,t#Wi,,,.D#L    ###K:   E#t   G##i,,G##, E#f,t#Wi,,E#t   jD    ,WW;  E#f,t#Wi,,,
  E#K:    L#W;     :K#K:   L##,    t#E        .D#; E#t  ;#W: :K#t     ##D.    E#t :K#K:   L##, E#t  ;#W: j#t          .D#; E#t  ;#W:
  EG      LE.     ;##D.    L##,     fE          tt DWi   ,KK:...      #G      .. ;##D.    L##, DWi   ,KK: ,;            tt DWi   ,KK:
  ;       ;@      ,,,      .,,       :                                j          ,,,      .,,


    Watermark thy implants, track them in VirusTotal
    Mariusz Banach / mgeeky '22, (@mariuszbit)
    <[email protected]>

usage: RedWatermarker.py [options] <infile>

options:
  -h, --help            show this help message and exit

Required arguments:
  infile                Input implant file

Optional arguments:
  -C, --check           Do not actually inject watermark. Check input file if it contains specified watermarks.
  -v, --verbose         Verbose mode.
  -d, --debug           Debug mode.
  -o PATH, --outfile PATH
                        Path where to save output file with watermark injected. If not given, will modify infile.

PE Executables Watermarking:
  -t STR, --dos-stub STR
                        Insert watermark into PE DOS Stub (This program cannot be run...).
  -c NUM, --checksum NUM
                        Preset PE checksum with this value (4 bytes). Must be number. Can start with 0x for hex value.
  -e STR, --overlay STR
                        Append watermark to the file's Overlay (at the end of the file).
  -s NAME,STR, --section NAME,STR
                        Append a new PE section named NAME and insert watermark there. Section name must be shorter than 8 characters. Section will be marked Read-Only, non-executable.

Currently only PE files watermarking is supported, but in the future Office documents and other formats are to be added as well.

IOCs Collection

IOCs may be collected by simply using -i option in ProtectMyTooling run.

They’re being collected at the following phases:

  • on the input file
  • after each obfuscation round on an intermediary file
  • on the final output file

They will contain following fields saved in form of a CSV file:

  • timestamp
  • filename
  • author - formed as [email protected]
  • context - whether a record points to an input, output or intermediary file
  • comment - value adjusted by the user through -I value option
  • md5
  • sha1
  • sha256
  • imphash - PE Imports Hash, if available
  • (TODO) typeref_hash - .NET TypeRef Hash, if available

Resulting will be a CSV file named outfile-ioc.csv stored side by side to generated output artifact. That file is written in APPEND mode, meaning it will receive all subsequent IOCs.

RedBackdoorer - built-in PE Backdooring

ProtectMyTooling utilizes my own RedBackdoorer.py script which provides few methods for backdooring PE executables. Support comes as a dedicated packer named backdoor. Example usage:

Takes Cobalt Strike shellcode on input and encodes with SGN (Shikata Ga-Nai) then backdoors SysInternals DbgView64.exe then produces Amber EXE reflective loader

PS> py ProtectMyTooling.py sgn,backdoor,amber beacon64.bin dbgview64-infected.exe -B dbgview64.exe

    ::::::::::.:::::::..      ...  :::::::::::.,::::::  .,-::::::::::::::::
     `;;;```.;;;;;;``;;;;  .;;;;;;;;;;;;;;;;;;;,;;;'````;;;;;;;;
      `]]nnn]]' [[[,/[[[' ,[[     \[[,  [[     [[cccc [[[           [[
       $$""    $$$c   $$,     $$  $     $"""" $$           $
       888o     888b "88bo"888,_ _,88P  88,    888oo,_`88bo,__,o,   88,
    .  YMMMb :.-:.MM   ::-. "YMMMMMP"   MMM    """"YUMMM"YUMMMMMP"  MMM
    ;;,.    ;;;';;.   ;;;;'
    [[[[, ,[[[[, '[[,[[['
    $$$$"$$   c$"
    888 Y88" 888o,8P"`
    ::::::::::::mM...        ...     :::    :::::.    :::. .,-:::::/
    ;;;;;;;;.;;;;;;;.  .;;;;;;;.  ;;;    ;;`;;;;,  `;;,;;-'````'
         [[   ,[[     \[[,[[     \[[,[[[    [[[ [[[[[. '[[[[   [[[[[[/
         $   $$,     $$$,     $$

Full RedBackdoorer usage:

cmd> py RedBackdoorer.py --help

     ██▀███ ▓█████▓█████▄
    ▓██ ▒ ██▓█   ▀▒██▀ ██▌
    ▓██ ░▄█ ▒███  ░██   █▌
    ▒██▀▀█▄ ▒▓█  ▄░▓█▄   ▌
    ░██▓ ▒██░▒████░▒████▓
    ░ ▒▓ ░▒▓░░ ▒░ ░▒▒▓  ▒
      ░▒ ░ ▒░░ ░  ░░ ▒  ▒
      ░░   ░   ░   ░ ░  ░
     ▄▄▄▄   ▄▄▄░  ░  ▄████▄  ██ ▄█▓█████▄ ▒█████  ▒█████  ██▀███ ▓█████ ██▀███
    ▓█████▄▒████▄  ░▒██▀ ▀█  ██▄█▒▒██▀ ██▒██▒  ██▒██▒  ██▓██ ▒ ██▓█   ▀▓██ ▒ ██▒
    ▒██▒ ▄█▒██  ▀█▄ ▒▓█    ▄▓███▄░░██   █▒██░  ██▒██░  ██▓██ ░▄█ ▒███  ▓██ ░▄█ ▒
    ▒██░█▀ ░██▄▄▄▄██▒▓▓▄ ▄██▓██ █▄░▓█▄   ▒██   ██▒██   ██▒██▀▀█▄ ▒▓█  ▄▒██▀▀█▄
    ░▓█  ▀█▓▓█   ▓██▒ ▓███▀ ▒██▒ █░▒████▓░ ████▓▒░ ████▓▒░██▓ ▒██░▒████░██▓ ▒██▒
    ░▒▓███▀▒▒▒   ▓▒█░ ░▒ ▒  ▒ ▒▒ ▓▒▒▒▓  ▒░ ▒░▒░▒░░ ▒░▒░▒░░ ▒▓ ░▒▓░░ ▒░ ░ ▒▓ ░▒▓░
    ▒░▒   ░  ▒   ▒▒ ░ ░  ▒  ░ ░▒ ▒░░ ▒  ▒  ░ ▒ ▒░  ░ ▒ ▒░  ░▒ ░ ▒░░ ░  ░ ░▒ ░ ▒░
     ░    ░  ░   ▒  ░       ░ ░░ ░ ░ ░  ░░ ░ ░ ▒ ░ ░ ░ ▒   ░░   ░   ░    ░░   ░
     ░           ░  ░ ░     ░  ░     ░       ░ ░     ░ ░    ░       ░  ░  ░
          ░         ░              ░


    Your finest PE backdooring companion.
    Mariusz Banach / mgeeky '22, (@mariuszbit)
    <[email protected]>

usage: RedBackdoorer.py [options] <mode> <shellcode> <infile>

options:
  -h, --help            show this help message and exit

Required arguments:
  mode                  PE Injection mode, see help epilog for more details.
  shellcode             Input shellcode file
  infile                PE file to backdoor

Optional arguments:
  -o PATH, --outfile PATH
                        Path where to save output file with watermark injected. If not given, will modify infile.
  -v, --verbose         Verbose mode.

Backdooring options:
  -n NAME, --section-name NAME
                        If shellcode is to be injected into a new PE section, define that section name. Section name must not be longer than 7 characters. Default: .qcsw
  -i IOC, --ioc IOC     Append IOC watermark to injected shellcode to facilitate implant tracking.

Authenticode signature options:
  -r, --remove-signature
                        Remove PE Authenticode digital signature since its going to be invalidated anyway.

------------------

PE Backdooring <mode> consists of two comma-separated options.
First one denotes where to store shellcode, second how to run it:

<mode>

    save,run
      |   |
      |   +---------- 1 - change AddressOfEntryPoint
      |               2 - hijack branching instruction at Original Entry Point (jmp, call, ...)
      |               3 - setup TLS callback
      |
      +-------------- 1 - store shellcode in the middle of a code section
                      2 - append shellcode to the PE file in a new PE section
Example:

    py RedBackdoorer.py 1,2 beacon.bin putty.exe putty-infected.exe

Cobalt Strike Integration

There is also a script that integrates ProtectMyTooling.py used as a wrapper around configured PE/.NET Packers/Protectors in order to easily transform input executables into their protected and compressed output forms and then upload or use them from within CobaltStrike.

The idea is to have an automated process of protecting all of the uploaded binaries or .NET assemblies used by execute-assembly and forget about protecting or obfuscating them manually before each usage. The added benefit of an automated approach to transform executables is the ability to have the same executable protected each time it’s used, resulting in unique samples launched on target machines. That should nicely deceive EDR/AV enterprise-wide IOC sweeps while looking for the same artefact on different machines.

Additionally, the protected-execute-assembly command has the ability to look for assemblies of which only name were given in a preconfigured assemblies directory (set in dotnet_assemblies_directory setting).

To use it:

  1. Load CobaltStrike/ProtectMyTooling.cna in your Cobalt Strike.
  2. Go to the menu and setup all the options

options

  1. Then in your Beacon’s console you’ll have following commands available:
  • protected-execute-assembly - Executes a local, previously protected and compressed .NET program in-memory on target.
  • protected-upload - Takes an input file, protects it if its PE executable and then uploads that file to specified remote location.

Basically these commands will open input files, pass the firstly to the CobaltStrike/cobaltProtectMyTooling.py script, which in turn calls out to ProtectMyTooling.py. As soon as the binary gets obfuscated, it will be passed to your beacon for execution/uploading.

Cobalt Strike related Options

Here’s a list of options required by the Cobalt Strike integrator:

  • python3_interpreter_path - Specify a path to Python3 interpreter executable
  • protect_my_tooling_dir - Specify a path to ProtectMyTooling main directory
  • protect_my_tooling_config - Specify a path to ProtectMyTooling configuration file with various packers options
  • dotnet_assemblies_directory - Specify local path .NET assemblies should be looked for if not found by execute-assembly
  • cache_protected_executables - Enable to cache already protected executables and reuse them when needed
  • protected_executables_cache_dir - Specify a path to a directory that should store cached protected executables
  • default_exe_x86_packers_chain - Native x86 EXE executables protectors/packers chain
  • default_exe_x64_packers_chain - Native x64 EXE executables protectors/packers chain
  • default_dll_x86_packers_chain - Native x86 DLL executables protectors/packers chain
  • default_dll_x64_packers_chain - Native x64 DLL executables protectors/packers chain
  • default_dotnet_packers_chain - .NET executables protectors/packers chain

Known Issues

  • ScareCrow is very tricky to run from Windows. What worked for me is following:
    1. Run on Windows 10 and have WSL installed (bash.exe command available in Windows)
    2. Have golang installed in WSL at version 1.16+ (tested on 1.18)
    3. Make sure to have PackerScareCrow.Run_ScareCrow_On_Windows_As_WSL = True set

Credits due & used technology

  • All packer, obfuscator, converter, loader credits goes to their authors. This tool is merely a wrapper around their technology!
    • Hopefully none of them mind me adding such wrappers. Should there be concerns - please reach out to me.
  • ProtectMyTooling also uses denim.exe by moloch– by some Nim-based packers.

TODO

  • Write custom PE injector and offer it as a “protector”
  • Add watermarking to other file formats such as Office documents, WSH scripts (VBS, JS, HTA) and containers
  • Add support for a few other Packers/Loaders/Generators in upcoming future:

Disclaimer

Use of this tool as well as any other projects I’m author of for illegal purposes, unsolicited hacking, cyber-espionage is strictly prohibited. This and other tools I distribute help professional Penetration Testers, Security Consultants, Security Engineers and other security personnel in improving their customer networks cyber-defence capabilities.
In no event shall the authors or copyright holders be liable for any claim, damages or other liability arising from illegal use of this software.

If there are concerns, copyright issues, threats posed by this software or other inquiries - I am open to collaborate in responsibly addressing them.

The tool exposes handy interface for using mostly open-source or commercially available packers/protectors/obfuscation software, therefore not introducing any immediately new threats to the cyber-security landscape as is.


:coffee: Show Support :coffee:

This and other projects are outcome of sleepless nights and plenty of hard work. If you like what I do and appreciate that I always give back to the community, Consider buying me a coffee (or better a beer) just to say thank you! :muscle:


Author

   Mariusz Banach / mgeeky, '20-'22
   <mb [at] binary-offensive.com>
   (https://github.com/mgeeky) 
```    $$ $$ "Y$c$"$c.    "$
         88,  "888,_ _,88"888,_ _,88o88oo,._888 888    Y88`Y8bo,,,o88o
         MMM    "YMMMMMP"  "YMMMMMP"""""YUMMMMM MMM     YM  `'YMUP"YMM

    Red Team implants protection swiss knife.

    Multi-Packer wrapping around multitude of packers, protectors, shellcode loaders, encoders.
    Mariusz Banach / mgeeky '20-'22, <[email protected]>
    v0.16

[.] Processing x86 file: "\Rubeus.exe"
[.] Generating output of ConfuserEx(<file>)...

[+] SUCCEEDED. Original file size: 417280 bytes, new file size ConfuserEx(<file>): 756224, ratio: 181.23%

Scenario 2: Simple ConfuserEx obfuscation followed by artifact test

One can also obfuscate the file and immediately attempt to launch it (also with supplied optional parameters) to ensure it runs fine with options DISCOURSE_PLACEHOLDER_26:

DISCOURSE_PLACEHOLDER_27

Scenario 3: Complex malware obfuscation with watermarking and IOCs collection

Below use case takes DISCOURSE_PLACEHOLDER_28 on input and feeds it consecutively into DISCOURSE_PLACEHOLDER_29DISCOURSE_PLACEHOLDER_30DISCOURSE_PLACEHOLDER_31 packers.

Then it will inject specified DISCOURSE_PLACEHOLDER_32 watermark to the final generated output artifact’s DOS Stub as well as modify that artifact’s checksum with value DISCOURSE_PLACEHOLDER_33.

Finally, ProtectMyTooling will capture all IOCs (md5, sha1, sha256, imphash, and other metadata) and save them in auxiliary CSV file. That file can be used for IOC matching as engagement unfolds.

DISCOURSE_PLACEHOLDER_34

Produced IOCs evidence CSV file will look as follows:

DISCOURSE_PLACEHOLDER_35

Supported Packers

DISCOURSE_PLACEHOLDER_36 was designed to support not only Obfuscators/Packers but also all sort of builders/generators/shellcode loaders usable from the command line.

At the moment, program supports various Commercial and Open-Source packers/obfuscators. Those Open-Source ones are bundled within the project. Commercial ones will require user to purchase the product and configure its location in DISCOURSE_PLACEHOLDER_37 file to point the script where to find them.

  1. DISCOURSE_PLACEHOLDER_38 - Reflective PE Packer that takes EXE/DLL on input and produces EXE/PIC shellcode
  2. DISCOURSE_PLACEHOLDER_39 - A Highly capable Pe Packer
  3. DISCOURSE_PLACEHOLDER_40 - A console obfuscator for .NET assemblies by Charterino
  4. DISCOURSE_PLACEHOLDER_41 - Obfuscates specific windows apis with different apis.
  5. DISCOURSE_PLACEHOLDER_42 - Popular .NET obfuscator, forked from Martin Karing
  6. DISCOURSE_PLACEHOLDER_43 - Popular PE loader that takes EXE/DLL/.NET on input and produces a PIC shellcode
  7. DISCOURSE_PLACEHOLDER_44 - A powerful system designed for comprehensive protection of executable files
  8. DISCOURSE_PLACEHOLDER_45 - runtime encrypter for 32-bit and 64-bit portable executables. It is a reference implementation and bases on the paper “Hyperion: Implementation of a PE-Crypter”
  9. DISCOURSE_PLACEHOLDER_46 - combines strong license security, highly adaptable licensing functionality/schema with reliable assembly protection
  10. DISCOURSE_PLACEHOLDER_47 - Obfuscates Powershell scripts with DISCOURSE_PLACEHOLDER_48 (by Daniell Bohannon)
  11. DISCOURSE_PLACEHOLDER_49 - A more advanced free and open .NET obfuscator using dnlib by AnErrupTion
  12. DISCOURSE_PLACEHOLDER_50 - Takes input EXE/DLL file and produces output one with cloned certificate, removed Golang-specific IoCs and bloated size. By Matt Eidelberg (@Tyl0us).
  13. DISCOURSE_PLACEHOLDER_51 - MPRESS compressor by Vitaly Evseenko. Takes input EXE/DLL/.NET/MAC-DARWIN (x86/x64) and compresses it.
  14. DISCOURSE_PLACEHOLDER_52 - Unmatched .NET code protection system which completely stops anyone from decompiling your code
  15. DISCOURSE_PLACEHOLDER_53 - an exe packer aka executable compressor, application password protector and virtual DLL binder for Windows & Linux .NET applications.
  16. DISCOURSE_PLACEHOLDER_54 - Generates Nim loader running input .NET, PE or Raw Shellcode. Authored by (@icyguider)
  17. DISCOURSE_PLACEHOLDER_55 - Takes Shellcode or .NET Executable on input, produces EXE or DLL loader. Brought to you by Cas van Cooten (@chvancooten)
  18. DISCOURSE_PLACEHOLDER_56 - Takes PE/Shellcode/.NET executable and generates robust Nim+Syscalls EXE/DLL loader. Sponsorware authored by (@S3cur3Th1sSh1t)
  19. DISCOURSE_PLACEHOLDER_57 - wrapper around John Adams’ DISCOURSE_PLACEHOLDER_58
  20. DISCOURSE_PLACEHOLDER_59 - Converts PE into a shellcode. By yours truly @hasherezade
  21. DISCOURSE_PLACEHOLDER_60 - A Multi-Pass Encoder & Heuristic Sandbox Bypass AV Evasion Tool
  22. DISCOURSE_PLACEHOLDER_61 - Uses “peresed” from avast/pe_tools to remove all existing PE Resources and signature (think of Mimikatz icon).
  23. DISCOURSE_PLACEHOLDER_62 - EDR-evasive x64 shellcode loader that produces DLL/CPL/XLL/JScript/HTA artifact loader
  24. DISCOURSE_PLACEHOLDER_63 - Shikata ga nai (仕方がない) encoder ported into go with several improvements. Takes shellcode, produces encoded shellcode
  25. DISCOURSE_PLACEHOLDER_64 - obfuscator that helps protect your application against reverse-engineering or modification, by making it difficult for a third-party to access your source code
  26. DISCOURSE_PLACEHOLDER_65 - Convert DLLs to position independent shellcode. Authored by: Nick Landers, @monoxgas
  27. DISCOURSE_PLACEHOLDER_66 - Advanced Windows software protection system
  28. DISCOURSE_PLACEHOLDER_67 - a free, portable, extendable, high-performance executable packer for several executable formats.
  29. DISCOURSE_PLACEHOLDER_68 - protects code by executing it on a virtual machine with non-standard architecture that makes it extremely difficult to analyze and crack the software

You can quickly list supported packers using DISCOURSE_PLACEHOLDER_69 option (table columns are chosen depending on Terminal width, the wider the more information revealed):

DISCOURSE_PLACEHOLDER_70

Above are the packers that are supported, but that doesn’t mean that you have them configured and ready to use. To prepare their usage, you must first supply necessary binaries to the DISCOURSE_PLACEHOLDER_71 directory and then configure your YAML file accordingly.

RedWatermarker - built-in Artifact watermarking

Artifact watermarking & IOC collection

This program is intended for professional Red Teams and is perfect to be used in a typical implant-development CI/CD pipeline. As a red teamer I’m always expected to deliver decent quality list of IOCs matching back to all of my implants as well as I find it essential to watermark all my implants for bookkeeping, attribution and traceability purposes.

To accommodate these requirements, ProtectMyTooling brings basic support for them.

Artifact Watermarking

DISCOURSE_PLACEHOLDER_72 can apply watermarks after obfuscation rounds simply by using DISCOURSE_PLACEHOLDER_73 option.:

DISCOURSE_PLACEHOLDER_74

There is also a standalone approach, included in DISCOURSE_PLACEHOLDER_75 script.

It takes executable artifact on input and accepts few parameters denoting where to inject a watermark and what value shall be inserted.

Example run will set PE Checksum to 0xAABBCCDD, inserts DISCOURSE_PLACEHOLDER_76 to PE file’s DOS Stub (bytes containing This program cannot be run…), appends DISCOURSE_PLACEHOLDER_77 to file’s overlay and then create a new PE section named DISCOURSE_PLACEHOLDER_78 append it to the end of file and fill that section with preset marker.

DISCOURSE_PLACEHOLDER_79

Full watermarker usage:

DISCOURSE_PLACEHOLDER_80

Currently only PE files watermarking is supported, but in the future Office documents and other formats are to be added as well.

IOCs Collection

IOCs may be collected by simply using DISCOURSE_PLACEHOLDER_81 option in DISCOURSE_PLACEHOLDER_82 run.

They’re being collected at the following phases:

  • on the input file
  • after each obfuscation round on an intermediary file
  • on the final output file

They will contain following fields saved in form of a CSV file:

  • DISCOURSE_PLACEHOLDER_83
  • DISCOURSE_PLACEHOLDER_84
  • DISCOURSE_PLACEHOLDER_85 - formed as DISCOURSE_PLACEHOLDER_86
  • DISCOURSE_PLACEHOLDER_87 - whether a record points to an input, output or intermediary file
  • DISCOURSE_PLACEHOLDER_88 - value adjusted by the user through DISCOURSE_PLACEHOLDER_89 option
  • DISCOURSE_PLACEHOLDER_90
  • DISCOURSE_PLACEHOLDER_91
  • DISCOURSE_PLACEHOLDER_92
  • DISCOURSE_PLACEHOLDER_93 - PE Imports Hash, if available
  • (TODO) DISCOURSE_PLACEHOLDER_94 - .NET TypeRef Hash, if available

Resulting will be a CSV file named DISCOURSE_PLACEHOLDER_95 stored side by side to generated output artifact. That file is written in APPEND mode, meaning it will receive all subsequent IOCs.

RedBackdoorer - built-in PE Backdooring

DISCOURSE_PLACEHOLDER_96 utilizes my own DISCOURSE_PLACEHOLDER_97 script which provides few methods for backdooring PE executables. Support comes as a dedicated packer named DISCOURSE_PLACEHOLDER_98. Example usage:

Takes Cobalt Strike shellcode on input and encodes with SGN (Shikata Ga-Nai) then backdoors SysInternals DbgView64.exe then produces Amber EXE reflective loader

DISCOURSE_PLACEHOLDER_99

Full RedBackdoorer usage:

DISCOURSE_PLACEHOLDER_100

Cobalt Strike Integration

There is also a script that integrates DISCOURSE_PLACEHOLDER_101 used as a wrapper around configured PE/.NET Packers/Protectors in order to easily transform input executables into their protected and compressed output forms and then upload or use them from within CobaltStrike.

The idea is to have an automated process of protecting all of the uploaded binaries or .NET assemblies used by execute-assembly and forget about protecting or obfuscating them manually before each usage. The added benefit of an automated approach to transform executables is the ability to have the same executable protected each time it’s used, resulting in unique samples launched on target machines. That should nicely deceive EDR/AV enterprise-wide IOC sweeps while looking for the same artefact on different machines.

Additionally, the protected-execute-assembly command has the ability to look for assemblies of which only name were given in a preconfigured assemblies directory (set in dotnet_assemblies_directory setting).

To use it:

  1. Load DISCOURSE_PLACEHOLDER_102 in your Cobalt Strike.
  2. Go to the menu and setup all the options

options

  1. Then in your Beacon’s console you’ll have following commands available:
  • DISCOURSE_PLACEHOLDER_103 - Executes a local, previously protected and compressed .NET program in-memory on target.
  • DISCOURSE_PLACEHOLDER_104 - Takes an input file, protects it if its PE executable and then uploads that file to specified remote location.

Basically these commands will open input files, pass the firstly to the DISCOURSE_PLACEHOLDER_105 script, which in turn calls out to DISCOURSE_PLACEHOLDER_106. As soon as the binary gets obfuscated, it will be passed to your beacon for execution/uploading.

Cobalt Strike related Options

Here’s a list of options required by the Cobalt Strike integrator:

  • DISCOURSE_PLACEHOLDER_107 - Specify a path to Python3 interpreter executable
  • DISCOURSE_PLACEHOLDER_108 - Specify a path to ProtectMyTooling main directory
  • DISCOURSE_PLACEHOLDER_109 - Specify a path to ProtectMyTooling configuration file with various packers options
  • DISCOURSE_PLACEHOLDER_110 - Specify local path .NET assemblies should be looked for if not found by execute-assembly
  • DISCOURSE_PLACEHOLDER_111 - Enable to cache already protected executables and reuse them when needed
  • DISCOURSE_PLACEHOLDER_112 - Specify a path to a directory that should store cached protected executables
  • DISCOURSE_PLACEHOLDER_113 - Native x86 EXE executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_114 - Native x64 EXE executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_115 - Native x86 DLL executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_116 - Native x64 DLL executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_117 - .NET executables protectors/packers chain

Known Issues

  • DISCOURSE_PLACEHOLDER_118 is very tricky to run from Windows. What worked for me is following:
    1. Run on Windows 10 and have WSL installed (DISCOURSE_PLACEHOLDER_119 command available in Windows)
    2. Have DISCOURSE_PLACEHOLDER_120 installed in WSL at version DISCOURSE_PLACEHOLDER_121 (tested on DISCOURSE_PLACEHOLDER_122)
    3. Make sure to have DISCOURSE_PLACEHOLDER_123 set

Credits due & used technology

  • All packer, obfuscator, converter, loader credits goes to their authors. This tool is merely a wrapper around their technology!
    • Hopefully none of them mind me adding such wrappers. Should there be concerns - please reach out to me.
  • ProtectMyTooling also uses DISCOURSE_PLACEHOLDER_124 by moloch– by some Nim-based packers.

TODO


Disclaimer

Use of this tool as well as any other projects I’m author of for illegal purposes, unsolicited hacking, cyber-espionage is strictly prohibited. This and other tools I distribute help professional Penetration Testers, Security Consultants, Security Engineers and other security personnel in improving their customer networks cyber-defence capabilities.
In no event shall the authors or copyright holders be liable for any claim, damages or other liability arising from illegal use of this software.

If there are concerns, copyright issues, threats posed by this software or other inquiries - I am open to collaborate in responsibly addressing them.

The tool exposes handy interface for using mostly open-source or commercially available packers/protectors/obfuscation software, therefore not introducing any immediately new threats to the cyber-security landscape as is.


:coffee: Show Support :coffee:

This and other projects are outcome of sleepless nights and plenty of hard work. If you like what I do and appreciate that I always give back to the community, Consider buying me a coffee (or better a beer) just to say thank you! :muscle:


Author

DISCOURSE_PLACEHOLDER_129
```    $$ $$ "Y$c$"$c.    "$
         88,  "888,_ _,88"888,_ _,88o88oo,._888 888    Y88`Y8bo,,,o88o
         MMM    "YMMMMMP"  "YMMMMMP"""""YUMMMMM MMM     YM  `'YMUP"YMM

    Red Team implants protection swiss knife.

    Multi-Packer wrapping around multitude of packers, protectors, shellcode loaders, encoders.
    Mariusz Banach / mgeeky '20-'22, <[email protected]>
    v0.16

[.] Processing x64 file :  beacon64.bin
[>] Generating output of sgn(<file>)...
[>] Generating output of backdoor(sgn(<file>))...
[>] Generating output of Amber(backdoor(sgn(<file>)))...

[+] SUCCEEDED. Original file size: 265959 bytes, new file size Amber(backdoor(sgn(<file>))): 1372672, ratio: 516.12%

Full RedBackdoorer usage:

DISCOURSE_PLACEHOLDER_100

Cobalt Strike Integration

There is also a script that integrates DISCOURSE_PLACEHOLDER_101 used as a wrapper around configured PE/.NET Packers/Protectors in order to easily transform input executables into their protected and compressed output forms and then upload or use them from within CobaltStrike.

The idea is to have an automated process of protecting all of the uploaded binaries or .NET assemblies used by execute-assembly and forget about protecting or obfuscating them manually before each usage. The added benefit of an automated approach to transform executables is the ability to have the same executable protected each time it’s used, resulting in unique samples launched on target machines. That should nicely deceive EDR/AV enterprise-wide IOC sweeps while looking for the same artefact on different machines.

Additionally, the protected-execute-assembly command has the ability to look for assemblies of which only name were given in a preconfigured assemblies directory (set in dotnet_assemblies_directory setting).

To use it:

  1. Load DISCOURSE_PLACEHOLDER_102 in your Cobalt Strike.
  2. Go to the menu and setup all the options

options

  1. Then in your Beacon’s console you’ll have following commands available:
  • DISCOURSE_PLACEHOLDER_103 - Executes a local, previously protected and compressed .NET program in-memory on target.
  • DISCOURSE_PLACEHOLDER_104 - Takes an input file, protects it if its PE executable and then uploads that file to specified remote location.

Basically these commands will open input files, pass the firstly to the DISCOURSE_PLACEHOLDER_105 script, which in turn calls out to DISCOURSE_PLACEHOLDER_106. As soon as the binary gets obfuscated, it will be passed to your beacon for execution/uploading.

Cobalt Strike related Options

Here’s a list of options required by the Cobalt Strike integrator:

  • DISCOURSE_PLACEHOLDER_107 - Specify a path to Python3 interpreter executable
  • DISCOURSE_PLACEHOLDER_108 - Specify a path to ProtectMyTooling main directory
  • DISCOURSE_PLACEHOLDER_109 - Specify a path to ProtectMyTooling configuration file with various packers options
  • DISCOURSE_PLACEHOLDER_110 - Specify local path .NET assemblies should be looked for if not found by execute-assembly
  • DISCOURSE_PLACEHOLDER_111 - Enable to cache already protected executables and reuse them when needed
  • DISCOURSE_PLACEHOLDER_112 - Specify a path to a directory that should store cached protected executables
  • DISCOURSE_PLACEHOLDER_113 - Native x86 EXE executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_114 - Native x64 EXE executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_115 - Native x86 DLL executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_116 - Native x64 DLL executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_117 - .NET executables protectors/packers chain

Known Issues

  • DISCOURSE_PLACEHOLDER_118 is very tricky to run from Windows. What worked for me is following:
    1. Run on Windows 10 and have WSL installed (DISCOURSE_PLACEHOLDER_119 command available in Windows)
    2. Have DISCOURSE_PLACEHOLDER_120 installed in WSL at version DISCOURSE_PLACEHOLDER_121 (tested on DISCOURSE_PLACEHOLDER_122)
    3. Make sure to have DISCOURSE_PLACEHOLDER_123 set

Credits due & used technology

  • All packer, obfuscator, converter, loader credits goes to their authors. This tool is merely a wrapper around their technology!
    • Hopefully none of them mind me adding such wrappers. Should there be concerns - please reach out to me.
  • ProtectMyTooling also uses DISCOURSE_PLACEHOLDER_124 by moloch– by some Nim-based packers.

TODO


Disclaimer

Use of this tool as well as any other projects I’m author of for illegal purposes, unsolicited hacking, cyber-espionage is strictly prohibited. This and other tools I distribute help professional Penetration Testers, Security Consultants, Security Engineers and other security personnel in improving their customer networks cyber-defence capabilities.
In no event shall the authors or copyright holders be liable for any claim, damages or other liability arising from illegal use of this software.

If there are concerns, copyright issues, threats posed by this software or other inquiries - I am open to collaborate in responsibly addressing them.

The tool exposes handy interface for using mostly open-source or commercially available packers/protectors/obfuscation software, therefore not introducing any immediately new threats to the cyber-security landscape as is.


:coffee: Show Support :coffee:

This and other projects are outcome of sleepless nights and plenty of hard work. If you like what I do and appreciate that I always give back to the community, Consider buying me a coffee (or better a beer) just to say thank you! :muscle:


Author

DISCOURSE_PLACEHOLDER_129
```    $$ $$ "Y$c$"$c.    "$
         88,  "888,_ _,88"888,_ _,88o88oo,._888 888    Y88`Y8bo,,,o88o
         MMM    "YMMMMMP"  "YMMMMMP"""""YUMMMMM MMM     YM  `'YMUP"YMM

    Red Team implants protection swiss knife.

    Multi-Packer wrapping around multitude of packers, protectors, shellcode loaders, encoders.
    Mariusz Banach / mgeeky '20-'22, <[email protected]>
    v0.16

[.] Processing x86 file: "\Rubeus.exe"
[.] Generating output of ConfuserEx(<file>)...

[+] SUCCEEDED. Original file size: 417280 bytes, new file size ConfuserEx(<file>): 756224, ratio: 181.23%

Scenario 2: Simple ConfuserEx obfuscation followed by artifact test

One can also obfuscate the file and immediately attempt to launch it (also with supplied optional parameters) to ensure it runs fine with options DISCOURSE_PLACEHOLDER_26:

DISCOURSE_PLACEHOLDER_27

Scenario 3: Complex malware obfuscation with watermarking and IOCs collection

Below use case takes DISCOURSE_PLACEHOLDER_28 on input and feeds it consecutively into DISCOURSE_PLACEHOLDER_29DISCOURSE_PLACEHOLDER_30DISCOURSE_PLACEHOLDER_31 packers.

Then it will inject specified DISCOURSE_PLACEHOLDER_32 watermark to the final generated output artifact’s DOS Stub as well as modify that artifact’s checksum with value DISCOURSE_PLACEHOLDER_33.

Finally, ProtectMyTooling will capture all IOCs (md5, sha1, sha256, imphash, and other metadata) and save them in auxiliary CSV file. That file can be used for IOC matching as engagement unfolds.

DISCOURSE_PLACEHOLDER_34

Produced IOCs evidence CSV file will look as follows:

DISCOURSE_PLACEHOLDER_35

Supported Packers

DISCOURSE_PLACEHOLDER_36 was designed to support not only Obfuscators/Packers but also all sort of builders/generators/shellcode loaders usable from the command line.

At the moment, program supports various Commercial and Open-Source packers/obfuscators. Those Open-Source ones are bundled within the project. Commercial ones will require user to purchase the product and configure its location in DISCOURSE_PLACEHOLDER_37 file to point the script where to find them.

  1. DISCOURSE_PLACEHOLDER_38 - Reflective PE Packer that takes EXE/DLL on input and produces EXE/PIC shellcode
  2. DISCOURSE_PLACEHOLDER_39 - A Highly capable Pe Packer
  3. DISCOURSE_PLACEHOLDER_40 - A console obfuscator for .NET assemblies by Charterino
  4. DISCOURSE_PLACEHOLDER_41 - Obfuscates specific windows apis with different apis.
  5. DISCOURSE_PLACEHOLDER_42 - Popular .NET obfuscator, forked from Martin Karing
  6. DISCOURSE_PLACEHOLDER_43 - Popular PE loader that takes EXE/DLL/.NET on input and produces a PIC shellcode
  7. DISCOURSE_PLACEHOLDER_44 - A powerful system designed for comprehensive protection of executable files
  8. DISCOURSE_PLACEHOLDER_45 - runtime encrypter for 32-bit and 64-bit portable executables. It is a reference implementation and bases on the paper “Hyperion: Implementation of a PE-Crypter”
  9. DISCOURSE_PLACEHOLDER_46 - combines strong license security, highly adaptable licensing functionality/schema with reliable assembly protection
  10. DISCOURSE_PLACEHOLDER_47 - Obfuscates Powershell scripts with DISCOURSE_PLACEHOLDER_48 (by Daniell Bohannon)
  11. DISCOURSE_PLACEHOLDER_49 - A more advanced free and open .NET obfuscator using dnlib by AnErrupTion
  12. DISCOURSE_PLACEHOLDER_50 - Takes input EXE/DLL file and produces output one with cloned certificate, removed Golang-specific IoCs and bloated size. By Matt Eidelberg (@Tyl0us).
  13. DISCOURSE_PLACEHOLDER_51 - MPRESS compressor by Vitaly Evseenko. Takes input EXE/DLL/.NET/MAC-DARWIN (x86/x64) and compresses it.
  14. DISCOURSE_PLACEHOLDER_52 - Unmatched .NET code protection system which completely stops anyone from decompiling your code
  15. DISCOURSE_PLACEHOLDER_53 - an exe packer aka executable compressor, application password protector and virtual DLL binder for Windows & Linux .NET applications.
  16. DISCOURSE_PLACEHOLDER_54 - Generates Nim loader running input .NET, PE or Raw Shellcode. Authored by (@icyguider)
  17. DISCOURSE_PLACEHOLDER_55 - Takes Shellcode or .NET Executable on input, produces EXE or DLL loader. Brought to you by Cas van Cooten (@chvancooten)
  18. DISCOURSE_PLACEHOLDER_56 - Takes PE/Shellcode/.NET executable and generates robust Nim+Syscalls EXE/DLL loader. Sponsorware authored by (@S3cur3Th1sSh1t)
  19. DISCOURSE_PLACEHOLDER_57 - wrapper around John Adams’ DISCOURSE_PLACEHOLDER_58
  20. DISCOURSE_PLACEHOLDER_59 - Converts PE into a shellcode. By yours truly @hasherezade
  21. DISCOURSE_PLACEHOLDER_60 - A Multi-Pass Encoder & Heuristic Sandbox Bypass AV Evasion Tool
  22. DISCOURSE_PLACEHOLDER_61 - Uses “peresed” from avast/pe_tools to remove all existing PE Resources and signature (think of Mimikatz icon).
  23. DISCOURSE_PLACEHOLDER_62 - EDR-evasive x64 shellcode loader that produces DLL/CPL/XLL/JScript/HTA artifact loader
  24. DISCOURSE_PLACEHOLDER_63 - Shikata ga nai (仕方がない) encoder ported into go with several improvements. Takes shellcode, produces encoded shellcode
  25. DISCOURSE_PLACEHOLDER_64 - obfuscator that helps protect your application against reverse-engineering or modification, by making it difficult for a third-party to access your source code
  26. DISCOURSE_PLACEHOLDER_65 - Convert DLLs to position independent shellcode. Authored by: Nick Landers, @monoxgas
  27. DISCOURSE_PLACEHOLDER_66 - Advanced Windows software protection system
  28. DISCOURSE_PLACEHOLDER_67 - a free, portable, extendable, high-performance executable packer for several executable formats.
  29. DISCOURSE_PLACEHOLDER_68 - protects code by executing it on a virtual machine with non-standard architecture that makes it extremely difficult to analyze and crack the software

You can quickly list supported packers using DISCOURSE_PLACEHOLDER_69 option (table columns are chosen depending on Terminal width, the wider the more information revealed):

DISCOURSE_PLACEHOLDER_70

Above are the packers that are supported, but that doesn’t mean that you have them configured and ready to use. To prepare their usage, you must first supply necessary binaries to the DISCOURSE_PLACEHOLDER_71 directory and then configure your YAML file accordingly.

RedWatermarker - built-in Artifact watermarking

Artifact watermarking & IOC collection

This program is intended for professional Red Teams and is perfect to be used in a typical implant-development CI/CD pipeline. As a red teamer I’m always expected to deliver decent quality list of IOCs matching back to all of my implants as well as I find it essential to watermark all my implants for bookkeeping, attribution and traceability purposes.

To accommodate these requirements, ProtectMyTooling brings basic support for them.

Artifact Watermarking

DISCOURSE_PLACEHOLDER_72 can apply watermarks after obfuscation rounds simply by using DISCOURSE_PLACEHOLDER_73 option.:

DISCOURSE_PLACEHOLDER_74

There is also a standalone approach, included in DISCOURSE_PLACEHOLDER_75 script.

It takes executable artifact on input and accepts few parameters denoting where to inject a watermark and what value shall be inserted.

Example run will set PE Checksum to 0xAABBCCDD, inserts DISCOURSE_PLACEHOLDER_76 to PE file’s DOS Stub (bytes containing This program cannot be run…), appends DISCOURSE_PLACEHOLDER_77 to file’s overlay and then create a new PE section named DISCOURSE_PLACEHOLDER_78 append it to the end of file and fill that section with preset marker.

DISCOURSE_PLACEHOLDER_79

Full watermarker usage:

DISCOURSE_PLACEHOLDER_80

Currently only PE files watermarking is supported, but in the future Office documents and other formats are to be added as well.

IOCs Collection

IOCs may be collected by simply using DISCOURSE_PLACEHOLDER_81 option in DISCOURSE_PLACEHOLDER_82 run.

They’re being collected at the following phases:

  • on the input file
  • after each obfuscation round on an intermediary file
  • on the final output file

They will contain following fields saved in form of a CSV file:

  • DISCOURSE_PLACEHOLDER_83
  • DISCOURSE_PLACEHOLDER_84
  • DISCOURSE_PLACEHOLDER_85 - formed as DISCOURSE_PLACEHOLDER_86
  • DISCOURSE_PLACEHOLDER_87 - whether a record points to an input, output or intermediary file
  • DISCOURSE_PLACEHOLDER_88 - value adjusted by the user through DISCOURSE_PLACEHOLDER_89 option
  • DISCOURSE_PLACEHOLDER_90
  • DISCOURSE_PLACEHOLDER_91
  • DISCOURSE_PLACEHOLDER_92
  • DISCOURSE_PLACEHOLDER_93 - PE Imports Hash, if available
  • (TODO) DISCOURSE_PLACEHOLDER_94 - .NET TypeRef Hash, if available

Resulting will be a CSV file named DISCOURSE_PLACEHOLDER_95 stored side by side to generated output artifact. That file is written in APPEND mode, meaning it will receive all subsequent IOCs.

RedBackdoorer - built-in PE Backdooring

DISCOURSE_PLACEHOLDER_96 utilizes my own DISCOURSE_PLACEHOLDER_97 script which provides few methods for backdooring PE executables. Support comes as a dedicated packer named DISCOURSE_PLACEHOLDER_98. Example usage:

Takes Cobalt Strike shellcode on input and encodes with SGN (Shikata Ga-Nai) then backdoors SysInternals DbgView64.exe then produces Amber EXE reflective loader

DISCOURSE_PLACEHOLDER_99

Full RedBackdoorer usage:

DISCOURSE_PLACEHOLDER_100

Cobalt Strike Integration

There is also a script that integrates DISCOURSE_PLACEHOLDER_101 used as a wrapper around configured PE/.NET Packers/Protectors in order to easily transform input executables into their protected and compressed output forms and then upload or use them from within CobaltStrike.

The idea is to have an automated process of protecting all of the uploaded binaries or .NET assemblies used by execute-assembly and forget about protecting or obfuscating them manually before each usage. The added benefit of an automated approach to transform executables is the ability to have the same executable protected each time it’s used, resulting in unique samples launched on target machines. That should nicely deceive EDR/AV enterprise-wide IOC sweeps while looking for the same artefact on different machines.

Additionally, the protected-execute-assembly command has the ability to look for assemblies of which only name were given in a preconfigured assemblies directory (set in dotnet_assemblies_directory setting).

To use it:

  1. Load DISCOURSE_PLACEHOLDER_102 in your Cobalt Strike.
  2. Go to the menu and setup all the options

options

  1. Then in your Beacon’s console you’ll have following commands available:
  • DISCOURSE_PLACEHOLDER_103 - Executes a local, previously protected and compressed .NET program in-memory on target.
  • DISCOURSE_PLACEHOLDER_104 - Takes an input file, protects it if its PE executable and then uploads that file to specified remote location.

Basically these commands will open input files, pass the firstly to the DISCOURSE_PLACEHOLDER_105 script, which in turn calls out to DISCOURSE_PLACEHOLDER_106. As soon as the binary gets obfuscated, it will be passed to your beacon for execution/uploading.

Cobalt Strike related Options

Here’s a list of options required by the Cobalt Strike integrator:

  • DISCOURSE_PLACEHOLDER_107 - Specify a path to Python3 interpreter executable
  • DISCOURSE_PLACEHOLDER_108 - Specify a path to ProtectMyTooling main directory
  • DISCOURSE_PLACEHOLDER_109 - Specify a path to ProtectMyTooling configuration file with various packers options
  • DISCOURSE_PLACEHOLDER_110 - Specify local path .NET assemblies should be looked for if not found by execute-assembly
  • DISCOURSE_PLACEHOLDER_111 - Enable to cache already protected executables and reuse them when needed
  • DISCOURSE_PLACEHOLDER_112 - Specify a path to a directory that should store cached protected executables
  • DISCOURSE_PLACEHOLDER_113 - Native x86 EXE executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_114 - Native x64 EXE executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_115 - Native x86 DLL executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_116 - Native x64 DLL executables protectors/packers chain
  • DISCOURSE_PLACEHOLDER_117 - .NET executables protectors/packers chain

Known Issues

  • DISCOURSE_PLACEHOLDER_118 is very tricky to run from Windows. What worked for me is following:
    1. Run on Windows 10 and have WSL installed (DISCOURSE_PLACEHOLDER_119 command available in Windows)
    2. Have DISCOURSE_PLACEHOLDER_120 installed in WSL at version DISCOURSE_PLACEHOLDER_121 (tested on DISCOURSE_PLACEHOLDER_122)
    3. Make sure to have DISCOURSE_PLACEHOLDER_123 set

Credits due & used technology

  • All packer, obfuscator, converter, loader credits goes to their authors. This tool is merely a wrapper around their technology!
    • Hopefully none of them mind me adding such wrappers. Should there be concerns - please reach out to me.
  • ProtectMyTooling also uses DISCOURSE_PLACEHOLDER_124 by moloch– by some Nim-based packers.

TODO


Disclaimer

Use of this tool as well as any other projects I’m author of for illegal purposes, unsolicited hacking, cyber-espionage is strictly prohibited. This and other tools I distribute help professional Penetration Testers, Security Consultants, Security Engineers and other security personnel in improving their customer networks cyber-defence capabilities.
In no event shall the authors or copyright holders be liable for any claim, damages or other liability arising from illegal use of this software.

If there are concerns, copyright issues, threats posed by this software or other inquiries - I am open to collaborate in responsibly addressing them.

The tool exposes handy interface for using mostly open-source or commercially available packers/protectors/obfuscation software, therefore not introducing any immediately new threats to the cyber-security landscape as is.


:coffee: Show Support :coffee:

This and other projects are outcome of sleepless nights and plenty of hard work. If you like what I do and appreciate that I always give back to the community, Consider buying me a coffee (or better a beer) just to say thank you! :muscle:


Author

DISCOURSE_PLACEHOLDER_129

GitHub:

3 Likes