Skip to main content

A lightweight Python package for parsing syscalls from ntdll.dll

Project description

ntparse

A lightweight Python package for parsing syscalls from ntdll.dll on Windows systems.

Features

  • Easy syscall extraction from ntdll.dll using capstone disassembly
  • Multiple output formats: JSON, CSV, Assembly, Python dict
  • Command line interface for quick usage
  • Clean Python API for integration into your projects
  • Automatic path detection for default ntdll.dll location
  • Validation of PE files and syscall detection

Installation

pip install ntparse

Development Installation

git clone https://github.com/micREsoft/ntparse/ntparse.git
cd ntparse
pip install -e .

Quick Start

Command Line Usage

Parse with specific output format:

ntparse --format json --output syscalls.json
ntparse --format csv --output syscalls.csv
ntparse --format asm --output syscalls.asm
ntparse --format python --output syscalls.py

Parse from a custom ntdll.dll:

ntparse --input C:\path\to\ntdll.dll --format json
ntparse --input C:\path\to\ntdll.dll --format json --output done.json

Python API Usage

from ntparse import parse_ntdll, to_json, to_csv

# parse syscalls from default ntdll.dll
syscalls = parse_ntdll()

# parse from custom path
syscalls = parse_ntdll("C:\\Windows\\System32\\ntdll.dll")

# convert to different formats
json_output = to_json(syscalls)
csv_output = to_csv(syscalls)

print(f"Found {len(syscalls)} syscalls")

API Reference

Core Functions

parse_ntdll(path=None, arch="x64")

Parse syscalls from ntdll.dll.

Parameters:

  • path (str, optional): Path to ntdll.dll. If None, uses default Windows location
  • arch (str): Target architecture ("x64" or "x86"). Currently only x64 is supported

Returns:

  • dict: Dictionary mapping function names to syscall numbers

Example:

syscalls = parse_ntdll()
# returns: {"NtClose": 0x0C, "NtOpenProcess": 0x26, ...}

get_syscalls(dll_path)

Extract syscall numbers from a specific DLL file.

Parameters:

  • dll_path (str): Path to the ntdll.dll file

Returns:

  • dict: Dictionary mapping function names to syscall numbers

Formatter Functions

to_json(syscalls, output_file=None)

Convert syscalls to JSON format.

to_csv(syscalls, output_file=None)

Convert syscalls to CSV format.

to_asm(syscalls, output_file=None)

Convert syscalls to x64 assembly format.

to_python_dict(syscalls, output_file=None)

Convert syscalls to Python dictionary format.

Output Formats

JSON Format

{
  "syscalls": {
    "NtClose": "0x0C",
    "NtOpenProcess": "0x26",
    "NtCreateFile": "0x55"
  },
  "count": 3,
  "metadata": {
    "format": "json",
    "version": "1.0"
  }
}

CSV Format

Function Name, Syscall ID, Offset (hex)
NtClose, 12, 0x0C
NtOpenProcess, 38, 0x26
NtCreateFile, 85, 0x55

Assembly Format

.code

; Generated by ntparse
; Syscall stubs for x64

NtClose PROC
    mov r10, rcx
    mov eax. 0Fh
    syscall
    ret
NtClose ENDP

NtOpenProcess PROC
    mov r10, rcx
    mov eax, 026h
    syscall
    ret
NtOpenProcess ENDP

end

Command Line Options

usage: ntparse [-h] [--input INPUT] [--format {json,csv,asm,python}]
               [--output OUTPUT] [--arch {x64,x86}] [--validate]

Parse syscalls from ntdll.dll

options:
  -h, --help            show this help message and exit
  --input INPUT, -i INPUT
                        Path to ntdll.dll (default: C:\Windows\System32\ntdll.dll)
  --format {json,csv,asm,python}, -f {json,csv,asm,python}
                        Output format (default: json)
  --output OUTPUT, -o OUTPUT
                        Output file path (default: stdout)
  --arch {x64,x86}      Target architecture (default: x64)
  --validate            Validate ntdll.dll before parsing

Requirements

  • Python 3.7+
  • Windows OS (for ntdll.dll access)
  • pefile
  • capstone

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Acknowledgments

  • Built with pefile for PE parsing
  • Uses capstone for disassembly
  • Inspired by Windows syscall research and development tools

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntparse-0.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ntparse-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file ntparse-0.2.0.tar.gz.

File metadata

  • Download URL: ntparse-0.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for ntparse-0.2.0.tar.gz
Algorithm Hash digest
SHA256 01cc9aed30e448bb52c3130e3c81bd29f07b4fe4757a318435d74c5ecf7f5643
MD5 226b9e9977dcef6b7e3ada22146a1158
BLAKE2b-256 440f6382b28c02210a1926a2c385127f25e97a5b397d3c8cd249529f4f55db49

See more details on using hashes here.

File details

Details for the file ntparse-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ntparse-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for ntparse-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b566882057789b8f0017078cf30d61425d3fa2736b762642698de783bd2ec097
MD5 e085f413b3de1b56c7b48ec7ce5aa523
BLAKE2b-256 4aa22d3a5e734de95257a8d809a84b62f087b5ab146219ae1249737700ecd38c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page