Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 2.61 KB

File metadata and controls

76 lines (57 loc) · 2.61 KB

In-Memory Shellcode Detonator

A proof-of-concept Linux x86_64 loader that allocates RWX memory and executes raw shellcode entirely in memory, no disk artifacts, no staging files.


Executive Overview

Objectives & Use Cases

  • Deliver a compact, single-stage loader for in-memory shellcode detonation.
  • Validate defensive controls by demonstrating pure in-memory detonation techniques.

Technical Details

Core Features

  • Memory Allocation (mmap): requests a private, anonymous RWX region for payload staging.
  • Payload Injection: copies raw shellcode from a generated header (shellcode.h) into the allocated buffer.
  • Direct Execution: casts buffer to a function pointer and transfers execution to shellcode.
  • Minimal Syscalls: only mmap, memcpy, and invocation—no dynamic linking beyond standard C library.

Internal Components

├── shellcode_injector.c   – PoC stub loader (allocates, injects, executes)
├── shellcode             – raw shellcode (generated by msfvenom)
├── shellcode.h           – xxd-generated C header with byte array
└── linux_in-memory_shellcode-detonation_PoC  – compiled binary

Supported Platforms

  • Linux x86_64 (glibc ≥ 2.17)
  • Tested on Kali Linux 6.x kernel

Installation & Usage

Prerequisites

  • Build Tools: gcc with C11 support, make (optional)
  • Payload Generator: msfvenom from Metasploit Framework
  • Payload Conversion: xxd to generate shellcode.h from raw bytes
  • Permissions: ability to allocate RWX pages (no restrictive SELinux/AppArmor policies)

Build Steps

  1. Generate Raw Shellcode
    msfvenom -p linux/x64/exec CMD="echo 'Hello World!'" -f raw -o shellcode
  2. Convert to Header
    xxd -i shellcode > shellcode.h
  3. Compile Loader
    gcc -std=c11 -Wall -Wextra -z execstack shellcode_injector.c -o linux_in-memory_shellcode-detonation_PoC

Execution Examples

  • Detonate Payload
    ./linux_in-memory_shellcode-detonation_PoC

References