PickerPacker

Building Custom Execution Chains with Rust

What is this ???

PickerPacker is a extremely modular rust-based packer that allows you to mix and match various attack techniques ranging from execution types to different injections and AV/EDR evasion methods to essentially create your own payload execution chain.

While PickerPacker is specifically made for red-teaming in mind, it can be used for benign software packing too! Just you know... don't use the evasion features for that.

β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €      β €β’€β£€β£€β£€β£€β£€β£€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €
β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €     β’€β£ β‘Άβ Ώβ Ώβ Ώβ ­β’€β£€β£€β ‰β£©β‘Ÿβ ’β ¦β£„β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €
β €β €β €β €β €β €β €β €β €β €β €β €β €     β£ β žβ ‰β €β €β €β €β €β €β €β €β ‰β ‰β ‰β €β €β €β ˜β£§β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €
β €β €β €β €β €β €β €β €β €β €β €    β € β’°β ‡β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β ˜β‘†β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €
β €β €β €β €β €β €     β €β €β €β €β €β €β‘Ύβ €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β ˆβ’»β‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €
β €β €β €β €β €β €β €β €β €β €     β €β €β‘‡β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β ˜β£§β €β €β €β €β €β €β €β €β €β €β €β €β €β €
    ⠀⣀⣀⣀⣀⑀⠀⠀⠀⠀⠀⠀⑇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⑆⠀⠀⠀⠀⒀⣀⠀⠀⠀⒀⣀⠀⠀
   β’°β ‹β €β €β €β ‰β ™β ²β’€β£€β €β €β‘‡β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’Ήβ‘„β’€β‘΄β šβ ‰β €β €β €β €β €β ˆβ’³β‘„
   β’Έβ‘„β €β €β €β €β €β €β €β ˆβ ‘β’¦β£§β£€β£€β£€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β£€β£€β£€β‘΄β Ÿβ ‰β €β €β €β €β €β €β €β €β €β €β‘·
   β ˆβ’³β‘€β €β €β €β €β €β €β €β €β €β ˆβ ™β »β’­β£‰β ™β ›β ’β ²β Άβ Άβ Άβ Άβ –β ’β ’β ’β ›β ‰β ‰β ‰β €β €β €β €β €β €β €β €β €β €β €β €β£Έβ ƒ
β €    β €β ™β’Άβ£„β €β €β €β €β €β €β €β €β €β €β €β ˆβ ™β ²β’€β£„β‘€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β‘Όβ ƒβ €
    β €β €β €β €β ˆβ ™β ’β’„β£€β €β €β €β €β €β €β €β €β €β €β €β €β ‰β “β ¦β’„β£€β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €β’€β£ β ΄β ‹β €β €β €
β €    β €β €β €β €β €β €β €β ˆβ ‰β “β ’β ’β ‚β €β €β €β €β €β €β €β €β €β €β €β €β €β €β£€β£€β €β €β €β €β €β €β ’β šβ ‰β €β €β €β €β €β €β €β €β €β €β €β €β €β €β €

           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— 
           β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
           β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
           β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘
           β•šβ•β•     β•šβ•β• β•šβ•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•
             β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— 
             β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
             β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
             β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
             β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘
             β•šβ•β•     β•šβ•β•  β•šβ•β• β•šβ•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•
    
        ✧ο½₯゚:*✧ο½₯゚:* Rust-Powered Customizable Packer *:ο½₯゚✧*:ο½₯゚✧
    
        Created by: Swayam Tejas Padhy (@Leek0gg)
        GitHub: https://github.com/Swayampadhy/PickerPacker

Why is this ??

I was looking into various packers and how they work for a research paper of mine while I realized that no packers existed which provided granular modularity in the execution of the payload i.e. letting the user pick and choose whatever they wanted for the execution chain .

While projects such as RustPacker, ProtectMyTooling exist, they are based on templates i.e. they have multiple options of execution chain sets but aren't granularly selective.

This led me to design PickerPacker which is granularly selective to the point that you can pick and choose each step of the payload's execution chain; creating unique and custom chains execution chains for yourself.

Now being the devil's advocate, being extremely granular is also not a good thing. For example: PickerPacker has 5 different ETW patching methods. Enabling them all at the same time is frankly stupid and just leads to more detection surface. Due to this, I have put some minor restrictions in the execution chain creation. But I will try to keep this as minimal as required.

I decided to develop this packer in rust because.... why not? I anyway wanted to learn rust and what's the best way to do that - Do a very complex rust project of course!! Who reads books Pffft (kidding).

On a sidenote, Rust is quickly becoming my favorite. While it can never replace C for me, it definitely is better than C++ or other languages that I have worked with in the past.


How to use this ??

PickerPacker is production-ready. So you can use it for your engagements if you want. I have tested the packer against various anti-malware solutions and the only ones to detect it are BkavPro (W64.AIDetectMalware) and Elastic (Medium confidence). Below is a virus total detection result of the final packed payload.

The packer was also able to evade Elastic's agent in full detect and prevent mode. I was not able to test it against other EDRs as I don't have access to them (I am still a college student lol).

I think these detections are specifically due to the self-deletion anti-analysis. Self-deletion in Windows 11 using rust is a bit wonky in the sense that even if the file data is transferred to another data stream, the file handle isn't deleted up until that file-handle is used again to run the program. This raises the detection risk.

While PickerPacker is production-ready, this doesn't mean that it is finished yet. I am planning to add a lot more features in upcoming releases. Stay tuned to the GitHub repo for that.


How PickerPacker Works ??

PickerPacker has two main parts to it -

  • The packer binary - This does the packing of the payload

  • The template folder - This folder contains the source files for the final packed binary. Any changes to the behavior of the final packed binary is to be done here.

While designing this packer, I had the option of embedding the packer template into the packer binary or keep it separate. While embedding it inside the packer allows for easier distribution (everything is contained in a huge binary), adding more features to the packer and maintaining it becomes exponentially difficult as everything breaks even if I change one simple variable. Thus I decided to keep it separate. This can of course be changed in future releases if people want it.

Overall Flowchart Of PickerPacker

As seen in the above flowchart, PickerPacker takes in the selected features to compile as input from the user, analyzes them, prepares template files accordingly and finally compiles the final packed executable accordingly. See below expandable for more details.

Detailed Packer Working

Stage 1: Configuration & Argument Parsing

CLI Configuration Structure

What it does: Users configure the packer with various execution methods (fiber, callbacks, timers), injection methods (default, mapping, function stomping), anti-analysis checks (debugger, VM detection), and evasion techniques (AMSI/ETW bypasses). Optional AES-256 encryption requires hexadecimal key/IV parameters.​


Stage 2: Enumeration System

Execution Methods (Sample)

What it does: Each execution method maps to a Cargo feature flag (e.g., ShellcodeExecuteFiber). This enables feature-driven conditional compilation where only selected code paths are included in the final binary.​

Check Methods (Anti-Analysis)

What it does: Anti-analysis techniques detect debuggers via PEB flags, hardware breakpoints, and VMs via CPU count, RAM size, USB history, and screen resolution.​


Stage 3: Payload Processing & Encryption

Payload Encryption

What it does: If encryption is enabled, the payload is converted to AES-256-CBC encrypted bytes. The user must preserve the key and IV for runtime decryption.​

Payload Embedding

What it does: The template contains a placeholder constant for the payload. This function searches and replaces it with the actual payload formatted as Rust byte array literals (e.g., &[0x90, 0x90, ...]), embedding the payload directly into source code.​


Stage 4: Template File Management

Template Module Registry

What it does: Centralized registry of all template files. Each file maps to a specific feature (execution methods, injections, checks, evasion techniques).​

Conditional Module Inclusion

What it does: Only includes template files necessary for the selected features. Encryption modules only copy if encryption is enabled. Anti-analysis modules only include if checks are enabled.​

Directory Setup

What it does: Creates the loader project directory structure and copies the Cargo.toml manifest (which contains all feature flags for conditional compilation).​


Stage 5: Compilation

Dynamic Cargo Command Building

What it does: Dynamically constructs the Cargo command with selected features.

Example output:

Execution & Error Handling

What it does: Invokes Cargo as a subprocess to compile the loader with all selected features. Only included code paths are compiled into the binary.​


Stage 6: Output

Main Workflow

What it does: The complete workflow: parse config β†’ read payload β†’ encrypt (if enabled) β†’ embed into template β†’ copy conditional modules β†’ compile with features β†’ output PickerPacker_Packed.exe.​

Executable Relocation

What it does: Moves the compiled executable from the build directory to the root folder, renamed as PickerPacker_Packed.exe for user convenience.​

The template folder contains the source code that is selectively compiled during final packer compilation. You can check out the template code here.

Which parts of the template code are compiled is dictated by a neat rust feature named - Rust Features. Rust features ensures that only the features that are selected during compilation are the ones that are included in the final compilation. Almost every code in the template folder is feature-gated except some bare essential code. This allows for compile-time modularity.

A Snippet of the Extensive Feature List In PickerPacker

Which features to be included in each compilation is dictated by the packer. The packer creates a cargo sub-process, takes in the desired feature inputs from the user, pushes appropriate compile flags to the sub-process and runs the cargo compile command. This results in the compilation of a packed executable with your unique desired execution chain features.


So How to use it ??

Basic Command Structure

Command-Line Options

Option
Description
Example

--input <FILE>

Required. Path to shellcode file

--input calc.bin

--execution <METHOD>

Execution technique (default: default)

--execution fiber

--injection <METHOD>

Injection method (default: default)

--injection modulestomping

--checks <CHECKS>

Comma-separated check methods

--checks dbgprocesslist,vmcpu

--evasion <EVASION>

Comma-separated evasion techniques

--evasion amsisimple,etwwinapi

--encrypt <METHOD>

Encryption algorithm (tinyaes or ctaes)

--encrypt tinyaes

--key <HEX>

AES key (64 hex chars / 32 bytes)

--key ABC123...

--iv <HEX>

AES IV (32 hex chars / 16 bytes)

--iv DEF456...

Usage Examples

1️⃣ Basic Execution

2️⃣ With Execution Method

3️⃣ With Injection Method

4️⃣ With Anti-Debug Checks

5️⃣ With Evasion Techniques

6️⃣ With Encryption

7️⃣ Kitchen Sink (All Features)

Running the Packed Executable

Please keep in mind that some CLI options may change in future versions. I will update them both in the Github repo and here accordingly.


Credits & Acknowledgments

This project incorporates techniques and code snippets from:

If you want to contribute to this project, see CONTRIBUTING.md.

Last updated