Windows shellcode development in Rust

Overview

Write Windows Shellcode in Rust

Project overview

Windows shellcode project is located in shellcode/, it can build into a PE file with only .text section and has no external dependencies.

shellcode.exe in pe-bear

Then we can dump the .text section and do some patches to make it position-independent. this idea was from hasherezade's project masm_shc.

How to build it

(Only tested on Win10 x64)

Build shellcode binary

rustup default nightly-x86_64-pc-windows-msvc
cd shellcode/
cargo build --release

If everthing goes well, we will get shellcode\target\x86_64-pc-windows-msvc\release\shellcode.exe

Dump .text section and do some patches

We patch at the start of .text section, make it jump to entry point. In this way, we can have some strings store in the merged section, or we have to use u8 and u16 bytes array on stack to represent string.

cd ..
cargo run

We will get shellcode\target\x86_64-pc-windows-msvc\release\shellcode.bin, this is the final shellcode file.

Test shellcode

Test the shellcode use your favorite shellcode loader, i use my own little tool rs_shellcode for demonstration.

git clone https://github.com/b1tg/rs_shellcode
cd rs_shellcode/
cargo build
./target/debug/rs_shellcode.exe -f "shellcode\target\x86_64-pc-windows-msvc\release\shellcode.bin" 

This demo shellcode will popup a message box and print some log use OutputDebugStringA, you can check it out in debugview or windbg.

run shellcode

References

You might also like...
A Rust command line tool to simplify embedded development and deployment.

Bobbin-CLI bobbin-cli is a tool designed to make it easy to build, deploy, test and debug embedded devices using a unified CLI. bobbin-cli understands

Are we lang yet? A simple website providing information about the status of Rust's language development ecosystem.

Are We Lang Yet This project answers the question "Is the Rust ecosystem ready to use for language development yet?". arewelangyet.com What is this? C

Rust-based language and runtime for cross-platform app development
Rust-based language and runtime for cross-platform app development

Pax Pax is a cross-platform rendering engine & Rust framework for interactive graphics, animations, and GUIs. Pax extends the Rust programming languag

Email test server for development, written in Rust
Email test server for development, written in Rust

MailCrab Email test server for development, written in Rust. Inspired by MailHog and MailCatcher. MailCrab was created as an exercise in Rust, trying

Umpteen is a general-purpose programming language currently in active development being bootstrapped from Rust

The Umpteen Programming Language This repository provides the reference implementation for the Umpteen Programming Language, bootstrapped from Rust. U

Call is an easy-to-use command tools for remote development.
Call is an easy-to-use command tools for remote development.

Call is an easy-to-use command tools for remote development. It helps you to build remote development easily and elegant. It can work with makefile and justfile.

Code and Development environment for adventofcode.com - 2021 edition

aoc-2021 Warning Spoiler Alert! If you want to solve the aoc problems on your own, do not read any further. This repository contains solutions for the

Cross-platform CLI Rimworld Mod manager. Still under development

rwm Inspired by Spoons rmm. This is a cross-platform Mod Manager for RimWorld intended to work with macOS, linux and Windows Up to now, you must have

DeFiChain octopus is a codename research & development for DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support.

DeFiCh/octopus DeFiChain octopus is a codename research & development for DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support . Proposed as a DFI

Owner
red
take notes please
red
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
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
Shellcode packer written in Rust

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 no

null 27 Dec 15, 2022
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
Platform that enables Windows driver development in Rust. Developed by Surface.

windows-drivers-rs This repo is a collection of Rust crates that enable developers to develop Windows Drivers in Rust. It is the intention to support

Microsoft 1.1k Oct 11, 2023
Windows-rs - Rust for Windows

Rust for Windows The windows crate lets you call any Windows API past, present, and future using code generated on the fly directly from the metadata

Microsoft 7.7k Dec 30, 2022
Use Thunk to build your Rust program that runs on old Windows platforms, support Windows XP and more!

Use Thunk to build your Rust program that runs on old platforms. Thunk uses VC-LTL5 and YY-Thunks to build programs that support old platforms. So, ho

null 6 May 21, 2023
Switch windows of same app with alt + ` on windows pc.

Windows Switcher Switch windows of same app with alt + ` on windows pc. 250k single file executable downloaded from Github Release. No installation re

null 172 Dec 10, 2022
Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)

is-wsl Check if the process is running inside Windows Subsystem for Linux (Bash on Windows) Inspired by sindresorhus/is-wsl and made for Rust lang. Ca

Sean Larkin 6 Jan 31, 2023
Windows Capture Simple Screen Capture for Windows 🔥

Windows Capture   Windows Capture is a highly efficient Rust library that enables you to effortlessly capture the screen using the Graphics Capture AP

null 3 Sep 24, 2023