Skip to content
Back to skills

Emulating Shellcode With Unicorn

ASecurity

'Emulates position-independent shellcode in a controlled CPU emulator (Unicorn) to

  • 22 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added September 11, 2026
securitypythonshellbashapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 11, 2026

npx -y skills add meltedinhex/analyst-ai-pack --skill emulating-shellcode-with-unicorn --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Emulating Shellcode With Unicorn?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Emulating Shellcode With Unicorn
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/meltedinhex-emulating-shellcode-with-unicorn/badge)](https://www.skillsdirectory.com/skills/meltedinhex-emulating-shellcode-with-unicorn)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: emulating-shellcode-with-unicorn
description: 'Emulates position-independent shellcode in a controlled CPU emulator (Unicorn) to
  trace executed instructions, memory writes, and decoded second stages without running it on a
  real host. Activates for requests to emulate shellcode, trace a decoder stub, or recover a stage
  unpacked at runtime by shellcode.'
domain: cybersecurity
subdomain: reverse-engineering
tags:
  - reverse-engineering
  - shellcode
  - emulation
  - unicorn
  - dynamic-analysis
version: 1.0.0
author: analyst-ai-pack
license: Apache-2.0
mitre_attack:
  - T1027
  - T1620
  - T1055
d3fend:
  - D3-DA
  - D3-SDA
references:
  - 'Unicorn CPU emulator framework — https://www.unicorn-engine.org/'
  - 'MITRE ATT&CK T1620 Reflective Code Loading — https://attack.mitre.org/techniques/T1620/'
---

# Emulating Shellcode With Unicorn

## When to Use

- You have a raw shellcode blob (decoder stub, egg hunter, staged loader) and want to observe its
  behavior via emulation rather than native execution.
- You want to recover a second stage that the shellcode decrypts/decompresses in memory.

**Do not use** native execution for this — emulation contains the code. Unsupported API calls must
be stubbed; emulation is not a full Windows environment.

## Prerequisites

- The shellcode blob and the `unicorn` Python package (degrades gracefully if absent — the script
  reports that emulation is unavailable and still does static prep).

## Safety & Handling

- Even under emulation, treat the blob as malicious; run on an isolated VM and store stages
  password-protected.

## Workflow

### Step 1: Prepare and validate the blob

```bash
python scripts/analyst.py prep shellcode.bin --arch x64
```

Reports size, detected architecture hints, and whether Unicorn is available.

### Step 2: Emulate with an instruction/memory trace

```bash
python scripts/analyst.py emulate shellcode.bin --arch x64 --max-insns 200000
```

Maps the code into emulator memory, sets up a minimal stack, hooks instruction and memory-write
events, and stops on a self-modified region or instruction budget.

### Step 3: Dump decoded stages

If the shellcode writes a new executable region, dump that buffer for follow-on analysis.

### Step 4: Document

Record the entry behavior, decoded stage offset, and any observed (stubbed) API references.

## Validation

- Emulation halts on the instruction budget or a clear decode-complete signal — never hangs.
- A decoded stage, if produced, has a recognizable header (MZ/known opcode prologue).
- Unsupported instructions/APIs are reported, not silently ignored.

## Pitfalls

- Missing API/syscall environment causing early faults — stub the calls the stub needs.
- Wrong architecture/bitness producing immediate invalid-instruction faults.
- Emulating an anti-emulation stub that detects timing/missing APIs.

## References

- See [`references/api-reference.md`](references/api-reference.md) for the emulator harness.
- Unicorn engine and ATT&CK T1620 (linked in frontmatter).

Files in this skill

  • LICENSE340 B
  • SKILL.md3 KB
  • references/api-reference.md1.4 KB
  • scripts/analyst.py3.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.