How topotam/petitpotam works
Project Overview and Purpose
• This project is a Proof-of-Concept (PoC) security tool that forces Windows hosts to authenticate to other machines using vulnerabilities in the MS‑EFSRPC (and LSARPC) interfaces. It has two implementations:
– A Windows-targeted C++ implementation (built via Visual Studio, as seen in the solution, project files, and C++ source code).
– A Python version that relies on the Impacket library to perform similar coercion.
• Its core goal is to trigger Windows authentication without needing credentials against a Domain Controller.
Analyzing the File Structure
• Top-Level Files:
– PetitPotam.exe: The compiled C++ binary for Windows.
– PetitPotam.py: The Python script version.
– PetitPotam.sln: The Visual Studio solution file (along with accompanying project files and filters), indicating a structured C++ Windows application.
• Source and Support Files:
– The PetitPotam directory contains the main C++ source file and its project configuration.
– Additional header/source files (ms-dtyp.h, ms-efsrpc_c.c, etc.) provide implementations for EFSRPC and LSARPC protocols.
• README.md provides context on the attack vector, dependencies, and relevant protocols (EFSRPC and LSARPC).
Components
A. Core Components:
• Command-Line Interface (CLI) – Represents the user’s starting point where they execute either the C++ PoC or the Python script.
• PetitPotam PoC (C++):
• Visual Studio Build Environment: Represents the development and build process.
• Executable (PetitPotam.exe): The Windows binary implementing the MS‑EFSRPC call.
• Supporting Code: Source files (PetitPotam.cpp) and headers related to the EFSRPC and LSARPC protocols.
• PetitPotam PoC (Python):
• Python Script (PetitPotam.py): Implements the same functionality using the Impacket library.
• Dependency on Impacket: Denoted as an external module/library that supplies necessary network protocol support.
• External Dependencies:
• Windows RPC Library (Rpcrt4.lib) – Mentioned explicitly as a linker input.
• Named Pipes / RPC Endpoints – LSARPC and EFSRPC channels used to trigger the authentication on the target.
• Target Windows Host:
• Remote Machine: The system that will be coerced into authenticating by virtue of receiving an MS‑EFSRPC (or LSARPC) call.
B. Relationships and Data Flows:
• User triggers execution (via CLI) → calls either the C++ executable or Python script.
• The chosen implementation then constructs an RPC call using one of the named pipe interfaces (primarily LSARPC, also EFSRPC) to target a Windows host.
• The tool sends a crafted RPC request (using functions like EfsRpcOpenFileRaw) that forces the target to authenticate, with authentication details flowing back to a designated endpoint (the attacker’s machine).
• The project’s design shows a clear separation: one branch compiled as a native Windows application (using Visual Studio) and one implemented in Python with reliance on third-party networking libraries.
C. Technical and Architectural Patterns:
• Protocol Abstraction: Although it is a targeted PoC, there is a separation of responsibilities between constructing and sending the RPC calls and handling the network communication.
• External Library Integration: For the Python version, it is important to illustrate the role of the Impacket library in managing the network protocol details.