aboutsummaryrefslogtreecommitdiff

go-shellcode2uuid

go-shellcode2uuid is an offensive security utility that encodes arbitrary binary shellcode into UUID strings, generating Python, C, CSharp and Rust stubs to decode and execute the shellcode at runtime. It supports Linux and Windows platforms, with optional single-byte XOR or 16bit random key RC4 encryption/decryption for obfuscation. This is a golang implementation of the popular technique written in many other programming lanauges by multiple authors.

WARNING: This tool is intended for authorized security assessments only. Misuse may violate laws or regulations. The author disclaims any responsibility for unlawful use. Always obtain explicit permission before conducting any security tests.

Features

  • UUID encoding: Converts raw shellcode bytes into UUID string literals for easy embedding.
  • Multi-platform stubs: Generates testing stubs for Python, C (Linux and Windows), CSharp, Rust (Linux and Windows).
  • XOR or RC4 encryption: Supports single-byte XOR or 16bit RC4 random key encryption/decryption for lightweight obfuscation.
  • Automatic shellcode padding: Pads shellcode to a multiple of 16 bytes to fit UUID size.

Installation

Prerequisites

  • Go: Version 1.21 or later.
  • Make: For building with the provided Makefile.
  • Git: To clone the repository.

Steps

  • Clone the repository:
$ git clone https://cgit.heqnx.com/go-shellcode2uuid
$ cd go-shellcode2uuid
  • Install dependencies:
$ go mod tidy
  • Build for all platforms:
$ make all
  • Binaries will be generated in the build/ directory for Linux, Windows, and macOS; alternatively, build for a specific platform:
$ make linux-amd64
$ make windows-amd64
$ make darwin-arm64

Usage

Command-Line Flags

Usage of ./go-shellcode2uuid-linux-amd64:
  -file string
        path to binary shellcode file
  -rc4
        enable rc4 encryption with 16bit random key
  -stub string
        stub language to output (py, c, cwin, rs)
  -xor
        enable single-byte xor encoding with random key

Examples

Generate a Python stub with RC4 encryption:

$ ./go-shellcode2uuid-linux-amd64 -file shellcode_linux.bin -rc4 -stub py
[inf] shellcode size (54 bytes) is not a multiple of 16, will pad with nullbytes
[inf] using rc4 key: r24OlLLBQr6Ay8rL
ef4cd858-172a-5494-d0f2-1aec40ea5813
00ccb780-888c-ea60-0353-85d24303e0a9
3627567b-6603-5074-4beb-a8c1b23c7211
c73d284b-b64d-d337-4ec5-3be297937f8f
[inf] stub written to stub.py

Generate a Windows C stub with XOR encryption:

$ ./go-shellcode2uuid -file shellcode_win.bin -xor -stub cwin
[inf] shellcode size (276 bytes) is not a multiple of 16, will pad with nullbytes
[inf] using xor key: 0x1c
e0549ff8-ecf4-dc1c-1c1c-5d4d5d4c4e4d
4a542dce-7954-974e-7c54-974e0454974e
3c54976e-4c54-13ab-5656-512dd5542ddc
b0207d60-1e30-3c5d-ddd5-115d1dddfef1
4e5d4d54-974e-3c97-5e20-541dcc979c94
1c1c1c54-99dc-687b-541d-cc4c97540458
975c3c55-1dcc-ff4a-54e3-d55d97289454
1dca512d-d554-2ddc-b05d-ddd5115d1ddd
24fc69ed-501f-5038-1459-25cd69c44458
975c3855-1dcc-7a5d-9710-5458975c0055
1dcc5d97-1894-541d-cc5d-445d44424546
5d445d45-5d46-549f-f03c-5d4ee3fc445d
45465497-0ef5-4be3-e3e3-4154a61d1c1c
1c1c1c1c-1c54-9191-1d1d-1c1c5da62d97
739be3c9-a7fc-0136-165d-a6ba89a181e3
c9549fd8-3420-1a60-169c-e7fc6919a75b
0f6e7376-1c45-5d95-c6e3-c97f7d707f32
7964791c-1c1c-1c1c-1c1c-1c1c1c1c1c1c
[inf] stub written to stub.c

$ head -10 stub.c
// x86_64-w64-mingw32-gcc -o stub.exe stub.c -Wl,--nxcompat -Wl,--dynamicbase
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

#define ORIGINAL_SHELLCODE_LENGTH 276

const char* uuid_strings[] = {
    "33874c2b-3f27-0fcf-cfcf-8e9e8e9f9d9e",

Generate a Windows Rust stub with XOR encryption:

go-shellcode2uuid-linux-amd64 -file shellcode_win.bin -xor -stub rs
[inf] shellcode size (276 bytes) is not a multiple of 16, will pad with nullbytes
[inf] using xor key: 0x92
6eda1176-627a-5292-9292-d3c3d3c2c0c3
c4daa340-f7da-19c0-f2da-19c08ada19c0
b2da19e0-c2da-9d25-d8d8-dfa35bdaa352
3eaef3ee-90be-b2d3-535b-9fd39353707f
c0d3c3da-19c0-b219-d0ae-da934219121a
929292da-1752-e6f5-da93-42c219da8ad6
19d2b2db-9342-71c4-da6d-5bd319a61ada
9344dfa3-5bda-a352-3ed3-535b9fd39353
aa72e763-de91-deb6-9ad7-ab43e74acad6
19d2b6db-9342-f4d3-199e-dad619d28edb
9342d319-961a-da93-42d3-cad3cacccbc8
d3cad3cb-d3c8-da11-7eb2-d3c06d72cad3
cbc8da19-807b-c56d-6d6d-cfda28939292
92929292-92da-1f1f-9393-9292d328a319
fd156d47-2972-8fb8-98d3-2834072f0f6d
47da1156-baae-94ee-9812-6972e79729d5
81e0fdf8-92cb-d31b-486d-47f1f3fef1bc
f7eaf792-9292-9292-9292-929292929292
[inf] rust stub written to stub/src/main.rs
[inf] stub written to stub/src/main.rs

$ head -10 stub/src/main.rs
// rustup target add x86_64-pc-windows-gnu
// cargo build --release --target x86_64-pc-windows-gnu
//
// rustup target add x86_64-unknown-linux-gnu
// cargo build --release --target x86_64-unknown-linux-gnu
#[cfg(windows)]
use winapi::ctypes::c_void;
#[cfg(unix)]
use std::ffi::c_void;
use std::ptr;
  • The tool prints the generated UUID strings to stdout and writes source files for the selected stub: stub.py, stub.c or stub/src/main.rs.

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE. See the LICENSE file for more details.

Disclaimer

go-shellcode2uuid is provided "as is" without warranties. The author and contributors are not responsible for any misuse or damages resulting from use. This tool is for educational and authorized security testing purposes only.