National Cyber Warfare Foundation (NCWF)login

impacket-programming-manual for building your own Active Directory PoC scripts


0 user ratings
2026-11-17 11:24:25
milo
Red Team (CNA)
"impacket-programming-manual

A book-length, source-code-driven manual that teaches authorized professionals to write their own impacket-based PoCs against the Kerberos, DCE/RPC and DCOM stack instead of copy-pasting example scripts.








ToollupingQAQ/impacket-programming-manual — book-length bilingual programming manual for developing domain-penetration scripts on top of impacket
CategorySecurity education / protocol development resource (Markdown + PDF + runnable example/ scripts)
Primary UseLearning the impacket source tree module by module so you can write your own PoC scripts for AD protocols — LDAP, krb5, dcerpc, DCOM/WMI — in authorized lab environments
Safe UseThe README's disclaimer restricts the manual to lawful security research, education, and authorized penetration testing against lab systems you own or are explicitly authorized to assess
Telemetry NoteAs documentation it leaves no footprint itself; the techniques it describes (Kerberos ticket requests, RPC binds, certificate enrollment via ICPR) generate standard Windows domain controller and AD CS logging visible to defenders

Most of the public material around impacket falls into one category: walkthroughs of the example scripts. You get told which flags to pass to secretsdump.py or psexec.py, but never how those tools actually work underneath. lupingQAQ/impacket-programming-manual takes the opposite approach — it is a roughly 5,400-line, nine-chapter source-code reading guide that walks the impacket tree module by module, with the explicit goal of teaching you to write your own proof-of-concept scripts the next time an Active Directory vulnerability drops. The author, Lu Ping (published via the WeChat blog IndexSec), points out that nearly every public exploit for recent AD flaws was built directly on impacket modules — the sam-the-admin technique, CVE-2022-33679, noPac, Zerologon tooling, and PetitPotam-style relay chains — which makes the library itself the highest-leverage skill to learn.


The structure follows the architecture of the codebase rather than the order of attack checklists. Part I covers the impacket directory layout and structure.py, the universal serialization base class that underpins every protocol packet in the library. This is a smart pedagogical choice: once you understand how structure.py packs and unpacks binary fields, every subsequent module becomes readable. Part II moves into authentication and directory services with dedicated chapters on ldap (queries, ACL structures, Global Catalog) and krb5 (tickets, ccache/keytab binary layouts, the PAC, GSS-API and SPNEGO).


Part III is the largest chunk: DCE/RPC internals — the NDR serialization engine, rpcrt, the endpoint mapper, and the transport factory — followed by more than twenty Microsoft protocol interface modules grouped into five functional families, including SAMR, NRPC, LSAD, RRP, SRVS, RPRN/PAR, TSCH, BKRP, and DRSUAPI. Part IV climbs the stack to DCOM and WMI, dissecting dcomrt, the oaut/comev/scmp/vds/wmi submodules, and the object model behind DCOMConnection/INTERFACE/IRemUnknown and IWbemServices method tables. Part V closes out the support libraries — SMB2/3, DPAPI, the NTDS ese parser, and TDS — which are the plumbing you need when your script touches files, secrets, or databases.


What distinguishes this manual from a simple source dump is its editorial discipline. Long code listings are compressed to key paths with step-numbered annotations — ① ② ③ in the Chinese edition, (1) (2) (3) in the English one — so you can trace execution flow without scrolling through boilerplate. The README also states that all cited code was verified against the current fortra/impacket master, and that known upstream quirks like the par.py opnum 39 tuple, the hept_map spelling, and the MimiUnbind vs MiniUnbind discrepancy are preserved and annotated rather than silently corrected. For anyone who has debugged a mismatch between documentation and reality, that fidelity is a genuine quality signal: it means the manual reflects the code you will actually be reading, not an idealized version of it.


Part VI is where the project shows its currency. It tracks the impacket 0.12–0.14 additions — ICPR for AD CS certificate enrollment, GKDI for group key distribution, NEGOEX for extended SPNEGO negotiation, RAA for remote authorization, SCMR, plus the acl.py and dpapi_ng.py helpers. These are interfaces that upstream ships with little or no standalone example code, which historically left a gap between the module existing and anyone being able to use it. The accompanying example/ folder fills that gap with four runnable scripts: certificate enrollment via ICPR, a GKDI key fetch, NEGOEX parsing, and RAA permission enumeration.


The case-study thread woven through the chapters is the strongest argument for the source-level approach. Rather than treating vulnerabilities as black boxes, the manual locates each one in its protocol module: Zerologon (CVE-2020-1472) in nrpc, PrinterBug/PrintNightmare in rprn/par, the CVE-2019-1040 NTLM MIC bypass in gssapi, Exchange RPC-over-HTTP relay via rpcmap, Akamai's Cold Hard Cache RPC security-callback bypass, WMI persistence with wmipersist, and golden PAC forging. Chapter 9 adds recent material — BadSuccessor (CVE-2025-53779), which abuses the Windows Server 2025 dMSA account type, and CVE-2025-33073, the reflective relay that yields SYSTEM on hosts without SMB signing. The framing here is documentary: these are anatomy lessons in how protocol-level flaws translate into exploitable code paths, intended for lab reproduction.


Getting the manual is straightforward: git clone https://github.com/lupingQAQ/impacket-programming-manual.git puts the bilingual Markdown editions, print-ready PDFs, the example/ scripts, and the mkdocs source for a bilingual docs site on your machine. The recommended practice environment is a Windows AD lab — the README suggests two VMs plus pip install impacket — followed by re-implementing the case studies module by module. The suggested reading path is sensible: foundations (chapters 1–2), then Kerberos (chapter 4), then picking RPC interface modules by functional group as needed. That non-linear ordering mirrors how experienced operators actually use the library, dipping into the interface they need for the task at hand.


For defenders, this resource has an underappreciated secondary value: it is effectively a field guide to adversary tradecraft at the protocol level. Blue teams who understand how getKerberosTGT/getKerberosTGS work internally, what an EPM lookup looks like on the wire, or what a DCOMConnection bind sequence generates in Windows event logs are far better positioned to write detections than those who only know tool names. The same source knowledge that lets a red-teamer build a novel PoC lets a detection engineer anticipate the network and authentication artifacts such tooling inevitably produces — Kerberos ticket requests against a domain controller, RPC binds to LSA and SAMR endpoints, certificate enrollment traffic toward AD CS.


The bilingual character of the project is worth noting for an English-speaking audience. The Chinese edition is the source of truth, revised through a second edition, with the English edition translated from it and scrubbed so that code blocks carry zero CJK characters. Every module heading in the table of contents carries a content summary — for example, nrpc.py annotated as Netlogon Authentication and Zerologon — rather than a bare filename, which makes the manual usable as a reference rather than a one-time read. Contributions are welcomed via fork-and-PR, with the author explicitly requesting technical review against impacket and Microsoft protocol documentation, new chapter material on topics like ADCS and ntlmrelayx internals, and translation fixes.


The README closes with a disclaimer that matches the reality of the content: lawful security research, education, and authorized penetration testing only, targeting lab environments you own or are explicitly authorized to assess. At 107 stars and release v2.3, this is a niche but serious project — not a tool you run, but a curriculum that changes what you are able to build. For anyone whose work involves Active Directory security on either side of the fence, and who has outgrown recipe-style tool walkthroughs, it is one of the more rigorous freely available resources on impacket internals currently published.



Official project repository for lupingQAQ/impacket-programming-manual.

Download Tool

Educational analysis for authorized security professionals. Use only in controlled, authorized environments.






Source: OffensiveSec
Source Link: https://www.offsecblog.com/2026/11/impacket-programming-manual-for.html


Comments
new comment
Nobody has commented yet. Will you be the first?
 
Forum
Red Team (CNA)



Copyright 2012 through 2026 - National Cyber Warfare Foundation - All rights reserved worldwide.