> For the complete documentation index, see [llms.txt](https://docs.hex-rays.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hex-rays.com/add-ons/malware/concepts/emulators/sogen.md).

# Sogen

Sogen is a Windows system emulator that is open source on GitHub and developed by Maurice Heumann (momo5502). It is written in C++ and emulates a CPU with a variety of backends, including Unicorn, Icicle, the Windows Hypervisor Platform, and more. Within the Malware Analysis add-on, we always use the Unicorn backend when we invoke Sogen, because it is cross-platform and widely tested.

Because Sogen is compiled to a standalone binary, the Sogen analyzer can be faster than [Speakeasy](https://docs.hex-rays.com/add-ons/malware/concepts/emulators/speakeasy.md): it can emulate more instructions per second. But this is not always that relevant, especially for interactive emulation, such as when you use IDA's debugging interface to step through code. Both Speakeasy and Sogen emulate so many CPU instructions per second that the experience is snappy enough.

Sogen is licensed under the [GPL-2.0](https://github.com/momo5502/sogen/blob/main/LICENSE). The source is at [github.com/momo5502/sogen](https://github.com/momo5502/sogen), and you can try it in a browser at [sogen.dev](https://sogen.dev).

## How Sogen emulates Windows

Sogen emulates Windows at the syscall layer. It sort of pretends to be a Windows kernel, and implements a minimal set of interfaces that allow the Windows loader to start a process, emulate the process, and interact with the emulated system. This means that Sogen requires all the user land components of Windows to emulate the target process.

For example, when the target process calls `CreateFile`, it actually calls into the Microsoft Windows `kernel32.dll` file. Sogen emulates the user land part of `CreateFile` all the way down to the syscall. At that point, the Sogen "kernel" handles the system interaction, such as opening a file handle with that path.

The strength of this technique is that the behavior of the emulator is very close to that of Windows, because it is a Windows user land that is being emulated. The behavior of `CreateFile` and other APIs is very close to that of a real system. The downside, of course, is that you need to have a Windows user land available. To compare Sogen with the other emulators, see [Choose an emulator](https://docs.hex-rays.com/add-ons/malware/concepts/emulators.md#choose-an-emulator).

## Sogen root

We call this Windows user land the Sogen root. It is a directory of Windows system files, the DLLs and the registry hives. These files come from a Windows installation from Microsoft, so we cannot distribute them along with the Malware Analysis add-on. When you want to use Sogen, we expect you to provide the Sogen root, if you have the appropriate Windows license. We do not provide these files to you, but we do provide a program that fetches, configures, and installs them for you.

To set up the root, select **Extensions → Malware Analysis → Emulation → Set up Sogen...**. You can do one of four things:

* If you have an existing Sogen root directory, maybe from other research, import that directory.
* Import the Sogen root that the Sogen project provides. This is a zip file, such as `root.zip` from [sogen.dev](https://sogen.dev).
* If you have Windows installation media, give the path to the ISO file. The add-on extracts the Sogen root from it.
* If you have a license and you confirm this, the add-on downloads the Windows Server 2025 evaluation ISO from Microsoft and copies out the files that Sogen needs. The download is 7.6 GiB and needs about 10 GiB of free disk space. The add-on deletes the ISO at the end.

We want to make this as easy as possible for users who have a license, such as a Visual Studio (MSDN) subscription or a volume license, to work with Sogen and its Microsoft Windows user land. Before the add-on reads Microsoft media, it shows the license statements and asks you to confirm them. If you do not have the license for these files, then you should not use the Sogen emulator.

The setup runs in the background, so you can use IDA while it downloads. The add-on keeps the root in `<IDAUSR>/malware-analysis/emulator/sogen/root`. When a setup fails or you cancel it, the current root does not change. When a root exists, the menu item is **Manage Sogen root...**. It shows the source and the size of the root, and lets you replace or remove it. If the root is not usable, the dialog tells you why. When you start Sogen and you have no root, the add-on asks you to set one up.

To set up the root without the IDA GUI, for example on a machine where you use idalib, run `fetch-root.py` from the `ida-sogen-runtime` directory of the installed add-on with [uv](https://docs.astral.sh/uv/):

```bash
uv run fetch-root.py --download               # the Windows Server 2025 evaluation ISO from Microsoft
uv run fetch-root.py --iso server.iso         # a Windows ISO that you have
uv run fetch-root.py --zip root.zip           # a Sogen root archive, for example from sogen.dev
uv run fetch-root.py --directory path/to/root # a copy of an existing root
uv run fetch-root.py --status
uv run fetch-root.py --remove
```

With `--iso`, `--iso-list-images` lists the images in the ISO, and `--iso-image-index N` selects one, also with `--download`. To confirm the license statements without a prompt, add `--accept-terms`.

When you start Sogen in idat or idalib with no root, the Output window shows the full path of `fetch-root.py`.

From an ISO, the add-on selects an x64 image in this order: Server Core, Server, client. Server Core has no desktop components, no Visual C++ runtime (`vcruntime140.dll`), and no legacy DirectX DLLs, so programs that need these files do not run with a root from the evaluation ISO.

## How the add-on uses Sogen

The add-on includes a Sogen analyzer in the `ida-sogen-runtime` component, for Windows x86-64, Linux x86-64, Linux AArch64, and macOS on Apple silicon. We build it from the unmodified upstream source. For a copy of the source of the build, email <support@hex-rays.com>. The add-on runs the analyzer as a separate process and does not load it into IDA.

For [isolated system emulation](https://docs.hex-rays.com/add-ons/malware/concepts/isolated-system-emulation.md), select **Extensions → Malware Analysis → Emulation → Start interactive emulation → with Sogen**, or set the `backend` setting to `sogen` and click the toolbar button. The add-on starts the analyzer with a GDB server on `127.0.0.1` and connects IDA's remote GDB debugger to it. Sogen runs 64-bit PE files, and 32-bit PE files through WOW64. For a 32-bit sample, IDA shows the 32-bit registers and modules.

The sample runs in the emulator, never on your system, as described in [Isolation](https://docs.hex-rays.com/add-ons/malware/concepts/isolated-system-emulation.md#isolation). All sessions share the Sogen root, and the guest cannot change it. Each session gets its own copies of `C:\Users`, `C:\ProgramData`, and `C:\Windows\Temp`, and a copy of the sample and the files next to it in `C:\sample`, which is the working directory of the sample. When these files are larger than 512 MB, the add-on copies only the sample. Registry changes stay in the memory of the emulator. When the session ends, the add-on deletes the copies, so changes to files and the registry do not go into the next session.

By default, the network is offline. The sample can connect only to other sockets in the emulator, and DNS lookups fail. To let a sample download its next stage or contact its C2 server, set `sogen_network` to `live`. In this mode, the sample uses the real network of your host, the add-on logs a warning, and the [isolation](https://docs.hex-rays.com/add-ons/malware/concepts/isolated-system-emulation.md#isolation) does not apply to the network. The sample can then send the copies of the files next to it to the network.

For [automated unpacking](https://docs.hex-rays.com/add-ons/malware/concepts/automated-unpacking.md), set `default_debugger` to `sogen`. The unpacker then starts Sogen through the isolated system emulator and runs its heuristics on the emulated process.

Sogen is not a backend for [sandbox integration](https://docs.hex-rays.com/add-ons/malware/concepts/sandbox-integration.md). To import a trace from an emulator, use [Speakeasy](https://docs.hex-rays.com/add-ons/malware/concepts/emulators/speakeasy.md).

The `sogen_root` and `sogen_analyzer` settings of the isolated system emulator select a different root or analyzer, as described in [Configuration](https://docs.hex-rays.com/add-ons/malware/concepts/isolated-system-emulation.md#configuration).

If you have a question, an idea, or a problem, email <support@hex-rays.com>. The Malware Analysis team reads every message and replies quickly.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hex-rays.com/add-ons/malware/concepts/emulators/sogen.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
