4324 Commits
Author SHA1 Message Date
RomernandGabi Gonzalez 0b3ef2b979 Simplify ccache SPN matching (#2318)
* Simplify ccache SPN matching

* tests: cover two-component ccache SPN matching

---------

Co-authored-by: Gabi Gonzalez <[email protected]>
2026-11-04 14:26:24 -03:00
mpgnandmpgn e694c65568 Move WIN_VERSIONS from smb3 to smb3structs (#2330)
The build-number table is plain data. smb3structs only depends on
impacket.structure, so code that only needs the table no longer loads
the SMB3 client. smb3 star-imports smb3structs, so
impacket.smb3.WIN_VERSIONS keeps working.

Co-authored-by: mpgn <[email protected]>
2026-11-04 09:29:40 -03:00
mpgnandmpgn c96563ed1d Wait for RemoteRegistry to be running instead of sleeping 1 second (#2336)
* Wait for RemoteRegistry to be running instead of sleeping 1 second

After starting a stopped or disabled RemoteRegistry service,
RemoteOperations.__checkServiceStatus() in secretsdump.py and
regsecrets.py slept a fixed second before connecting to winreg. Poll
hRQueryServiceStatus() every 0.1 s until the service reports
SERVICE_RUNNING instead, for at most 50 tries (about 5 s). After that,
the winreg connect is attempted as before.

The wait is still needed because StartService can return while the
service is START_PENDING, and __connectWinReg() does not retry. On
Windows Server 2019 the first poll already returns SERVICE_RUNNING, so
enableRegistry() drops from about 1.15 s to 0.15 s.

* Cap the RemoteRegistry wait by elapsed time and warn on timeout

The 50-try cap did not count the time each hRQueryServiceStatus() call
takes, so a slow link could stretch the wait well past 5 seconds (15 s
with a 200 ms round trip). Stop once 5 seconds have elapsed, and log a
warning when the service is still not running before connecting to
winreg.

---------

Co-authored-by: mpgn <[email protected]>
2026-11-04 03:30:33 -03:00
lupingandLu Ping e26afea74a [par.py] Fix opnum 39 response class in OPNUMS (#2310)
Co-authored-by: Lu Ping <[email protected]>
2026-11-04 02:50:08 -03:00
AzoxandKali c6efd1a868 fix(kerberos): support inter-realm (referral) TGT from a ccache (#2351)
* fix(kerberos): support inter-realm (referral) TGT from a ccache

* krb5/ccache: make the inter-realm TGT selection deterministic

* fix(krb5): normalize SPN hosts for referral selection

---------

Co-authored-by: Kali <[email protected]>
2026-11-03 12:28:55 -03:00
adrian manrique b35fd9a737 Fix syntax in GitHub Actions workflow 2026-11-02 17:45:39 -03:00
adrian manrique 9c76d74d26 Fix condition for runs-on in CI workflow 2026-11-02 17:41:15 -03:00
adrian manrique 2e5423cd1e Update runner version to ubuntu-22.04 2026-11-02 16:26:45 -03:00
AzoxandKali c8c1054bb1 Add SMB and LDAP signing bypass to ntlmrelayx (cross-user re-authentication) (#2345)
* Add SMB signing bypass to ntlmrelayx (cross-user re-authentication)

* Add LDAP signing bypass to ntlmrelayx

* Support anonymous session for the LDAP signing bypass

* Add --delegate-target option for RBCD

* Document LDAP bypass port limitation

* Point the shadow credentials output at getTGT.py for PKINIT

---------

Co-authored-by: Kali <[email protected]>
2026-10-30 13:20:30 -03:00
AzoxandKali 40b1eb7a0d Add a PKINIT client implementing RFC 4556, RFC 5349, RFC 4557 and RFC 8070 (#2260)
* Add a PKINIT client implementing RFC 4556, RFC 5349 and RFC 4557

* Fix DiffieHellman ignoring an explicitly supplied generator

* Send paChecksum2 so KDCs with SHA-1 disabled accept the AS-REQ

* Support the RFC 8070 PKINIT freshness extension

* Report a wrong PFX password as such instead of blaming legacy algorithms

* Point the shadow credentials attack at getTGT.py for the TGT

* Validate the KDC path when -ca-cert holds a DER certificate

* Fix PKINIT parsing of oversized ASN.1 lengths

* Fix RSA PKINIT interoperability with Windows

* Fix PKINIT certificate issuer selection

---------

Co-authored-by: Kali <[email protected]>
2026-10-28 17:33:08 -03:00
Dennys Kaluzny Pereiraandprotonnegativo 8a23c420b2 Fix 'succesfully' typo in user-facing messages (#2346)
Co-authored-by: protonnegativo <[email protected]>
2026-10-28 12:43:11 -03:00
Yang Baiandybai08 1265f5cee1 IP: reject options with a length below 2 when decoding (#2334)
IP.load_header() did not check the length octet of an option other than
EOL and NOP. A length of 0 left the remaining option bytes unchanged, so
the loop never ended, and decoding the packet hung. This also happens
for an ICMP destination unreachable message that quotes such a header,
since ICMPDecoder decodes the quoted IP header.

Raise ImpactPacketException for a length below 2, as TCP.load_header()
already does for TCP options.

Fixes #990

Co-authored-by: ybai08 <[email protected]>
2026-10-28 03:55:26 -03:00
Yang Baiandybai08 84a515fa0e IP: do not append options to the header buffer in get_packet() (#2333)
IP.get_packet() extended the array returned by get_bytes(), which is the
header's own buffer, with the options and padding. Every call after the
first one added the options again, so the serialized header grew and
ip_hl no longer matched the header that was sent.

Build the options in a separate buffer instead, and set ip_hl and the
checksum before joining it to a copy of the header.

Fixes #504

Co-authored-by: ybai08 <[email protected]>
2026-10-28 03:50:16 -03:00
n3rada 3ee67be6e1 fix(changepasswd): consistent connect logging and connection timeout across all protocols (#2291)
* feat(epm): add optional connection timeout to hept_map

* fix(changepasswd): consistent connect logging and timeout across all protocols

* fix(changepasswd): reject zero and negative -timeout values

* fix(changepasswd): default -timeout to 30s and clarify it is a connection timeout

* test(changepasswd): verify -timeout propagation across all protocols
2026-10-28 02:16:46 -03:00
H S BHARATH SURYAandClaude Sonnet 5 81af2e1fbb fix(ntlmrelayx): finished_attacks socks command loses history across --keep-relaying cycles (#2307)
Every relay server calls TargetsProcessor.reloadTargets(full_reload=True)
when --keep-relaying is active and all targets have been attacked once,
so the same targets can be re-attacked. That call wipes finishedAttacks
(and failedAttacks) entirely - which is correct for its actual purpose
(excluding already-attacked targets from generalCandidates/namedCandidates)
but also destroys the only record the finished_attacks socks command reads
from, so it shows only attacks completed since the last reload instead of
the full session history (#2028).

Add allFinishedAttacks, a persistent list appended to alongside
finishedAttacks in registerTarget() but never cleared by reloadTargets(),
and point do_finished_attacks() at it instead. finishedAttacks/failedAttacks
and the exclusion logic that depends on them being clearable are untouched.

Fixes #2028.

Co-authored-by: Claude Sonnet 5 <[email protected]>
2026-10-27 18:05:35 -03:00
Jannik Vieten 988e5e8d22 mssql/version.py: fixed SyntaxWarning (#2340)
Python 3.14 emits "SyntaxWarning: 'return' in a 'finally' block"
2026-10-27 18:01:06 -03:00
Gabriel GonzalezandKali df59669245 Fix SMB server file jail containment validation (#2344)
* Fix SMB server file jail path validation

* Test SMB1 set path information file jail

* Honor read-only shares in SMB1 path metadata updates

Return STATUS_ACCESS_DENIED for TRANS2_SET_PATH_INFORMATION on read-only shares after validating path containment.

Validated with the SMB server suite (84 passed, 8 skipped) and 143 local functional checks using Impacket and Samba clients.

---------

Co-authored-by: Kali <[email protected]>
2026-10-26 16:06:01 -03:00
e9ae5bc550 Add CES Relay to ADCS endpoint (#2325)
* Add AD CS CES relay support to ntlmrelayx

* Remove CES startup preflight

* Validate CES endpoint after authentication is received

* Simplify CES integration using ntlmrelayx infrastructure

* Share AD CS template selection with CES

* Keep CES helpers with HTTP attack

* Use generic target handling for CES

* Fix --template description

* Require explicit CES template selection

---------

Co-authored-by: pavi6 <pavi6@krokodil>
Co-authored-by: Gabi Gonzalez <[email protected]>
2026-10-21 09:57:10 -03:00
Sahil Panchal 800b2241c8 Add LDAP paged search to findDelegation.py and GetNPUsers.py (#2285) 2026-10-21 01:26:51 -03:00
Julien EGLOFFandKali 4f0348e838 Allow serviceaccount's name extraction with local secretsdump (#2124)
* Allow service account parsing with local secretsdump

* Implement requested changes

* Improve printSecret of Secretsdump when used with -history switch

* Add test and test data for LocalService local decryption

* Fix bug with -history and secretsdump remote local service

* test: cover local service secret edge cases

* test: align mock import with master

* Fix empty remote service account fallback

---------

Co-authored-by: Kali <[email protected]>
2026-10-19 12:33:52 -03:00
RomernandGabi Gonzalez 75938fcb01 Optimize TDS receive performance (#2320)
* Join TDS packet data once instead of copying it with each packet

Clean Up Loop

* Test TDS receive reassembly across multiple packets

---------

Co-authored-by: Gabi Gonzalez <[email protected]>
2026-10-15 09:58:10 -03:00
Azox b9e6e0fa5c Add support for LDAP Schannel authentication using a client certificate (PFX/PEM) (#2205)
* Add Schannel authentication via TLS client certificate

* add PKCS#12 input and verify the Schannel certificate mapping

* propagate whoami failures and support DER certificate files
2026-10-15 09:46:46 -03:00
RomernandGabi Gonzalez 63d0b14b6b Optimize TDS send performance (#2321)
* Optimize TDS send performance

use memoryview for payload
packetID cannot be larger than 256 and wraps around

* test(tds): cover send framing boundaries and packet ID rollover

---------

Co-authored-by: Gabi Gonzalez <[email protected]>
2026-10-15 09:44:30 -03:00
zblurxandKali f733aa63bd [LDAP] Fix channel binding computing to be fully RFC compliant (#2286)
* fix channel binding computing to be fully rfc compliant

* • LDAP: handle hashless certificate signatures for CBT

  Keep simple LDAPS binds available when tls-server-end-point cannot be
  computed, and fail closed when NTLM or Kerberos authentication requests
  channel binding.

  Add mocked coverage for RFC 5929 hash selection and hashless certificate
  signatures.

* CheckLDAPStatus: report LDAPS certificate signature algorithm
   Display the peer certificate signature algorithm alongside LDAP signing
   and channel binding status, making CBT behavior with non-SHA-256
   certificates easier to diagnose.

---------

Co-authored-by: Kali <[email protected]>
2026-10-14 11:25:40 -03:00
Adil Alperen Çiftci d96cef17ba fix(dns): prevent cyclic pointer recursion in compressed name parsing (#2304) 2026-10-14 04:50:03 -03:00
Emily AstranovaandKali 1875828d0f Add LSA dump to ntlmrelayx SMB attack (#2252)
* Add LSA dump to ntlmrelayx

* Gated SMB LSA dump beind --dump-lsa

* Keep SAM and LSA extraction independent so a SAM failure does not prevent a requested LSA dump.
Attempt SAM, SECURITY, and RemoteOperations cleanup independently to ensure RemoteRegistry restoration is still attempted after errors.
Move --dump-lsa into the SMB client options group and clarify that LSA secret extraction is opt-in.

---------

Co-authored-by: Kali <[email protected]>
2026-10-01 12:25:11 -03:00
mpgnandmpgn 36ff27a4b9 secretsdump: add inter-realm trust AES key salt (NetBIOS & FQDN) (#2288)
* secretsdump: fix inter-realm trust AES key salt (NetBIOS, not FQDN)

* fix fqdn

* tests: update trust key line count for the added trust-account keys

* fix review and offline dump

---------

Co-authored-by: mpgn <[email protected]>
2026-09-30 03:11:10 -03:00
Gabriel Gonzalez b1fe3ab4ab Standardize LDAPS flags across LDAP examples (#2309) 2026-09-29 17:57:43 -03:00
b-mineandGabi Gonzalez 6474a1175e Add NetShareEnum function with 502 struct option (#2295)
* Add NetShareEnum function with 502 struct option

* test(smbconnection): cover level 502 share enumeration

---------

Co-authored-by: Gabi Gonzalez <[email protected]>
2026-09-29 17:45:46 -03:00
Roman Karwacik 79cae1a6ec Add option to use LDAPS with GetUserSPNs.py using -ldaps flag (#2299) 2026-09-29 17:42:30 -03:00
AndreySolodandGabi Gonzalez 505d39ec39 MS-FSRVP, MS-SCMR (#2265)
* Fix some SMB relay server syntax error

* Added MS-FSRVP, 2 new calls to SCMR

* Remove wrong email

* added tests for MS-FSRVP

* fix some errors with vairable typing

* Added remote mark for test FSRVP

* Fix FSRVP type hints for Python 3.9

* Add offline NDR tests for FSRVP and SCMR

* Expand FSRVP and SCMR remote tests and skip unsupported methods

* Fix SCMR service creation response tag pointer types

---------

Co-authored-by: Gabi Gonzalez <[email protected]>
2026-09-29 17:21:50 -03:00
ThatTotallyRealMythandKali ba33c7ed5f MS-NEGOEX Phase 3 Implementation (#2213)
* created test case file to test spnego/negoex integration and added spengo helper functions

* added getNegoExMessages() function

Added the getNegoExMessages() function to both the init and response classes

* Implement NEGOEX / PKU2U authentication check

Raise NotImplementedError in smb3.py if NEGOEX is selected instead of parsing as NTLM messages

* Raise ldapsession error if ldap server picks NEGOEX

Raise LDAPSessionError for unsupported NEGOEX/PKU2U authentication instead of parsing it as a type2 NTLM message. 

Unsure as to using LDAPSessionError or using the NotImplementedError like in smb3.py

* smb.py: Raise NotImplementedError if NEGOEX is selected

* smbserver.py: log for when NEGOEX is offered to us by the client

* Log NEGOEX/PKU2U in smb2 handler

Log a message when NEGOEX/PKU2U authentication is offered by the client, indicating it is not supported for relay, during the SMB2/3 handler section

* wcfrelayserver.py: log if NEGOEX/PKU2U is currently offered

Log a message when NEGOEX/PKU2U authentication is offered by the client, which is not currently supported

* Added NEGOEX check in SPNEGO unwrapping

within the auth-phase SPNEGO unwrap, I inserted a NEGOEX check. 

Note I am Unsure if this appropriate for the context or correct placement so a check is appreciated

* socksplugins/smb.py: Detect NEGOEX selection/offering

Log in the SMB1 and SMB2/3 handlers if we have NEGOEX being offered or/and selected.

* Handle NEGOEX/PKU2U authentication in sendAuth

Add check for NEGOEX/PKU2U authentication support in sendAuth method.

* ldaprelayclient.py: Handle NEGOEX/PKU2U relay support in sendAuth

Add check for NEGOEX/PKU2U authentication support in sendAuth method.

* smtprelayclient.py: Handle NEGOEX/PKU2U authentication in sendAuth

Added check for NEGOEX/PKU2U authentication support in sendAuth method.

* imaprelayclient.py: Handle NEGOEX/PKU2U authentication in sendAuth

Added a check for NEGOEX/PKU2U authentication and raised an exception if unsupported.

* rpcrelayclient.py: Handle unsupported NEGOEX/PKU2U authentication

Added check for NEGOEX/PKU2U authentication in sendAuth method.

* mssqlrelayclient.py: added NEGOEX check

* winrmrelayclient.py: log NEGOEX

* Update dcsyncclient.py

* smbrelayclient.py: Add NEGOEX/PKU2U relay support check in SMB1 and smb2

* import log

* Added lazy import as well as made SPNEGO NegTokenInit parsing to be  lil more conservative/strict

* Implemented smb handlers, kerberos checking in DCERPC helpers and finally added relevant testcases to ensure the correct behavior is observed

* preserve NTLM fallback for non-NTLM SPNEGO offers

* Addressed remaining issues as well as added regression tests

* ntlmrelayx: handle SPNEGO fallback across relay servers

Add shared helpers for inspecting SPNEGO tokens and requesting NTLM when clients prefer an unsupported mechanism such as NEGOEX/PKU2U.\n\nPreserve SPNEGO framing for NTLM challenges across MSSQL, RDP, RPC, SMB, WCF, WinRM, and WinRMS listeners, and add regression coverage for offer, selection, fallback, and challenge handling.

* • Fix MSSQL relay TLS client address logging

---------

Co-authored-by: Kali <[email protected]>
2026-09-23 10:01:42 -03:00
Gabriel Gonzalez c38d1eeb6c Improve multirelay initial authentication handling (#2275) 2026-09-16 04:05:33 -03:00
Gabriel Gonzalez 6c9907e2f5 Revise 'Contact Us' section in README.md
Updated the 'Contact Us' section to include GitHub issues for general inquiries and clarified the reporting process for security vulnerabilities.
2026-09-10 16:31:55 -03:00
Gabriel Gonzalez 98b676289b Enhance security policy with reporting instructions
Expanded the security policy with detailed reporting guidance for vulnerabilities and misuse.
2026-09-10 16:31:17 -03:00
ChrisJr404andChris a2d35007c9 IP: add DSCP and ECN accessors to the IP class (#2267)
The old ToS byte is now the DiffServ field (RFC 2474/3168), so expose
get/set for the 6 bit DSCP and 2 bit ECN parts, mirroring the traffic
class helpers on IP6. get_ip_tos/set_ip_tos are left untouched.

Closes #211

Co-authored-by: Chris (ChrisJr404) <[email protected]>
2026-09-09 03:19:15 -03:00
mpgnandmpgn 9a3e62a4da secretsdump: write trust keys to their own .ntds.trustkeys file (#2278)
Signed-off-by: mpgn <[email protected]>
Co-authored-by: mpgn <[email protected]>
2026-09-09 02:47:45 -03:00
Harouna Coulibaly 9a69baf5a1 secretsdump: respect -history for trust keys (#2269) 2026-09-09 02:23:26 -03:00
Gabriel Gonzalez a441158eb0 Fix SMB3 directory leasing parent tracking (#2262)
* Fix SMB3 directory leasing parent tracking

* Fix SMB3 share-root parent tracking

* Normalize SMB3 share-root parent keys
2026-09-09 02:15:15 -03:00
n3rada 3b8ddd75d8 krb5: add optional connection timeout for Kerberos and kpasswd requests (#2253)
* feat(krb5): add optional connection timeout to sendReceive/TGT/TGS/kpasswd

* test(krb5): accept timeout kwarg in TGS enctype test mock
2026-09-09 02:09:24 -03:00
zblurxandKali 49ab4643d2 [WMI] Support parsing UINT8 array objects in WMI GetObject (#2268)
* add uint8 in WMI GetObject

* cut the data at the end with numItems

* added testcase for uint8 array retrieval

* fixed test to use __EventFilter builtin class

* fix unnecessary allocation

* change heapData usage

---------

Co-authored-by: Kali <[email protected]>
2026-09-08 12:44:36 -03:00
Alexandre Detiste 0b1a949a7c drop Python2 hybridation imports (#2276)
The "from __future__ import annotations" are the only from __future__ still usefull
with Python3, they stay.

impacket$ git diff | grep annota
 from __future__ import annotations
 from __future__ import annotations
impacket$
2026-09-04 15:00:37 -03:00
cbevandGabriel Gonzalez a517f82886 Add PAC client/device claims (CLAIMS_SET) parsing to describeTicket (#2258)
* Add PAC client/device claims (CLAIMS_SET) parsing to describeTicket

* Update impacket/krb5/pac.py

Co-authored-by: Gabriel Gonzalez <[email protected]>

* Update impacket/krb5/pac.py

Co-authored-by: Gabriel Gonzalez <[email protected]>

* Enumerate PAC_DEVICE_INFO (buffer 14) in describeTicket

* Update examples/describeTicket.py

Co-authored-by: Gabriel Gonzalez <[email protected]>

---------

Co-authored-by: Gabriel Gonzalez <[email protected]>
2026-09-04 09:18:15 -03:00
adrian manrique 5dc98d8e69 ntlmrelayx: migrate AD CS CSR generation to cryptography (#2273)
Replace the deprecated pyOpenSSL X509Req implementation used by the
AD CS HTTP and ICPR relay attacks with cryptography.x509.
Fixes #2248
2026-09-03 16:25:52 -03:00
rwa d310e07c75 fix: NDR.__str__ returns bytes (#2261)
Python throws an error when a call to `__str__` returns something other
than an instance of `str`:

```
>>> from impacket.dcerpc.v5.srvs import SHARE_INFO_1
>>> str(SHARE_INFO_1())
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    str(SHARE_INFO_1())
    ~~~^^^^^^^^^^^^^^^^
TypeError: __str__ returned non-string (type bytes)
```

Wrapped the current result with a call to `hexlify`.
2026-09-02 14:54:55 -03:00
Mario Madersbacher 598ae8457d Fix BootpDecoder crash on truncated BOOTP messages (#1900) (#2263)
* Fix BootpDecoder crash on plain BOOTP packets without DHCP options

* warn on undersized bootp messages instead of treating them as plain bootp

* actually fix #1900, the reported packet is 235 bytes not 236
2026-09-02 14:45:23 -03:00
herbenderbler 032dfb1bb5 addcomputer: support SAMR-to-LDAP finalization workflows (#2179) 2026-08-28 12:08:13 -03:00
Maximilian HildebrandandGabriel Gonzalez ce5e948ad8 New --shadow-credentials and --interactive option to backup (and clear) existing msDS-KeyCredentialLink attributes (#2251)
* implemented backup and clear

* always list amount of existing keycredentials for target object

* added do_backup_shadow_creads to ldap_shell. Aligned do_clear_shadow_creds by requiring a target per argument

* ldap shell shadow creds operations now report the amount of already existing credentiallinks

* Update typo

Co-authored-by: Gabriel Gonzalez <[email protected]>

* Fix typo

Co-authored-by: Gabriel Gonzalez <[email protected]>

* Centralized backup logic

* use one MODIFY_REPLACE instead of two

* renamed flag

* added restore_shadow_creds command to ldap shell

* fix

---------

Co-authored-by: Gabriel Gonzalez <[email protected]>
2026-08-24 18:24:31 -03:00
clou42 f133bb889e Adding logic for DCs with RestrictRemoteClients = 2 (#2166) 2026-08-19 09:41:27 -03:00
n3rada ec94d72a9a feat(smb3): add AES-128-GCM support to the SMB3 client (#2259) 2026-08-19 05:31:26 -03:00