• Stars
    star
    471
  • Rank 89,649 (Top 2 %)
  • Language
    Python
  • License
    Boost Software Li...
  • Created over 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An easy-to-use library for emulating memory dumps. Useful for malware analysis (config extraction, unpacking) and dynamic analysis in general (sandboxing).

dumpulator

Note: This is a work-in-progress prototype, please treat it as such. Pull requests are welcome! You can get your feet wet with good first issues

An easy-to-use library for emulating code in minidump files. Here are some links to posts/videos using dumpulator:

Feel free to send a pull request to add your article here!

Examples

Calling a function

The example below opens StringEncryptionFun_x64.dmp (download a copy here), allocates some memory and calls the decryption function at 0x140001000 to decrypt the string at 0x140017000:

from dumpulator import Dumpulator

dp = Dumpulator("StringEncryptionFun_x64.dmp")
temp_addr = dp.allocate(256)
dp.call(0x140001000, [temp_addr, 0x140017000])
decrypted = dp.read_str(temp_addr)
print(f"decrypted: '{decrypted}'")

The StringEncryptionFun_x64.dmp is collected at the entry point of the tests/StringEncryptionFun example. You can get the compiled binaries for StringEncryptionFun here

Tracing execution

from dumpulator import Dumpulator

dp = Dumpulator("StringEncryptionFun_x64.dmp", trace=True)
dp.start(dp.regs.rip)

This will create StringEncryptionFun_x64.dmp.trace with a list of instructions executed and some helpful indications when switching modules etc. Note that tracing significantly slows down emulation and it's mostly meant for debugging.

Reading utf-16 strings

from dumpulator import Dumpulator

dp = Dumpulator("my.dmp")
buf = dp.call(0x140001000)
dp.read_str(buf, encoding='utf-16')

Running a snippet of code

Say you have the following function:

00007FFFC81C06C0 | mov qword ptr [rsp+0x10],rbx       ; prolog_start
00007FFFC81C06C5 | mov qword ptr [rsp+0x18],rsi
00007FFFC81C06CA | push rbp
00007FFFC81C06CB | push rdi
00007FFFC81C06CC | push r14
00007FFFC81C06CE | lea rbp,qword ptr [rsp-0x100]
00007FFFC81C06D6 | sub rsp,0x200                      ; prolog_end
00007FFFC81C06DD | mov rax,qword ptr [0x7FFFC8272510]

You only want to execute the prolog and set up some registers:

from dumpulator import Dumpulator

prolog_start = 0x00007FFFC81C06C0
# we want to stop the instruction after the prolog
prolog_end = 0x00007FFFC81C06D6 + 7

dp = Dumpulator("my.dmp", quiet=True)
dp.regs.rcx = 0x1337
dp.start(begin=prolog_start, end=prolog_end)
print(f"rsp: {hex(dp.regs.rsp)}")

The quiet flag suppresses the logs about DLLs loaded and memory regions set up (for use in scripts where you want to reduce log spam).

Custom syscall implementation

You can (re)implement syscalls by using the @syscall decorator:

from dumpulator import *
from dumpulator.native import *
from dumpulator.handles import *
from dumpulator.memory import *

@syscall
def ZwQueryVolumeInformationFile(dp: Dumpulator,
                                 FileHandle: HANDLE,
                                 IoStatusBlock: P[IO_STATUS_BLOCK],
                                 FsInformation: PVOID,
                                 Length: ULONG,
                                 FsInformationClass: FSINFOCLASS
                                 ):
    return STATUS_NOT_IMPLEMENTED

All the syscall function prototypes can be found in ntsyscalls.py. There are also a lot of examples there on how to use the API.

To hook an existing syscall implementation you can do the following:

import dumpulator.ntsyscalls as ntsyscalls

@syscall
def ZwOpenProcess(dp: Dumpulator,
                  ProcessHandle: Annotated[P[HANDLE], SAL("_Out_")],
                  DesiredAccess: Annotated[ACCESS_MASK, SAL("_In_")],
                  ObjectAttributes: Annotated[P[OBJECT_ATTRIBUTES], SAL("_In_")],
                  ClientId: Annotated[P[CLIENT_ID], SAL("_In_opt_")]
                  ):
    process_id = ClientId.read_ptr()
    assert process_id == dp.parent_process_id
    ProcessHandle.write_ptr(0x1337)
    return STATUS_SUCCESS

@syscall
def ZwQueryInformationProcess(dp: Dumpulator,
                              ProcessHandle: Annotated[HANDLE, SAL("_In_")],
                              ProcessInformationClass: Annotated[PROCESSINFOCLASS, SAL("_In_")],
                              ProcessInformation: Annotated[PVOID, SAL("_Out_writes_bytes_(ProcessInformationLength)")],
                              ProcessInformationLength: Annotated[ULONG, SAL("_In_")],
                              ReturnLength: Annotated[P[ULONG], SAL("_Out_opt_")]
                              ):
    if ProcessInformationClass == PROCESSINFOCLASS.ProcessImageFileNameWin32:
        if ProcessHandle == dp.NtCurrentProcess():
            main_module = dp.modules[dp.modules.main]
            image_path = main_module.path
        elif ProcessHandle == 0x1337:
            image_path = R"C:\Windows\explorer.exe"
        else:
            raise NotImplementedError()
        buffer = UNICODE_STRING.create_buffer(image_path, ProcessInformation)
        assert ProcessInformationLength >= len(buffer)
        if ReturnLength.ptr:
            dp.write_ulong(ReturnLength.ptr, len(buffer))
        ProcessInformation.write(buffer)
        return STATUS_SUCCESS
    return ntsyscalls.ZwQueryInformationProcess(dp,
                                                ProcessHandle,
                                                ProcessInformationClass,
                                                ProcessInformation,
                                                ProcessInformationLength,
                                                ReturnLength
                                                )

Custom structures

Since v0.2.0 there is support for easily declaring your own structures:

from dumpulator.native import *

class PROCESS_BASIC_INFORMATION(Struct):
    ExitStatus: ULONG
    PebBaseAddress: PVOID
    AffinityMask: KAFFINITY
    BasePriority: KPRIORITY
    UniqueProcessId: ULONG_PTR
    InheritedFromUniqueProcessId: ULONG_PTR

To instantiate these structures you have to use a Dumpulator instance:

pbi = PROCESS_BASIC_INFORMATION(dp)
assert ProcessInformationLength == Struct.sizeof(pbi)
pbi.ExitStatus = 259  # STILL_ACTIVE
pbi.PebBaseAddress = dp.peb
pbi.AffinityMask = 0xFFFF
pbi.BasePriority = 8
pbi.UniqueProcessId = dp.process_id
pbi.InheritedFromUniqueProcessId = dp.parent_process_id
ProcessInformation.write(bytes(pbi))
if ReturnLength.ptr:
    dp.write_ulong(ReturnLength.ptr, Struct.sizeof(pbi))
return STATUS_SUCCESS

If you pass a pointer value as a second argument the structure will be read from memory. You can declare pointers with myptr: P[MY_STRUCT] and dereferences them with myptr[0].

Collecting the dump

There is a simple x64dbg plugin available called MiniDumpPlugin The minidump command has been integrated into x64dbg since 2022-10-10. To create a dump, pause execution and execute the command MiniDump my.dmp.

Installation

From PyPI (latest release):

python -m pip install dumpulator

To install from source:

python setup.py install

Install for a development environment:

python setup.py develop

Related work

  • Dumpulator-IDA: This project is a small POC plugin for launching dumpulator emulation within IDA, passing it addresses from your IDA view using the context menu.
  • wtf: Distributed, code-coverage guided, customizable, cross-platform snapshot-based fuzzer designed for attacking user and / or kernel-mode targets running on Microsoft Windows
  • speakeasy: Windows sandbox on top of unicorn.
  • qiling: Binary emulation framework on top of unicorn.
  • Simpleator: User-mode application emulator based on the Hyper-V Platform API.

What sets dumpulator apart from sandboxes like speakeasy and qiling is that the full process memory is available. This improves performance because you can emulate large parts of malware without ever leaving unicorn. Additionally only syscalls have to be emulated to provide a realistic Windows environment (since everything actually is a legitimate process environment).

Credits

More Repositories

1

TitanHide

Hiding kernel-driver for x86/x64.
C
1,694
star
2

AppInitHook

Global user-mode hooking framework, based on AppInit_DLLs. The goal is to allow you to rapidly develop hooks to inject in an arbitrary process.
C
127
star
3

lolbin-poc

Small PoC of using a Microsoft signed executable as a lolbin.
C++
112
star
4

NtPhp

Ever wanted to execute PHP in your kernel driver? Look no further!
C
88
star
5

akt

Armadillo Key Tool
C++
78
star
6

JitMagic

Simple tool that allows you to have multiple Just-In-Time debuggers at once.
C#
67
star
7

haxxmap

Some simple go tools to perform a Man-in-the-middle (MITM) attack on your IMAP server in case you forgot your password.
Go
62
star
8

EfiCMake

CMake template for a basic EFI application/bootkit. This library is header-only, there is no EDK2 runtime!).
C++
59
star
9

driver_unpacking

Ghetto user mode emulation of Windows kernel drivers.
C
58
star
10

ArmaG3ddon

ArmaG3ddon by CondZero/ARTeam
C++
49
star
11

idapatch

IDA plugin to patch IDA Pro in memory.
C++
45
star
12

MiniDumpPlugin

Simple x64dbg plugin to save a full memory dump
CMake
41
star
13

perfect-dll-proxy

Perfect DLL Proxying using forwards with absolute paths.
Python
29
star
14

YaraGen

Plugin for x64dbg to generate Yara rules from function basic blocks.
C
27
star
15

REToolSync

Collaboration platform for reverse engineering tools.
C++
27
star
16

PatternFinder

Parallel signature matcher in C#
C#
26
star
17

zig-cross

Example of using as a CMake Toolchain for cross compiling.
CMake
25
star
18

CEAutoAttach

Tool to automatically make Cheat Engine attach to a process via the command line.
C++
25
star
19

Diff

Diff plugin for x64dbg
C
24
star
20

portable-executable-library

Automatically exported from code.google.com/p/portable-executable-library
C++
21
star
21

WorkraveQt

Modern reimplementation of Workrave in Qt. Optimized to look out for you where you don't.
C++
20
star
22

IATFaker

Small project to generate fake DLLs based on an executable's import table
C++
20
star
23

DotNetPluginCS

DotNetPluginCS based on:
C#
18
star
24

FunUtils

Just some fun utilities I wrote for productivity reasons.
C#
18
star
25

VMHunt_instracelog

Windows build files for the VMHunt Intel PIN Trace tool
17
star
26

CpConverter

Code Page Converter - Convert HTML/Text files to different encoding formats e.g. ANSI to UTF-8 or Unicode. Convert multiple files with 1 click. Works with all encodings.
C#
17
star
27

VMProtectTest

VMProtectTest
C++
16
star
28

WibuDebugHook

Injectable DLL that helps with debugging Wibu CodeMeter.
C
15
star
29

go-gitea-webhook

Simple webhook receiver implementation for Gitea/Gogs.
Go
15
star
30

regstep

Simple x64dbg plugin to show registers on every step.
C
13
star
31

DisableParallelLoader

Plugin for x64dbg to disable parallel loading of dependencies
CMake
13
star
32

AStyleHelper

Simple tool to perform AStyle formatting in a git repository.
C#
12
star
33

DarkSouls3.TextViewer

This tool helps you view all in-game text of Dark Souls 3.
C#
11
star
34

cxx-common-cmake

Experiment building lifting-bits dependencies with pure CMake
CMake
11
star
35

mrexodia.github.io

Personal blog
CSS
10
star
36

rosetta-multipass

Use Rosetta to run amd64 binaries on your M1 with Multipass.
Python
10
star
37

StackContains

Sample x64dbg plugin to scan the stack during tracing.
C
9
star
38

BoomPowGui

Simple C# GUI for BoomPow (banano miner).
C#
9
star
39

SN8F2288_gui

Interactive disassembler and emulator for the SN8F2288.
C++
9
star
40

NoFlashWindow

Disables FlashWindow and FlashWindowEx using AppInit_DLLs hook.
C++
9
star
41

Utf8Ini

Small C++ INI Parser.
C++
8
star
42

BreakpointUnresolved

Plugin for x64dbg to break on unresolved APIs.
C
8
star
43

imgui_cmkr

Experimental imgui app framework for rapid prototyping.
7
star
44

DrDecode

Simple plugin for x64dbg to decode debug registers
C
7
star
45

cloudflare-redirect

Simple CloudFlare Worker to implement a service similar to redirect.name, but with HTTPS support.
JavaScript
7
star
46

SimpleAutoItCrypter

Simple AutoIt crypter.
C++
7
star
47

gogitterirc

Gitter/IRC Sync bot written in Go
Go
7
star
48

YaraFlirt

Project to convert F.L.I.R.T. Signatures signatures to Yara Rules.
C#
6
star
49

Arxan

Some super old control flow exploration experiments
C
6
star
50

TracePlugin

Very simple trace plugin example for x64dbg.
C
6
star
51

pygame_qt

Combinding pygame and PyQt5 in python3
Python
6
star
52

crypto

Small, fast, header only, zero dependency cryptographic library.
C++
6
star
53

GitIdentityManagerCpp

Very simple cross-platform utility to manage your git identities.
C++
5
star
54

svelte-cpp-whiskey-list

Example Svelte frontend with C++ backend
C++
5
star
55

LivecodingTwitch

Bot to synchronize Livecoding and Twitch chats.
C++
5
star
56

CMakeMASM

CMake
4
star
57

BrainfuckInterpreter

Simple brainfuck interpreter written for Quora.
C++
4
star
58

PasteFile

Plugin for x64dbg to paste a file in memory...
C
4
star
59

AsmParser

Loose parser for x86 assembly, used for translating them into IR.
C++
4
star
60

ClickCatcher

Example plugin for x64dbg to handle mouse click events.
C
4
star
61

unicorn_template

Project template for unicorn based on CPM.
CMake
4
star
62

IXWebSocket_template

Simple template for IXWebSocket (websocket and http client/server library for C++) based on CPM.
CMake
4
star
63

VTIL-Hello

Example CMake project for VTIL.
C++
4
star
64

CutterUpdater

Very simple utility to automatically check for, download and install the latest version of Cutter.
C#
4
star
65

XInputScanner

Tool for x360ce to scan which XInput DLL is used.
C#
4
star
66

BatchDecompiler

Script to batch-decompile things with IDA.
C#
4
star
67

SMMNEX

010 editor binary templates for SMM NEX
3
star
68

JNIEnv

Plugin to assist in reverse engineering programs that use JNI.
C
3
star
69

debuggerpyd

Random Script DLL for x64dbg
C
3
star
70

TimeStampFormat

Example plugin to print a timestamp in the log.
C
3
star
71

gotgslack

Telegram/Slack synchronization bot.
Go
3
star
72

GleeDbg

Experiments with imgui
C++
3
star
73

NativeExport

Very simple example of native exports with C# and C++
C#
3
star
74

vergiliusparser

Simple script to scrape https://www.vergiliusproject.com/
Python
3
star
75

ExtendDumpSel

Plugin for x64dbg to add a command that extends the dump selection
C
3
star
76

StaticEngine

Playground for statically loading files into x64dbg.
C
3
star
77

ModulePathList

A simple x64dbg plugin to list modules with their paths.
C
2
star
78

cgit-theme

A theme for cgit
CSS
2
star
79

ExpressionParser

Very simple expression parser for binary operations with operator precedence, unary minus/plus/NOT and parentheses.
C#
2
star
80

CMakePackageExample

CMake
2
star
81

fluffy-adventure

Some testing code with binary visualization
C++
2
star
82

reimagined-umbrella

2
star
83

SwigSample

SwigSample with C#
C#
2
star
84

miasm-old

Automatically exported from code.google.com/p/miasm
Python
2
star
85

yara_vs13

The pattern matching swiss knife (used by x64dbg).
C
2
star
86

QClickableMenu

Project to support the triggered signal of the QMenu::menuAction if you click on the QMenu.
C++
2
star
87

cryptopals

My solutions to the cryptopals crypto challenges.
Objective-C
2
star
88

RestartSpam

Simple plugin to spam restarts in x64dbg
CMake
2
star
89

VisualMutatorGUI

Simple GUI to visualize a results file from VisualMutator.
C#
2
star
90

pybind11_example

CMake
2
star
91

kraken

Go
2
star
92

knowledge-base

Knowledge base watching and scraping service.
TypeScript
2
star
93

angelscript-cpp-interface-generator

Automatically exported from code.google.com/p/angelscript-cpp-interface-generator
Python
2
star
94

SimpleIATParser

C++
1
star
95

DebugLoopRace

C
1
star
96

reversi

C#
1
star
97

mandelbrot

C#
1
star
98

RotMG.Common

Common utility library for RotMG by creepylava.
C#
1
star
99

python64

Hack to have both python and python64 in your PATH environment variable.
C++
1
star
100

OpenCVTest

A test CLion/CMake project for OpenCV 3 on OS X.
CMake
1
star