An easy-to-use library for emulating code in minidump files.

Overview

dumpulator

Note: This is a work-in-progress prototype, please treat it as such.

An easy-to-use library for emulating code in minidump files.

Example

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

from dumpulator import Dumpulator

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

The test.dmp is collected at the entry point of the tests/StringEncryptionFun example.

Collecting the dump

There is a simple plugin for x64dbg available in the MiniDumpPlugin folder (you can also download a precompiled binary in the releases). To use it you 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

Credits

Comments
  • Implement a handle manager

    Implement a handle manager

    Handles are currently hacked in. Add a handle manager that allows something like this:

    def ZwCreateFile_syscall(...):
        handle_data = (...)
        hFile = dp.handles.new(data)
        return hFile
    
    def ZwReadFile_syscall(hFile: HANDLE, ...):
        handle_data = dp.handles.get(hFile, None)
        return
    
    def ZwCloseHandle(hFile):
        dp.handles.close(hFile)
    

    It should also support duplication (every handle points to refcounted data).

    feature 
    opened by mrexodia 5
  • Implementing a standalone memory manager

    Implementing a standalone memory manager

    This is the first pass of the memory manager, I have not implemented it into dumpulator code. On its own, it works, it is not optimized at all.

    Please let me know if you think anything should be done another way and how I should start replacing mem_map calls.

    opened by Calastrophe 4
  • x64 dump of x86 process fail to emulate

    x64 dump of x86 process fail to emulate

    I have noticed if you do a dump on x64 OS of a x86 process (from task manager or procdump64 for example) dumpulator would try to emulate everything in x64 even though most of the dump is actually x86 causing some unexpected behavior, it doesn't happen if you do a x86 dump from x32dbg or from procdump(32).

    feature 
    opened by thewhitegoatcb 4
  • Memory manager refactor

    Memory manager refactor

    I rewrote the memory manager to use the paging, although an issue that arose was that the checking function is a bit limited at the moment.

    I have had my hand at trying to improve it - it will detect if something was allocating in already allocated space, or "enveloping" allocated space, but if it were to have one 'foot' in at any side of the region - it won't catch the allocation error.

    This one is way faster ( mainly because the checker function had to be limited ), hopefully you guys can point me in the right direction if there is something glaringly wrong. Thanks.

    opened by Calastrophe 3
  • File Handle Fixes + New Functionality

    File Handle Fixes + New Functionality

    Latest update to the handle manager broke how normal files were loaded and used. This is intended to fix this issue as well as adding in new functionality.

    Inspired by the mapped files idea, I have implemented create_file within handles, this will depending on creation flags either open an existing file and load it in as a mapped file with it's data or create a new empty mapped file.

    It's not perfect yet but it's a good start in the right direction, this way when emulating something that relies on touching files we should in theory be able to follow and capture the changes without them effecting the system, I'm sure there will be bugs behind this, something like \\.\PhysicalDrive0 might be an issue but I hope it would just raise an exception rather than try to load the entire disk into memory...

    Added handles.create_file to add new files to mapped files Refactored FileObject and added write Added CreateDisposition flags Updated HandleTest exe

    opened by oopsmishap 3
  • Implement exception handling

    Implement exception handling

    When unicorn gets an exception it needs to build a stack frame and set EIP/RIP on KiUserExceptionDispatcher

    http://www.nynaeve.net/?p=201

    It also needs a test application and a prepared dump in Windows Sandbox for CI.

    feature 
    opened by mrexodia 3
  • Module Manager

    Module Manager

    First pass of a Module Manager for #17 Probably good for a PR as is but I would like to finish it and have good unit test coverage before then. Just creating the PR so you can have a look 👍

    opened by oopsmishap 2
  • Basic Export Forwaring

    Basic Export Forwaring

    Resolves export forwards.

    1. In Module's _parse_pe, if export points to .rdata store as an export forwarder (only caveat is x64 ntdll.dll's RtlNtdllName which is located in .rdata)
    2. After all modules have been loaded in iterate over modules to then parse the export forwarders, this is done by overwriting the current export address with the resolved forward export's address
    3. If we could not resolve the forwarder leave address to zero and assert we could not resolve the function within find_export

    Currently does not resolve API sets, but we can cross that bridge later.

    opened by oopsmishap 1
  • Incorrect width for Enums in 64bit

    Incorrect width for Enums in 64bit

    When a syscall is processes an enum with a 64bit dump the value is treated as a 64bit integer. Within Windows syscalls most enums are treated as 32bit values. I can't find the documentation for this but if you start going through syscalls that use enums you will notice the trend.

    When a syscall with an enum is called Dumpulator processes it as the following resulting in a ValueError

    Error: ValueError: 549755813892 is not a valid FSINFOCLASS
    
    549755813892 = 0x8000000004
    
    Previous argument in the call had the value: 0x8
    

    I have tried to implement a CTypes style of python enum's to no avail. The following hotfix is enough to fix the issue, but could run into issues if an enum size is anything other than 32bit wide, however I have yet to find one that isn't 32bit wide.

    elif issubclass(argtype, Enum):
        try:
            argvalue = argtype(dp.args[i] & 0xFFFFFFFF)
        except KeyError as x:
            raise Exception(f"Unknown enum value {dp.args[i]} for {type(argtype)}")
    
    opened by oopsmishap 1
  • Handle manager

    Handle manager

    PR for #16 for the implantation of a handle manager.

    Also added needed syscall functionality to get simple file reads working. Source I tested is included with the PR. This currently is working for 32bit.

    Unicorn failed on 64bit due to the extended instruction set usage within ntdll!memset

    opened by oopsmishap 1
  • Fix loading of kernel32 on modern systems

    Fix loading of kernel32 on modern systems

    SizeOfImage is not consecutive in memory. So unicorn fails to read the memory. Fix would be to read the memory in chunks of 0x1000 pages, or only pass the first page to pefile and load in pages when necessary.

    bug good first issue 
    opened by mrexodia 1
  • Dumpulator takes a long time to load when handling large dumps

    Dumpulator takes a long time to load when handling large dumps

    Feature Request: Please look into addressing the issue where large dump files aren't easily processed by dumpulator.

    Description: Dumpulator is taking an excessively long time to load a dump file of 40MB. I was testing the decryption of an RC4 encrypted configuration block from gh0stRAT. I dumped out the process and it was 40MB. I fed this dump into dumpulator and it was still trying to load after 20 minutes.

    Sample: https://www.virustotal.com/gui/file/0a9c881b857d4044cb6dfeba682190d7d9dc6ef94bc149cac77f3e0f65e9c69a

    feature 
    opened by gakar06 3
  • Proper (extensible) testing

    Proper (extensible) testing

    Currently the "tests" are just running the "getting-started" examples. This doesn't scale and makes it difficult to find regressions.

    The test framework:

    • [x] A single unified Visual Studio solution with test executables
    • [ ] Build the solution with GitHub Actions so new feature PRs can be tested in the same PR
    • [x] A dump of a minimal Windows usermode environment (ntdll, kernel32, kernelbase, x64+x86)
    • [x] A dump of a more "complete" environment (winsock, cryptapi, advapi32, shell32, user32, etc.)
    • [x] Load the test executables with dp.map_module
    • [x] Execute the (exported) test functions on a fresh Dumpulator instance each time
    • [ ] Calculate code coverage per test

    Necessary tests:

    All of these should use /NODEFAULTLIB to not have to care about the MSVC runtime initialization (which uses a lot of unimplemented syscalls)

    • [ ] ExceptionTest (for testing different exception scenarios)
    • [ ] LoadLibrary (to test map_module and the whole PEB loading chain)
    • [ ] StringEncryptionFun
    • [ ] More depending on coverage...
    feature 
    opened by mrexodia 0
  • Trace points

    Trace points

    The idea would be to generate a unique number for each syscall invocation and print it in the log. The sequence should be deterministic for a given dumpulator version (although preferably across versions as well). Uses cases:

    • "Breakpoint" (stop emulation or literally a debugger breakpoint) at a certain ID you saw previously in the log for closer inspection.
    • Enable single step tracing (slow) only after/between trace points.
    • Dump the state after a certain trace point to avoid re-running the same code over and over again (needs #13)
    feature 
    opened by mrexodia 0
  • Saving/restoring state

    Saving/restoring state

    Right now the state after a .call or .start persists. It would be nice to have a feature to roll back memory changes without having to reload the dump.

    I think unicorn has a feature for this.

    feature 
    opened by mrexodia 1
  • Design ctypes equivalent for syscall implementation

    Design ctypes equivalent for syscall implementation

    Currently the type system for syscalls is very rough and you need to do a lot of manual work. A type system similar to ctypes needs to be implemented where you can set struct members, work with enums etc.

    Once the type system is complete a pdb/header parser can be implemented to support all the native types.

    feature 
    opened by mrexodia 1
Releases(v0.1.2)
  • v0.1.2(Jan 6, 2023)

  • v0.1.1(Nov 23, 2022)

    What's Changed

    • Fix for argument width for Enums by @oopsmishap in https://github.com/mrexodia/dumpulator/pull/31
    • Basic Export Forwaring by @oopsmishap in https://github.com/mrexodia/dumpulator/pull/32
    • Start implementing a test framework https://github.com/mrexodia/dumpulator/pull/33
    • Fix a crash when fetching instructions from unmapped memory
    • Support WRITECOMBINE, NOCACHE and GUARD pages
    • Fix regression where 32-bit pointers were not masked correctly
    • Emulate unsupported instructions (RDRAND)
    • Improve performance of the memory map on startup

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Oct 11, 2022)

    What's Changed

    • Initial version of exception support, VEH, VCH, SEH, UnhandledExceptionFilter are all working!
    • 8 implement write byte write word by @oopsmishap in https://github.com/mrexodia/dumpulator/pull/18
    • Handle manager by @oopsmishap in https://github.com/mrexodia/dumpulator/pull/19
    • Added support for setting/getting flags in Registers() by @Calastrophe in https://github.com/mrexodia/dumpulator/pull/20
    • File Handle Fixes + New Functionality by @oopsmishap in https://github.com/mrexodia/dumpulator/pull/21
    • Implementing a standalone memory manager by @Calastrophe in https://github.com/mrexodia/dumpulator/pull/22
    • New memory manager by @mrexodia in https://github.com/mrexodia/dumpulator/pull/25
    • Module manager by @oopsmishap and @mrexodia in https://github.com/mrexodia/dumpulator/pull/26

    New Contributors

    • @Calastrophe made their first contribution in https://github.com/mrexodia/dumpulator/pull/20

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.11...v0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.0.11(Jun 20, 2022)

    What's Changed

    • Documentation improvements
    • Minor bugfixes

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.10...v0.0.11

    Source code(tar.gz)
    Source code(zip)
  • v0.0.10(Apr 4, 2022)

    What's Changed

    • Use the thread that caused the exception in the dump instead of the first thread

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.9...v0.0.10

    Source code(tar.gz)
    Source code(zip)
  • v0.0.9(Mar 20, 2022)

    What's Changed

    • Add support for Dumpulator(quiet=True)
    • Allow dp.regs[name]
    • Stores handles in Dumpulator class
    • Implement a few more syscalls

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.8...v0.0.9 @mrexodia

    Source code(tar.gz)
    Source code(zip)
  • v0.0.8(Mar 11, 2022)

    What's Changed

    • Add empty bodies for every single syscall by @mrexodia in https://github.com/mrexodia/dumpulator/pull/11

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.7...v0.0.8

    Source code(tar.gz)
    Source code(zip)
  • v0.0.7(Dec 23, 2021)

    What's Changed

    • Support unicorn2 by @jtorreno in https://github.com/mrexodia/dumpulator/pull/7
    • Add support for dp.call(0x140001000, regs={'rcx': temp_addr, 'rdx': 0x140017000})

    New Contributors

    • @jtorreno made their first contribution in https://github.com/mrexodia/dumpulator/pull/7

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.6...v0.0.7

    Source code(tar.gz)
    Source code(zip)
  • v0.0.5(Nov 29, 2021)

    • Deterministic order for operand registers in trace
    • Remove trap flag at the beginning of a trace and set gs_base
    • Decode utf-16 strings properly
    • Fix a bug with memory mapping addresses >= 0x80000000 on 32-bit
    • Add a helper script to convert x64dbg traces to dumpulator traces
    • Ignore some files and stub ZwQueryInformationToken

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.4...v0.0.5

    Source code(tar.gz)
    Source code(zip)
  • v0.0.4(Nov 24, 2021)

    What's Changed

    • Improve the trace format to make it more human-readable (include module transitions and export labels)

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.3...v0.0.4

    Source code(tar.gz)
    Source code(zip)
  • v0.0.3(Nov 21, 2021)

    What's Changed

    • Polish README
    • Initial implementation of 32-bit processes
    • Move the MiniDumpPlugin to a separate repository
    • Add GitHub Actions to publish to PyPI

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.2...v0.0.3

    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(Nov 21, 2021)

    What's Changed

    • Vendor the locally patched minidump library, see: https://github.com/skelsec/minidump/pull/28

    Full Changelog: https://github.com/mrexodia/dumpulator/compare/v0.0.1...v0.0.2

    Source code(tar.gz)
    Source code(zip)
Owner
Duncan Ogilvie
Passionate C++ developer and reverse engineer. Main developer of @x64dbg. Also familiar with C#, Haskell, Assembly, Python and a bunch of web-related languages.
Duncan Ogilvie
A simple bulk file renamer, written in python.

Python File Editor A simple bulk file renamer, written in python. There are two functions, the bulk rename and the bulk file extention change. Bulk Fi

Sam Bloomfield 2 Dec 22, 2021
Python code snippets for extracting PDB codes from .fasta files

Python_snippets_for_bioinformatics Python code snippets for extracting PDB codes from .fasta files If you have a single .fasta file for all protein se

Sofi-Mukhtar 3 Feb 09, 2022
FileGenerator - File Generator for sites that accepts documents

File Generator for sites that accepts documents This code generates files as per

Shaunak 2 Mar 19, 2022
Python module that parse power builder file (PBD) and analyze code

PowerBuilder-decompile Python module that parse power builder file (PBD) and analyze code (Incomplete) this tool is composed of: pbd_dump.py pbd file

Samy Sultan 8 Dec 15, 2022
Python file organizer application

Python file organizer application

Pak Maneth 1 Jun 21, 2022
Python script for converting figma produced SVG files into C++ JUCE framework source code

AutoJucer Python script for converting figma produced SVG files into C++ JUCE framework source code Watch the tutorial here! Getting Started Make some

SuperConductor 1 Nov 26, 2021
A file utility for accessing both local and remote files through a unified interface.

A file utility for accessing both local and remote files through a unified interface.

AI2 19 Nov 16, 2022
This python project contains a class FileProcessor which allows one to grab a file and get some meta data and header information from it

This python project contains a class FileProcessor which allows one to grab a file and get some meta data and header information from it. In the current state, it outputs a PrettyTable to txt file as

Joshua Wren 1 Nov 09, 2021
This simple python script pcopy reads a list of file names and copies them to a separate folder

pCopy This simple python script pcopy reads a list of file names and copies them to a separate folder. Pre-requisites Python 3 (ver. 3.6) How to use

Madhuranga Rathnayake 0 Sep 03, 2021
Simple addon to create folder structures in blender.

BlenderCreateFolderStructure Simple Add-on to create a folder structure in Blender. Installation Download BlenderCreateFolderStructure.py Open Blender

Dominik Strasser 2 Feb 21, 2022
Automatically generates a TypeQL script for doing entity and relationship insertions from a .csv file, so you don't have to mess with writing TypeQL.

Automatically generates a TypeQL script for doing entity and relationship insertions from a .csv file, so you don't have to mess with writing TypeQL.

3 Feb 09, 2022
Annotate your Python requirements.txt file with summaries of each package.

Summarize Requirements 🐍 📜 Annotate your Python requirements.txt file with a short summary of each package. This tool: takes a Python requirements.t

Zeke Sikelianos 8 Apr 22, 2022
Find potentially sensitive files

find_files Find potentially sensitive files This script searchs for potentially sensitive files based off of file name or string contained in the file

4 Aug 20, 2022
Small-File-Explorer - I coded a small file explorer with several options

Petit explorateur de fichier / Small file explorer Pour la première option (création de répertoire) / For the first option (creation of a directory) e

Xerox 1 Jan 03, 2022
File support for asyncio

aiofiles: file support for asyncio aiofiles is an Apache2 licensed library, written in Python, for handling local disk files in asyncio applications.

Tin Tvrtković 2.1k Jan 01, 2023
Dragon Age: Origins toolset to extract/build .erf files, patch language-specific .dlg files, and view the contents of files in the ERF or GFF format

DAOTools This is a set of tools for Dragon Age: Origins modding. It can patch the text lines of .dlg files, extract and build an .erf file, and view t

8 Dec 06, 2022
This program can help you to move and rename many files at once

This program can help you to rename and save many files in a folder in seconds, but don't give the same name to files, it can delete both files.

João Assalim 1 Oct 10, 2022
This is just a GUI that detects your file's real extension using the filetype module.

Real-file.extnsn This is just a GUI that detects your file's real extension using the filetype module. Requirements Python 3.4 and above filetype modu

1 Aug 08, 2021
Ini adalah program python untuk mengubah background foto dalam 1 folder, tidak perlu satu satu

Myherokuapp my web drive You can see my web drive and can request film/Application do you want in here my blog you can visit my blog RemBg ini adalah

XnuxersXploitXen 13 Dec 01, 2022
Object-oriented file system path manipulation

path (aka path pie, formerly path.py) implements path objects as first-class entities, allowing common operations on files to be invoked on those path

Jason R. Coombs 1k Dec 28, 2022