Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:416rehman DeepZero PEIngest

From Leeroopedia
Knowledge Sources
Domains PE_Analysis, Ingest, Security_Research
Last Updated 2026-10-27 00:00 GMT

Overview

External IngestProcessor that discovers PE files, parses headers via LIEF, and extracts driver metadata including kernel-driver detection, IOCTL surface analysis, dangerous import detection, and vulnerability priority scoring.

Description

The PEIngest class is an external IngestProcessor (located in processors/pe_ingest/) that discovers Portable Executable files and extracts rich metadata from their PE headers. It uses the lief library (optional [pe] extra) to parse PE structure, imports, and signatures.

Metadata extracted per file:

  • Identity: sha256, md5, size_bytes, imphash
  • PE structure: is_valid_pe, subsystem (NATIVE=kernel driver, GUI=1, etc.), is_kernel_driver, machine_type
  • Imports: imported_dlls, imported_functions
  • IOCTL surface: has_ioctl_surface (checks for IoCreateDevice, IoCreateSymbolicLink, etc.), creates_device, creates_symlink
  • Dangerous APIs: dangerous_imports (MmMapIoSpace, ZwMapViewOfSection, __readmsr, etc.)
  • Signing: is_signed
  • Priority score: 0-10 score weighted by IOCTL surface, physical memory access, process manipulation, MSR I/O, section count, and OS version

A subsystem_filter config option can restrict ingestion to specific subsystems (e.g., [1] for NATIVE/kernel drivers only). File analysis runs in a ThreadPoolExecutor with I/O and parsing parallelized.

Usage

  • BYOVD driver ingestion: extensions: [".sys"], subsystem_filter: [1]
  • Scanning specific subdirectories: subdirs: ["DP_Chipset", "DP_Display"]
  • Limiting corpus size: limit: 500

Code Reference

Source Location

  • Repository: DeepZero
  • File: processors/pe_ingest/pe_ingest.py

Signature

class PEIngest(IngestProcessor):
    description = "discovers portable executable files, parses PE headers, and extracts driver metadata"
    version = "2.0"
    provides = ("sha256", "md5", "size_bytes")

    def process(self, ctx: ProcessorContext, target: Path) -> list[Sample]: ...

Import

# Loaded via pipeline YAML as: processor: pe_ingest/pe_ingest.py:PEIngest
# Not imported directly; resolved by the registry from processors/ directory

I/O Contract

Inputs

Name Type Required Description
target Path Yes Driver pack directory or single PE file
extensions list[str] No (config) File extensions (default [".sys"])
recursive bool No (config) Walk subdirectories (default True)
subdirs list[str] No (config) Subdirectory name patterns to scan
subsystem_filter list[int] No (config) Restrict to PE subsystems (e.g., [1]=NATIVE)
limit int No (config) Max samples (0 = no limit)

Outputs

Name Type Description
returns list[Sample] One Sample per PE file
Sample.data dict sha256, md5, size_bytes, is_valid_pe, subsystem, is_kernel_driver, machine_type, imported_dlls, imported_functions, has_ioctl_surface, dangerous_imports, is_signed, priority_score, imphash

Usage Examples

BYOVD Pipeline YAML

stages:
  - name: discover
    processor: pe_ingest/pe_ingest.py:PEIngest
    config:
      extensions: [".sys"]
      recursive: true
      subdirs: ["DP_Chipset", "DP_Display", "DP_NM"]
      subsystem_filter: [1]  # NATIVE = kernel drivers only
      limit: 0

Priority Score Logic

# The priority score (0-10) is computed when has_ioctl_surface is True:
# +3.0 if imports include physical memory APIs (MmMapIoSpace, ZwMapViewOfSection, ...)
# +2.0 if imports include process manipulation (PsLookupProcessByProcessId, ...)
# +2.0 if imports include MSR I/O (__readmsr, __writemsr, HalGetBusDataByOffset, ...)
# +1.0 if <= 6 sections (smaller = more likely hand-crafted)
# +3.0 if OS version >= 10 (modern drivers are higher value targets)
# Capped at 10.0

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment