How to analyze shellcode without running it

Shellcode is position-independent machine code with no file format around it: no headers, no import table, nothing that says where it starts or which CPU it is for. That makes it awkward to study. You can’t double-click it, and a disassembler on its own often shows only the first few instructions: most shellcode decodes itself, or finds the Windows functions it needs at run time, so the interesting part isn’t in the bytes you have.

There are three ways to look inside.

Read it: disassembly

A disassembler such as Capstone, Ghidra or IDA turns the bytes into instructions. It is safe and complete in one sense: every byte is shown. But it can’t follow a decoder, so an encoded payload stays encoded, and data mixed into the code throws a linear disassembly off track.

Run it: a debugger and a loader

On a Windows machine you can load the bytes into executable memory with a small loader and step through them in a debugger. You see exactly what happens on that machine, including the real responses from the network. It is also the riskiest option: the code really runs, so it belongs on an isolated analysis machine with no route to anything you care about.

Emulate it

An emulator runs the instructions on a software CPU and answers the Windows API calls itself. Speakeasy, from Mandiant’s FLARE team, is built for exactly this: it emulates the CPU with Unicorn, lays out a Windows process around the shellcode, and records every API call with its decoded arguments. Nothing runs on a real CPU or a real Windows, file writes go to an emulated file system, and the network is simulated.

Emulation gets you most of what running it would, without the risk:

Reading the report

Shellcode Emulator runs Speakeasy on what you paste and shows the result.

  1. The verdict says whether the code returned or stopped, and where. A stop isn’t a failure of the analysis: shellcode often ends in a crash once it has done its work, or when it waits for something the emulator doesn’t provide.
  2. The byte map shows each input byte. Amber bytes ran. Cyan bytes were rewritten by the code itself, which is what an in-place decoder does. Click a byte to see its instruction.
  3. Summary lists what matters first: network, processes, files, registry and loaded libraries.
  4. Calls is the full timeline of API calls.
  5. Code is the disassembly, marked with what ran, plus each stage the code wrote and ran.
  6. Memory holds the stages and other memory the code filled, as hex, to download for a closer look.

When emulation stops early

What emulation can’t tell you

The emulator answers DNS and HTTP requests with made-up addresses and placeholder content. A stager that downloads its next stage gets that placeholder instead of the real payload, so the report shows where it would have connected, not what it would have received. Code that checks its environment closely enough can also tell it isn’t on a real machine and behave differently. When the stakes are high, treat the emulator’s report as the map and confirm the details on an isolated analysis machine.