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/yourusername/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.1.0.tar.gz (14.4 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.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ntparse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 45040745f11b54410726b77b17afc1f46f8501fbb88736bd7985415d20117479
MD5 7c08ea94d97fdee877163493114eed5f
BLAKE2b-256 053af2578385b9e1b8e909873d358729b00912b2bbcbabdf0e7e6dd02b0f116b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ntparse-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58b9763c22068d1ddc6502cb6d504d94663926a694bedd49a7a74d012d198245
MD5 b614b9eafa5b2da52a092497839dd407
BLAKE2b-256 debe1c67cb29e37e8bd30d7813765b633e3eb30a681d8001fbef0174b68e187e

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