236 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
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
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
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
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
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
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
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
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
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
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
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
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
Laced 3c37ab1b44 keylistattack: support PAC-hardened DCs (#2233)
* keylistattack: support PAC-hardened DCs

The RODC partial TGT now carries a signed PAC, so patched DCs accept
the KERB-KEY-LIST request. LIST mode gains -domain-sid / username:rid.

* keylistattack: recover keys despite extra PA-DATA

getKey() finds KERB-KEY-LIST-REP by type, not encrypted_pa_data[0].

* keylistattack: warn on placeholder PAC requestor

_createPartialPac() now logs a WARNING naming the user when it falls
back to placeholder RID 1000, so the operator sees the requestor SID
will not match the target and can supply username:rid.
2026-08-19 02:32:24 -03:00
Gabriel Gonzalez 29424fb50b Standardize Kerberos TGS enctype negotiation (#2241) 2026-08-19 02:18:10 -03:00
n3radaandGabi Gonzalez c23b3d55bc smbserver: add SMB 3.1.1 dialect support (#2216)
* feat(smbserver): add SMB 3.1.1 support with pre-auth integrity, KBKDF signing, and session encryption

* fix(smbserver): echo request SessionId in SMB2 response headers per MS-SMB2 §3.3.4.1

* refactor(smbserver): drop spec URLs and section numbers from comments

* fix(smbserver): reject unsupported SMB2 dialects instead of defaulting to 2.002

* fix(smbserver): encrypt SMB2 compound responses as a single message

* fix(smbserver): verify SMB2 transform header auth tag before trusting plaintext

* fix(smbserver): source SMB2 transform cipher from connection state, not the packet

* fix(smbserver): use correct SMB2 transform flags constant on the encrypt side

* fix(smbserver): preserve real SessionId in encrypted LOGOFF transform header

* test(smbserver): add SMB 3.1.1 regression tests

* test(smbserver): pin functional suites to legacy dialects

---------

Co-authored-by: Gabi Gonzalez <[email protected]>
2026-08-14 16:48:00 -03:00
Gabriel Gonzalez 8ea54feb10 Modernize byte string normalization (#2243) 2026-08-12 05:01:29 -03:00
0x00JeffandGabriel Gonzalez 243d64a675 Fix IndexError in CCache.getCredential when handling 3-part SPNs in multi domain forests (e.g. dumped LDAP tickets using rubeus dump module) (#2242)
* Fix IndexError in CCache.getCredential when handling 3-part SPNs

* Update impacket/krb5/ccache.py

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

* Add regression tests for 3-part SPN matching in CCache.getCredential

---------

Co-authored-by: Gabriel Gonzalez <[email protected]>
2026-08-10 13:46:19 -03:00
alexisbalbachan 701354e937 Fix DCOM interface context loss after same-target disconnect + test (#2236) 2026-08-05 10:01:40 -03:00
65534a2d8d Add MSSQLClient/TDS.py capabilities for named pipe exposed instances (#2202)
* Working tds np

* Print answer

* WORKING POOOOOOOC

* WORKING POOOOOOOC

* WORKING POOOOOOOC

* Removing dupplicated functions

* Removing dupplicate code

* Merged all in one

* Add detection version for MSSQL server 2025

* Switch pipe_name to positional argument to not break other things

* Comply to remoteHost/remoteName for Kerberos auth

* Patch small error

* Preserve MSSQL constructor compatibility

* Default MSSQL named pipe remote host

* Fix MSSQL named pipe timeout and disconnect handling

* Support separate SMB credentials for MSSQL named pipes

* Fix MSSQL named pipe authentication routing

* Honor MSSQL named pipe connection timeouts

* Close failed MSSQL named pipe transports

---------

Co-authored-by: Aurélien CHALOT <[email protected]>
Co-authored-by: Gabi Gonzalez <[email protected]>
2026-07-29 09:36:47 -03:00
c779bb31c8 Fix AttributeError when parsing a credential with auth data (#2219)
* Fix AttributeError when parsing a credential with auth data

Credential.authData was initialized as a tuple and never turned into a
list before the parse loop appended to it, so any ccache credential
carrying authorization data raised "AttributeError: 'tuple' object has
no attribute 'append'". Initialize it as a list right before the loop,
mirroring how addresses is already handled. Adds a regression test.

* simplified initialization code

---------

Co-authored-by: Eugen Goebel <[email protected]>
Co-authored-by: Kali <[email protected]>
2026-07-22 00:38:16 -03:00
Raz KissosandKali 984aedbd78 Fix - Add support for DCOM connections to loopback addresses (#2039)
* feature - add support for DCOM connections to loopback addresses.

* applied requested changes
added testcase

---------

Co-authored-by: Kali <[email protected]>
2026-07-21 23:54:21 -03:00
n3radaandGabi Gonzalez 00e25d443b tds: fix binary and char column values displaying as Python bytes repr (#2214)
* fix(tds): decode hex bytes to str for binary column display

* fix(tds): decode BIGCHARTYPE and TEXTTYPE bytes as latin-1 string

* test(tds): cover decoded binary and char row values

Add parseRow regression coverage for binary/image hex output and non-Unicode text/char values so Python 3 does not render them as bytes reprs.\n\nAlso simplify latin-1 decode paths, since latin-1 accepts every byte value and the UnicodeDecodeError fallback was unreachable.

---------

Co-authored-by: Gabi Gonzalez <[email protected]>
2026-07-08 10:21:07 -03:00
Gabriel GonzalezandKali 74db114bba Fix REG_MULTI_SZ output formatting (#2199)
* Fix REG_MULTI_SZ output formatting

* added testcase for winregistry

---------

Co-authored-by: Kali <[email protected]>
2026-06-19 17:44:17 -03:00
Azox 153e8ddb1e Persist TGT and ST obtained during kerberosLogin (#2193)
* persist TGT and ST obtained during kerberosLogin

* Persist TGT/ST only after successful Kerberos session setup
2026-06-18 13:51:23 -03:00
Abdul Moizandmoizxsec 4a72cb8325 Fix duplicate keys in epm.KNOWN_PROTOCOLS (#2206)
KNOWN_PROTOCOLS is a dict literal keyed by interface UUID, so duplicate
keys are silently collapsed by Python and the second entry shadows the
first, producing incorrect protocol lookups (issue #2126).

Two UUIDs were listed twice:

- 12345778-1234-ABCD-EF00-0123456789AB was mapped to both MS-LSAD and
  MS-LSAT. Both protocols are served over the same lsarpc interface
  (MSRPC_UUID_LSAD == MSRPC_UUID_LSAT), so the two entries are merged
  into one that names both.
- 00000000-0000-0000-C000-000000000046 is IID_IUnknown (see
  dcomrt.IID_IUnknown) and already maps to MS-DCOM. It was also listed
  in the MS-RSMP block, which has its own interface UUIDs; that
  erroneous entry is removed.

Adds a regression test that parses the source and asserts KNOWN_PROTOCOLS
has no duplicate keys.

Closes #2126

Co-authored-by: moizxsec <[email protected]>
2026-06-17 03:47:37 -03:00
ThatTotallyRealMyth 29fff61bcf MS-NEGOEX Protocol implementation phase 1 and phase 2 (#2195)
* Add NEGOEX protocol implementation in negoex.py

This file implements the NEGOEX protocol for SPNEGO extended negotiation, including message types, structures, and parsing functions. This commit is a initial, first start attempt at the protocol

* Minor cleanups

Just cleaned up and trimmed up certain code elements from leftover.

* Corrected the intended file for PR

* Added new function to create a negoex message instance

The `createNegoMessage` function has been implemented to create a negoex message as either the initiator or acceptor

* Function to create Exchange message

Implemented the function that's able to create an exchange message used within the NEGOEX protocol

* Added helper functions, fixed imports and minor changes

* Removed NegoExContext

* Added commented section seperators to make it easier to read the module

* Added auth scheme UID for PKU2U

* Implemented createAlert/createVerify message functions

* Replaced older python convention with f strings

* Addede exposed safe accessors

* Added strict signutre check in the function that checks the message headers for the correct strucutre/format

* Minor fixes on F strings

* Implemented stricter parsing as well as added testcases for the negoex.py module

* Created NegoExContext

Created the NegoExContext class that will be exposing to public consumers to drive the state machine required for the protocol to work

* Implement method to register auth scheme and create exchange messages depending on the status of the caller

* Implemented internal function to create verify messages + checksum creation as well as step through the sequencing in the message exchang

* Implemented functions to process/track incoming verify messages, function to process incoming NEGOEX token, and a function to create the first message to initiate the negotiation protocol/process

* Corrected comment

* Implemented function to inform consumers they have finished the protocol exchange

* Modified order of methods in state machine class to be more logical and reader friendly

* Added the option for caller to provide optimistictoken to eliminate the need for a full round trip and allows us to instead progress directly with the authentication exchange

* Added testcases for the negoex state machine based on the microsoft protocol example in MS-NEGOEX open spec

* Fixed sequnce number bug where sequence number were not incremented correctly

* Fixed the failing testcase by just asserting it equals the selected scheme since mutual schemes should only have the scheme that we, the iniator, offered

* removed uneccesary test assertion

* Implement _processAlert method in NegoEx class

The current defined alert message is informational in nature as it requires nothing for us, the receiver to practically do anything in response to it. 

This could change in future revisions of the module and so for now while we only log it via debug we got a verify message, there might be new logic needed in the future with revisions.

* Implement _processNego internal function

Additionally fixed an error I had accidentally left in place from editing via iPad

* implemented internal function to validate convId

Implemented function to track conversation IDs and ensure incoming messages are the right authentication schemes and match our expected conversation ids

* implemented 4 new test cases to track/validate conversation ID, acceptor side processing

* fixed indent

* Add NegoExError import to test_negoex.py

* Fix test case indentation issues
2026-06-16 09:47:57 -03:00
ThatTotallyRealMythandKali 41fe8a96d0 Implementation for the Remote Authorization API Protocol, MS-RAA (#2186)
* Create raa.py

Implemented new module to implement the MS-RAA protocol

* Implement Remote Authorization API Protocol Interface

This file implements the Remote Authorization API Protocol Interface for client-side operations, including various structures and RPC calls necessary for authorization tasks.

* Convert SID to RPC_SID object in context initialization

Fixed bug in which passing directly the Sid from the string, and instead we need to convert the string to an RPC_SID instance

* clarity

* Fixed issues with the token groups NDRstruct. Additionally fixed issue passing the proper UUID for the interface

* Add test cases for the MS-RAA module rpc calls

* • tests: select the matching RAA TCP endpoint

  Use RPC_C_EP_MATCH_BY_IF when looking up MS-RAA endpoints and verify
  that each returned tower belongs to the RAA interface before selecting a
  TCP port.

  The previous lookup could return unrelated endpoint mapper entries, so
  the tests could bind the RAA interface to another service's dynamic RPC
  port and fail with abstract_syntax_not_supported.

  Also guard ProtocolData access while scanning tower floors and reuse
  epm.FLOOR_TCPPORT_IDENTIFIER instead of a magic b'\x07' value.

* • raa: fix token group parsing and remote test coverage

  Fix AUTHZR_TOKEN_GROUPS marshalling for real non-empty group SID
  responses. Windows NDR32 replies omit the conformant-array max count in
  this structure, while NDR64 replies include it before GroupCount, so the
  parser now handles both observed layouts.

  Also fix several helper serialization issues:
  - default AUTHZR_HANDLE data is now bytes on Python 3
  - hAuthzrInitializeContextFromSid sends zeroed reserved Identifier fields
  - ModifyClaims/ModifySids helpers wrap operation values as NDRENUM items

  Update the RAA remote tests to:
  - select the matching MS-RAA TCP endpoint from EPM
  - use epm.FLOOR_TCPPORT_IDENTIFIER instead of a magic b'\x07'
  - resolve the configured test account SID at runtime via LSAT
  - exercise ModifyClaims/ModifySids helper calls against a live context

* Updated comments at the very top of file

Updated comments to remove old comment that said tests would be soon and instead referenced the file in which the test cases are found in

* minor fixes

---------

Co-authored-by: Kali <[email protected]>
2026-05-26 10:38:38 -03:00
Kali c456746d7a tests: initialize DCOM connection for RemoteGetClassObject
Use DCOMConnection in test_RemoteGetClassObject instead of a raw
  DCE/RPC connection from self.connect(). RemoteGetClassObject returns an
  interface whose RemRelease path expects the DCOMConnection PORTMAPS cache
  to be initialized for the target; the raw connection path leaves that
  cache empty and can raise KeyError keyed by the target address.

  Wrap the interface use in a try/finally so the DCOM connection is always
  disconnected after the test.
2026-05-15 12:40:42 -03:00
Kali 9dcc815344 do not use hardcoded paths for tests.
do cleanup on finally block even in test fails
2026-05-15 11:27:47 -03:00
Herbenderbler 0be6514bdf BUG-2099: Fix Unhandled ValueError during authentication (#2151)
* Fix #2099: handle truncated SMB responses (SessionError + debug log)

- structure: asciiz without NUL raises clear ValueError with field name
- smb: catch ValueError at session/negotiate parse sites; log at debug, raise SessionError
- smbconnection: docstring notes invalid/truncated server response
- ci: fix flake8 F824 (goldenPac, ldapattack)
- tests: regression for asciiz NUL and session setup parsing; align with TESTING.md
- docs: ChangeLog

* Fix #2099 struct.error mapping.
2026-05-06 01:53:30 -03:00
alexisbalbachanandGabriel Gonzalez 899ef248d8 ticketer.py: preserve KDC-issued lifetime for diamond tickets (issue #2058) (#2181)
* preserve request-based ticket lifetime and add regression test

* tests: expand coverage for request-based ticket lifetime preservation

* Updated tests to comply with the code review

* Update examples/ticketer.py

* update description of the -duration parameter

---------

Co-authored-by: Gabriel Gonzalez <[email protected]>
2026-05-01 00:56:43 -03:00
alexisbalbachan 3236169747 Fix TS_ALL_PROCESSES_INFO parsing for RpcWinStationGetAllProcesses (#2155)
* Fixed TS_ALL_PROCESSES_INFO parsing for RpcWinStationGetAllProcesses

* Removed ldap3 dependency, fixed mismatched data type for rawsid, added missing test

* Removed unused imports, renamed imagenamesize -> imagename to match docs. Added missing test
2026-04-30 11:56:58 -03:00
alexisbalbachanandKali 426f354767 Fix large-page ESE tag-state parsing for Windows Server 2025 NTDS.dit (issue #1924) (#2158)
* Fix issue #1924 large-page tag count parsing

* Applied code review changes, added unit test

* improved code
added testcase

* Fix USER_PROPERTIES parsing per MS-SAMR spec

---------

Co-authored-by: Kali <[email protected]>
2026-04-30 11:41:05 -03:00
Julien EGLOFF 3439d335a1 Modify ticketer and ccache logic (#2159)
* Modify ticketer and ccache logic

* ticketer now update existing ccache if KRB5CCNAME is specified
* ticketConverter now convert all TGS within the Kirbi or provided Ccache
* Fix a bug during the conversion from ccache to kirbi that does not correctly preserve ticket flags

* Update kirbi test cases. Improve Kirbi to Ccache conversion.
2026-04-29 17:13:05 -03:00