Spartacus Toolkit

repository·main·Indexed 22 days ago

https://github.com/accenture/spartacus

A DLL and COM hijacking toolkit designed to automate the discovery and exploitation of hijacking vulnerabilities. It parses SysInternals Process Monitor logs to identify missing files and registry keys, scans for insecure ACLs, and generates Visual Studio proxy DLL projects. It features Ghidra integration for advanced function signature extraction, a detection mode for active DLL hijacking, and tools for generating self-signed certificates and signing DLL files.

Tokens
3.8K
Snippets
15
Records
17
Agent score
78%

What's inside Spartacus

  1. Generate DLL proxy Visual Studio solutions

    main

    Spartacus can generate Visual Studio skeleton projects to create proxy DLLs. It supports two main approaches:

    1. Simple Redirection: Redirects all exported functions back to the legitimate DLL. Payloads must be executed from DllMain.
    2. Ghidra-powered Proxying: Uses Ghidra to extract function signatures. This allows you to execute payloads from specific proxied functions (e.g., GetFileVersionInfoExW) instead of relying on DllMain.

    Usage Examples:

    Simple redirection (no function proxying):

    --mode proxy --dll C:\Windows\System32\version.dll --solution "C:\data\tmp\refactor-version" --overwrite --verbose --external-resources

    Advanced proxying with Ghidra: Extract signatures to create proxy functions for as many functions as possible.

    --mode proxy --ghidra C:\ghidra\support\analyzeHeadless.bat --dll C:\Windows\System32\userenv.dll --solution C:\Projects\spartacus-userenv --overwrite --verbose

    Proxy specific functions only:

    --mode proxy --ghidra C:\ghidra\support\analyzeHeadless.bat --dll C:\Windows\System32\version.dll --solution C:\Projects\spartacus-version --verbose --overwrite --external-resources --only "GetFileVersionInfoExW, GetFileVersionInfoExA"

    Manage function prototypes: Generate a prototype database from .h files to assist Ghidra:

    --mode proxy --action prototypes --path "C:\Program Files (x86)\Windows Kits" --csv C:\data\prototypes.csv --verbose
  2. Self-sign certificates and sign DLLs with `--mode sign`

    main

    Spartacus provides a sign mode to facilitate the creation of self-signed certificates and the subsequent signing of compiled DLLs or executables. This is useful for bypassing certain security checks during hijacking research.

    Generate a self-signed certificate

    Use --action generate to create a .pfx certificate. You can use --copy-from <path> to automatically copy the Issuer and Subject from an existing signed file (e.g., a system DLL) to make the new certificate appear more legitimate.

    Sign a file

    Use --action sign to sign a target file using a previously generated .pfx certificate. You can specify the hashing algorithm using --algorithm (e.g., SHA256).

    # Generate a self-signed certificate copying metadata from an existing file
    --mode sign --action generate --pfx "C:\Output\myCertificate.pfx" --password "Welcome1" --not-before "2023-01-01 00:00:04" --not-after "2025-01-01 00:00:42" --copy-from C:\Windows\System32\version.dll --verbose
    
    # Sign a compiled DLL with the certificate
    --mode sign --action sign --pfx "C:\Output\myCertificate.pfx" --password "Welcome1" --path "C:\Projects\Spartacus-AMSI\amsi.dll" --algorithm SHA256 --verbose
  3. Detect active DLL hijacking

    main

    The --detect mode attempts to identify running applications that are currently proxying calls. It enumerates processes, loads their modules, and flags instances where a DLL with a common name (e.g., version.dll) is loaded from a user-writable location instead of a standard OS path (like Windows\System32).

    Usage:

    --detect
  4. Identify COM hijacking vulnerabilities

    main

    Spartacus supports two methods for finding COM hijacking vulnerabilities:

    1. Log Parsing: Parses ProcMon logs to find missing registry keys ending in InprocServer32 that result in NAME_NOT_FOUND. If the key is under HKEY_CURRENT_USER, it attempts to find the associated GUID in HKEY_CLASSES_ROOT.
    2. Local System Scanning: Scans the registry (HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE) for keys like InProcServer, InProcServer32, LocalServer, or LocalServer32 that have missing EXE/DLL locations or insecure ACLs (e.g., user-writable).

    Usage Examples:

    Collect events from ProcMon:

    --mode com --procmon C:\SysInternals\Procmon.exe --pml C:\Data\logs.pml --csv C:\Data\VulnerableCOM.csv --verbose

    Parse existing PML logs:

    --mode com --existing --pml C:\Data\logs.pml --csv C:\Data\VulnerableCOM.csv --verbose

    Scan local registry for misconfigurations:

    --mode com --acl --csv C:\Data\VulnerableCOM.csv --verbose
  5. Identify DLL hijacking vulnerabilities

    main

    Spartacus can automate the discovery of DLL hijacking vulnerabilities by parsing SysInternals Process Monitor (ProcMon) logs.

    Workflow:

    1. Spartacus generates a ProcMon configuration file.
    2. It executes ProcMon and waits for user input.
    3. You run or terminate processes to trigger DLL loading attempts.
    4. Press ENTER to stop ProcMon.
    5. Spartacus parses the resulting .pml file to identify NAME_NOT_FOUND or PATH_NOT_FOUND events, compares them to actually loaded DLLs, and generates Visual Studio solutions for proxying the identified vulnerable DLLs.

    Usage Examples:

    Collect new events: Save events to a specific PML file and output results to CSV and Visual Studio solutions.

    --mode dll --procmon C:\SysInternals\Procmon.exe --pml C:\Data\logs.pml --csv C:\Data\VulnerableDLLFiles.csv --solution C:\Data\Solutions --verbose

    Parse existing logs: Process an existing .pml file to find vulnerabilities and generate solutions.

    --mode dll --existing --pml C:\MyData\SomeBackup.pml --csv C:\Data\VulnerableDLLFiles.csv --solution C:\Data\Solutions --verbose
  6. Sign DLL files

    main

    Spartacus can generate self-signed certificates (copying attributes from an existing signed DLL) and sign new DLL files.

    Usage Examples:

    Generate a signing certificate: Uses properties from a legitimate signed DLL (e.g., version.dll) to create a .pfx.

    --mode sign --action generate --pfx "C:\Output\certificate.pfx" --password "Welcome1" --not-before "2022-12-31 00:00:55" --not-after "2026-01-01 00:00:01" --copy-from C:\Windows\System32\version.dll --verbose

    Sign a DLL:

    --mode sign --action sign --pfx "C:\Output\certificate.pfx" --password "Welcome1" --path "C:\Input\MyFakeVersion.dll" --algorithm SHA256 --verbose
  7. Create a proxy using Ghidra for function definitions

    main

    To avoid running implants from DllMain, you can use Ghidra to create function definitions. Provide the path to the Ghidra analyzeHeadless.bat script using the --ghidra flag. You can also use the --only flag to proxy specific functions while forwarding the rest.

    # Standard proxy with Ghidra
    Spartacus.exe --mode proxy --action default --dll "C:\Windows\System32\amsi.dll" --ghidra "C:\Ghidra\support\analyzeHeadless.bat" --solution "C:\Output\AmsiSolution" --prototypes "./Assets/prototypes.csv" --verbose
    
    # Proxy only specific functions
    Spartacus.exe --mode proxy --action default --dll "C:\Windows\System32\amsi.dll" --ghidra "C:\Ghidra\support\analyzeHeadless.bat" --solution "C:\Output\AmsiSolution" --only "FunctionA" --prototypes "./Assets/prototypes.csv" --verbose
  8. Find applications vulnerable to COM Hijacking

    main

    Use --mode com to identify applications vulnerable to COM hijacking. This requires a Process Monitor executable and a .pml log file.

    Spartacus.exe --mode com --verbose --procmon "C:\SysInternals\ProcMon64.exe" --pml "C:\Output\ProcMonOutput.pml" --csv "C:\Output\VulnerableCOM.csv"
  9. Sign a DLL

    main

    To sign an existing DLL, use --mode sign and --action sign. You must provide a .pfx file, a password, the path to the DLL, and a signing algorithm (e.g., SHA256).

    Spartacus.exe --mode sign --action sign --pfx "C:\Output\certificate.pfx" --password "Welcome1" --path "C:\Input\MyFakeVersion.dll" --algorithm SHA256 --verbose
  10. View DLL exports

    main

    Use --mode proxy with --action exports to view the exported functions of a specific DLL. You can provide a CSV of prototypes to assist the process.

    Spartacus.exe --mode proxy --action exports --dll "C:\Windows\System32\version.dll" --prototypes "./Assets/prototypes.csv" --verbose
  11. Create a proxy for a specific DLL

    main

    To create a proxy for a DLL, use --mode proxy and --action default. You can specify a --solution path to automatically generate Visual Studio solutions for the identified DLLs.

    Spartacus.exe --mode proxy --action default --dll "C:\Windows\System32\version.dll" --solution "C:\Output\VisualStudioProjects" --prototypes "./Assets/prototypes.csv" --verbose