# parrotsec/mimikatz architecture

> Architecture diagram of the GitHub repository parrotsec/mimikatz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/parrotsec/mimikatz
- Repository: https://github.com/parrotsec/mimikatz

## Overview

##### Project type and purpose
- This is a low-level Windows security tool written in C/C++ (“mimikatz.exe”) with an optional kernel-mode driver (“mimidrv.sys”).
- It provides modules (sekurlsa, kerberos, crypto, vault, lsadump, token, etc.) to extract credentials, tickets, hashes, perform pass-the-hash/ticket, Golden Ticket attacks, and interact with Windows security subsystems.

##### File structure
- Top-level:
- README.md – project overview and usage
- mimicom.idl – COM interface definitions (if any)
- kiwi_passwords.yar – YARA rules for password detection
- debian/ – Debian packaging metadata (control, rules, install scripts)
- Build output trees:
- Win32/ – 32-bit builds: mimikatz.exe, mimidrv.sys, mimilove.exe
- x64/ – 64-bit builds: mimikatz.exe, mimidrv.sys
- The presence of a driver (WinDDK) and a desktop executable indicates a split user‐mode vs kernel‐mode architecture.

##### Pulling architecture hints from the README
- Core “mimikatz.exe” loads modules at runtime (e.g., sekurlsa::, kerberos::, crypto::, vault::, lsadump::).
- An optional driver (“mimidrv.sys”) is used for operations requiring direct kernel memory access or to bypass certain OS protections.
- Uses standard Windows APIs (LSA, CryptoAPI, CNG, Vault, SAM, Kerberos).

##### Main components
a. User-mode CLI front-end (mimikatz.exe)
b. Module loader / plugin manager (dispatches sekurlsa, kerberos, crypto, vault, lsadump, token modules)
c. Native library “mimilib” (common code shared by modules)
d. Optional kernel-mode driver (mimidrv.sys)
e. Windows security subsystems & processes:
- LSASS.exe (local logon session data)
- CryptoAPI / CNG
- Vault API
- SAM database / Active Directory calls
- Local or remote KDC / Domain Controller for Kerberos
f. Debian packaging pipeline (dpkg-build, control, rules) – can be shown as a peripheral CI/CD component if desired.

##### Relationships and data flows
- CLI issues a module command → module loader → invokes module code in process
- Module code may:
- Call mimilib routines for parsing memory structures
- Call standard Win32 APIs (LSA, Crypt32, NCrypt)
- Communicate with mimidrv.sys via DeviceIoControl for raw memory read/write
- Driver runs in kernel context → reads LSASS memory or modifies kernel objects → returns data back to user-mode
- For Kerberos operations: module calls KERB protocol over RPC to KDC, or writes .kirbi files to disk
- For Debian packaging: source files + compiled binaries → dpkg packaging → .deb artifacts

##### Architectural patterns and design principles
- Modular / plugin architecture for security modules
- Clear separation of privileges: user-mode vs kernel-mode
- Reuse of common code via “mimilib”
- Build matrix for multiple architectures (Win32, x64, ARM64)
- Packaging integration (Debian) for cross-platform distribution

##### Recommendations for high fidelity
- Be precise about the user-mode vs kernel-mode boundary
- Detail each module’s major dependencies (e.g., sekurlsa → LSASS memory structures)
- Optional paths (if driver not installed, module falls back to API)
- Build inputs (Visual Studio projects, WinDDK) and packaging steps separately at the bottom or side

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef user fill:#EFE,stroke:#333,stroke-width:1px;
    classDef usermode fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef kernel fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef ossvc fill:#98FB98,stroke:#333,stroke-width:1px;
    classDef storage fill:#98FB98,stroke:#333,stroke-width:1px;
    classDef domain fill:#98FB98,stroke:#333,stroke-width:1px;
    classDef component fill:#B0E0E6,stroke:#333,stroke-width:1px;
    classDef module fill:#87CEFA,stroke:#333,stroke-width:1px;
    classDef kernelcomp fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef output fill:#FFFFE0,stroke:#333,stroke-width:1px;
    classDef pkg fill:#FFDAB9,stroke:#333,stroke-width:1px;

    subgraph "Operator" 
        User["User (Operator)"]:::user
    end

    subgraph "User-Mode" 
        CLI["CLI Front-End\n(mimikatz.exe)"]:::component
        Loader["Module Loader"]:::component
        subgraph "Modules"
            sek["sekurlsa"]:::module
            ker["kerberos"]:::module
            cry["crypto"]:::module
            vault["vault"]:::module
            lsad["lsadump"]:::module
            tok["token"]:::module
        end
        lib["mimilib"]:::component
    end

    subgraph "Kernel-Mode"
        Driver["mimidrv.sys"]:::kernelcomp
    end

    subgraph "Windows Security Subsystems"
        LSASS["LSASS.exe"]:::ossvc
        CAPI["CryptoAPI / CNG"]:::ossvc
        VAPI["Vault API"]:::ossvc
        SAM["SAM Database"]:::storage
        KDC["Kerberos KDC / DC"]:::domain
    end

    subgraph "Output"
        Console["Console / Logs"]:::output
        Ffiles[".kirbi & Certificates"]:::output
    end

    subgraph "Debian Packaging"
        Control["debian/control\nchangelog\ncompat\ncopyright"]:::pkg
        Rules["debian/rules\nmimikatz.install"]:::pkg
        SourceFmt["debian/source/format\nwatch"]:::pkg
        Docs["debian/docs\ndirs"]:::pkg
    end

    User -->|runs| CLI
    CLI -->|loads modules| Loader
    Loader --> sek & ker & cry & vault & lsad & tok
    sek -->|uses| lib
    ker -->|uses| lib
    cry -->|uses| lib
    vault -->|uses| lib
    lsad -->|uses| lib
    tok -->|uses| lib
    sek -->|DeviceIoControl| Driver
    ker -->|RPC KERB| KDC
    cry -->|CryptoAPI| CAPI
    vault -->|Vault API| VAPI
    lsad -->|Memory API| LSASS
    tok -->|SAM API| SAM
    Driver -->|Reads/Writes| LSASS
    Loader -->|outputs to| Console
    ker -->|writes| Ffiles

    Control --> Rules
    Rules --> SourceFmt
    SourceFmt --> Docs

    click CLI "https://github.com/parrotsec/mimikatz/blob/master/Win32/mimikatz.exe"
    click CLI "https://github.com/parrotsec/mimikatz/blob/master/x64/mimikatz.exe"
    click Driver "https://github.com/parrotsec/mimikatz/blob/master/Win32/mimidrv.sys"
    click Driver "https://github.com/parrotsec/mimikatz/blob/master/x64/mimidrv.sys"
    click Control "https://github.com/parrotsec/mimikatz/tree/master/debian/control"
    click Control "https://github.com/parrotsec/mimikatz/tree/master/debian/changelog"
    click Control "https://github.com/parrotsec/mimikatz/tree/master/debian/compat"
    click Control "https://github.com/parrotsec/mimikatz/tree/master/debian/copyright"
    click Rules "https://github.com/parrotsec/mimikatz/tree/master/debian/rules"
    click Rules "https://github.com/parrotsec/mimikatz/blob/master/debian/mimikatz.install"
    click SourceFmt "https://github.com/parrotsec/mimikatz/tree/master/debian/source/format"
    click SourceFmt "https://github.com/parrotsec/mimikatz/tree/master/debian/watch"
    click Docs "https://github.com/parrotsec/mimikatz/tree/master/debian/docs"
    click Docs "https://github.com/parrotsec/mimikatz/tree/master/debian/dirs"
    click IDL "https://github.com/parrotsec/mimikatz/blob/master/mimicom.idl"
    click YARA "https://github.com/parrotsec/mimikatz/blob/master/kiwi_passwords.yar"

    IDL["mimicom.idl"]:::pkg
    YARA["kiwi_passwords.yar"]:::pkg

    class User user
    class CLI,Loader,lib component
    class sek,ker,cry,vault,lsad,tok module
    class Driver kernelcomp
    class LSASS,CAPI,VAPI,KDC ossvc
    class SAM storage
    class Control,Rules,SourceFmt,Docs pkg
    class Console,Ffiles output
```
