Commit Graph

1286 Commits

Author SHA1 Message Date
alexisbalbachan 46e9b038be secretsdump: Filter offline NTDS accounts by local domain SID (#2178)
* Filter offline NTDS rows by local domain SID

* Use remoteops.getDomainSid when isRemote == True

* Skip offline NTDS rows with unavailable PEK indexes

* Allow snapshot enumeration over SMB 3.1.1

---------

Co-authored-by: gabrielg5 <gabriel.gonzalez@fortra.com>
2026-05-08 12:08:09 -03:00
Tomik f1cb36178e GetUserSPNs.py - Added a switch not to force RC4-HMAC when requesting a TGT (#2141)
* Added a switch not to force RC4-HMAC when requesting a TGT as newer servers (e.g., 2025) won't issue service tickets when provided with RC4-HMAC TGT.

* Update examples/GetUserSPNs.py

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>

---------

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>
2026-05-05 13:46:31 -03:00
ThatTotallyRealMyth 8601e43614 Fix Issues with ACE type filtering and ObjectType GUID parsing in BadSuccessor.py search_ous() that causes False negatives (#2170)
* Added processing to object specific ACEs in search_ous()

* Fixed GUID parser for ObjectType handling for object-specific ACEs

* Apply suggestion from @alexisbalbachan

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>

---------

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>
2026-05-05 13:07:11 -03:00
alexisbalbachan 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 <gabriel.gonzalez@fortra.com>
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
alexisbalbachan 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 <adrian.manrique@gmail.com>
2026-04-30 11:41:05 -03:00
Julien Egloff b58e72b689 Add dpapidump to impacket (#1917)
* Adding dpapidump to impacket

* Apply suggestions from code review

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update examples/dpapidump.py

* Update examples/dpapidump.py

* Update examples/dpapidump.py

* Update examples/dpapidump.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

---------

Co-authored-by: laxa <laxa@ddracepro.net>
Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2026-04-30 10:24:21 -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
Julien EGLOFF 46e39eb35e Fix describe ticket (#2117)
* Fix describe ticket

* fix describeTicket credential indexing after skipped decrypts

  Use enumerate() when iterating ccache credentials so output keeps the
  correct credential index even when a ticket is skipped due to missing or
  invalid decryption material.

  Also update the Kerberoast debug message to report the ticket encrypted
  part etype, matching the value now used for the extraction decision.

---------

Co-authored-by: Kali <adrian.manrique@gmail.com>
2026-04-27 17:36:33 -03:00
huh? 2f130643d4 raiseChild: fix PAC buffer preservation and add AES support for modern Windows (#2164)
* raiseChild: fix PAC buffer preservation and add AES support for modern Windows

Two bugs fixed:

1. makeGolden() hardcoded exactly 4 PAC buffers, discarding all others.
   Windows Server 2022 with CVE-2021-42287 patches requires PAC_REQUESTOR
   (type 18) to be present. Stripping it causes KDC_ERR_TGT_REVOKED.
   Fix: preserve all original PAC buffers, only update modified ones.

2. getKerberosTGT() called with aesKey=None hardcoded, ignoring -aesKey.
   Fix: pass aesKey, try AES first then fall back to RC4.

Additional improvements:
- Auto-retry golden ticket with AES if RC4 is rejected by KDC
- Fix signature zeroing to use actual length instead of hardcoded 12/16
- Updated help text with AES key usage examples

Tested against Windows Server 2022 Build 20348. Backward compatible.

* krb5: share PAC rebuild and signing helpers

* krb5: share AES ticket key selection helpers

* Fix password fallback suppression and TGT re-acquisition on golden ticket retry

* raiseChild: fix credential retry flow

* raiseChild: pass normalized AES key to target exec login

---------

Co-authored-by: plur1bu5 <plur1bu5@users.noreply.github.com>
Co-authored-by: Gabi Gonzalez <gabriel.gonzalez@fortra.com>
Co-authored-by: Your Name <you@example.com>
2026-04-24 10:30:19 -03:00
Ashok Chand c9456e9543 Update owneredit.py DN search. (#2162)
* Update owneredit.py DN search.

Update DN search. Currently DN lookup is from root partition only.

* Update owneredit.py

looked up owner DN update. previously typo mistake.
2026-04-21 10:02:08 -03:00
Julien EGLOFF 5c68193080 Add timestamp to SAM parsing (#2142)
* Add timestamp to SAM parsing

* Make SAM output consistent with NTDS output when using -pwd-last-set
2026-04-16 16:33:15 -03:00
Deft_ 76ee87746d Custom fake CBT flag for MSSQLClient via TDS.py (#2098)
* Add fake CBT value for NXC

* Add fake CBT value for NXC

* Add checkMSSQLstatus.py

* Fixed required modifications

---------

Co-authored-by: Aurélien CHALOT <aurelien.chalot@orangecyberdefense.com>
2026-03-26 15:08:34 -03:00
mollysec 2c77435e4f Update secretsdump.py (#2154)
It was missing a 'to' as far as I see. Refined the help message.
2026-03-18 21:59:53 -03:00
alexisbalbachan 084aff60df ntlmrelayx: NTLM SEAL flag drop paths for CVE-2025-33073 and --remove-mic (#2133)
* Added remove_sign_seal flag, drop seal flag when remove mic

* moved seal flag removal from sendauth/remove-mic and into sendauth/remove-sign-seal

* Added missing token regeneration after removing seal
2026-03-13 15:41:48 -03:00
masterDeus d362ca74e9 Modified reg-key creation to assume persistent key creation with impacket-reg (#2113)
* Added flag functionality to specify that a created registry key should be volatile, and changed the default behavior to instead create non-volatile keys

* Reverted to default behavior and clarified description

- Reverted default behavior back to volatile keys
- Changed --volatile flag to --persistent
- Moved flag verification to subkey creation section
- Added printed warning that key is volatile if --permanent is not set (only in subkey creation)
- Clarified flag description.
2026-03-05 11:07:03 -03:00
alexisbalbachan 9f2bf6b58c Ntfs read fixes (#2106)
* Fixed files not being listed when in INDEX_ROOT

* Added support for sparse files

* Fix double VNC shift, causing incorrect reads.
handle walk() returning None
null checks in do_cat
error handling in getINode
general refactor

* added tests for ntfs-read

---------

Co-authored-by: Kali <adrian.manrique@gmail.com>
2026-03-05 10:42:52 -03:00
Adham Elmosalamy 8cb82c0fdf feat: added --base64 option to ticketConverter (#2104)
* feat: added --base64 option to ticketConverter

* Cleanup manually to avoid issues with Windows delete permissions
2026-02-09 18:01:51 -03:00
Roman Karwacik d7a0d57560 smbserver.py: add signing (NTLM/Kerberos) support, add read-only option (#1975)
* smbserver.py: add signing support by using computer account with NetLogon

* Move kerberos key calculation into impacket.krb5.crypto for portability

* smbserver.py: Support Kerberos

* smbserver.py: NetLogon only works with sealing

* smbserver.py: Adjust fixme

* smbserver.py: Fix raw NTLM authentication

* smbserver.py: Fix signed computer account authentication in NetLogon

* smbserver.py: Add readonly, and options to disable NTLM or Kerberos

smbserver.py: More debugging logs

* fix missing fileName for logging

* fix smbv1 typo

* smbserver.py: Add user to logging, simplify log output

* fix broken log

* fix smbv1 logging

* smbserver.py: Adjust cli option descriptions

* generate_kerberos_keys: change debug message

* smbserver.py: Username logging also for kerberos

* smbserver.py: change defaults for signing

* smbserver.py: Fallback to no signing if ticket decryption fals or client does not support signing

* smbserver.py: provoding computer credentials ONLY authenticates the specified user, netLogon and kerberos are in this case not used

* smbserver.py: return STATUS_LOGON_FAILURE if the Kerberos ticket cannot be decrypted

* smbserver.py: Return correct error message

* smbserver.py: Change -dcip to -dc-ip

* smbserver.py: correct -computeraccountdomain argument description

* smbrelayserver.py: Disable KerberosSupport in smbserver

* smbserver.py: Use getter methods for NTLM/Kerberos support
2026-01-30 15:33:00 -03:00
Azox a813ebe72b Implements RDP Relay Server (#2101)
* Add RDP Server

* fixing a typo

* Remove of an unnecessary log

* Fix RDP relay cookie and duplicate connection issues

* change log type

* refactor: restructure RDP server

* Remove second authentication blocking

* Revert accidental removal of debug print
2026-01-26 10:12:37 -03:00
Coontzy1 028f0724fe Added SAM history parsing to secretsdump.py and regsecrets.py (#2059)
* Added SAM history parsing to secretsdump.py and secretsdump.py

* Update impacket/examples/regsecrets.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/secretsdump.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/secretsdump.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/regsecrets.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update help message for -history argument

Clarified help message for -history argument to specify NTDS and SAM hashes.

* Clarify -history argument help text

Updated help text for the -history argument to clarify that it dumps NTDS and SAM hashes.

---------

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2026-01-09 16:18:01 -03:00
Q2Flc2Fy f2765e5f2e Add -basic switch to use Basic Authentication in exchanger (#2077)
* Add Basic Auth support in exchanger

* Update examples/exchanger.py

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>

---------

Co-authored-by: Thomas Caesar <thomas.caesar@sva.de>
Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>
2026-01-09 02:09:57 -03:00
Eugenie Potseluevskaya 40f5fd0056 feat: Added MSSQL Relay Server to NTLMRelayx (#2083)
* feat: Added MSSQL Relay Server to NTLMRelayx

* The PRELOGIN response was reified, instead than returning a hardcoded hex message. Several not needed imports were removed. The server name in the LOGIN request was changed to match the target.

* Updated ntlmrelayx.py to the current version, only lines related to MSSQLRelayServer added

* Added response to the client for NTLM authentication (imitate logon failure for unknown reasons)

* Update impacket/examples/ntlmrelayx/servers/mssqlrelayserver.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/ntlmrelayx/servers/mssqlrelayserver.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/ntlmrelayx/servers/mssqlrelayserver.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/ntlmrelayx/servers/mssqlrelayserver.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/ntlmrelayx/servers/mssqlrelayserver.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/examples/ntlmrelayx/servers/mssqlrelayserver.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Changed the constant in NTLM authentication as requested, and added import struct

* Update impacket/examples/ntlmrelayx/servers/mssqlrelayserver.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Added login failed response for MSSQL server authentication

---------

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2026-01-02 08:19:49 -03:00
omry99 96f362a2ae Fix typo in help message for registry value name (#2096) 2025-12-22 14:51:30 -03:00
n3rada 9c2d8b61ee Enhance MSSQL class to accept workstation ID and application name parameters (#2074)
* Enhance MSSQL class to accept workstation ID and application name parameters

* Add timeout parameter to MSSQL connect method for improved socket handling

* Update impacket/tds.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Update impacket/tds.py

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* Defined --host-name and --app-name parameters in the mssqlclient example, leveraging workstation_id and application_name properties added to TDS

---------

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2025-11-20 09:56:52 -03:00
fulc2um 7bd0d5abe5 [tstool.py update] Remote Desktop Shadowing feature support (#2064)
* added RpcShadow2 function and prereqs. Modified tstool to include shadow function

* Resolved requested change: unnecessarily creating a second instance of TSTS.RpcShadow2Response
2025-11-17 16:33:31 -03:00
adrian manrique 4030fc03d2 Include deprecation warning in split.py
Added a deprecation warning banner to notify users.
2025-10-16 11:19:18 -03:00
adrian manrique cbaf60e555 Add deprecation warning in main function
Print deprecation warning banner when main is called.
2025-10-16 11:18:35 -03:00
zblurx eaf2e55638 [LDAP] Add custom cbt_value (#1977)
* add custom cbt_value

* add example script to check LDAP status

* applied code review changes
   - make channel_bidinng_value variable public

---------

Co-authored-by: Kali <adrian.manrique@gmail.com>
2025-10-02 11:38:29 -03:00
MaxToffy 77988233c0 Add parsing for 'Export' hives and boot key computation from class names (#1840)
* Added support for "export" hive format + compute  bootkey from class names

* Fixing bug when key does not exist

* Better data extraction to avoid special characters errors

* Fix remote dumping errors

* Fix conflicts

* Reverting changes in examples/secretsdump and impacket/examples/secretsdump. Will be handled in a new PR

* Implemented Registry as an abstract class. Implemented winregistry.get_registry_parser as a factory function to instantiate right parser based in given hive parameter. Refactor registry-read and secretsdump to leverage this factory.

* Enhancing -system description in secretsdump\nClarifying that SYSTEM hive has to be in binary format

* Update the description of the `system` flag

---------

Co-authored-by: gabrielg5 <gabriel.gonzalez@fortra.com>
2025-09-26 15:58:09 -03:00
Peter Gabaldon 2e518256cb [SECRETSDUMP] - NTDS.dit Dumping with Shadow Snapshot Method via WMI (No Code Execution) (#2021)
* Implemented also NTDS.dit download using ShadowSnapshot method via WMI

* Added some debug msgs

* Finished, but error when decrypting. Also with other methods. Found bug?

* Finished, but error when decrypting. Also with other methods. Found bug?

* Adding checks for correct options usage. https://github.com/fortra/impacket/pull/2021#pullrequestreview-3227404992

---------

Co-authored-by: Peter Gabaldon <peter@pgj11.com>
2025-09-24 23:49:00 -03:00
Gabriel Gonzalez 85a03c64b9 Enhance attack logging for ntlmrelayx (#2032)
* Adding ID to each client. Logging it when relay succeeds. Showin it in 'socks' command

* Avoid crashing ntlmrelayx when 'socks' command has an invalid filter

* Showing relayed connection information when running attacks in context of relay

* Showing scheme in attacks logging. Fixing table printing in 'socks' command

* Add whitespace to standardize

* Code cleanup. Set 'target' and 'relay_client' as optional parameters in ProtocolAttack (backwards compatibilty)

* Format identity filter
2025-09-24 23:46:27 -03:00
Gabriel Gonzalez 8426ec9977 SMBServer & NTLMRelayx with IPv6 support (#2024)
* Adding IPv6 support to SMBServer

* Adding IPv6 support to NTLMRelayX (should update after #2023 - utils.get_address() -)

* Reusing utils.get_address to resolve the address on which each relay server will listen

* Update smbserver.py

Added a comment explaining why repeated code in SMBSERVER constructor

* Setting right address family for relay servers (ipv6)

* Fixing scope_id resolution in SMBSERVER class for IPv6
2025-09-19 21:08:43 -03:00
MaxToffy 35a71962bf Fix dacledit.py object query on specified DN (#1855) 2025-09-12 10:17:46 -03:00
Deft_ a6eac5173a [NTLMRELAYX] Implements WinRM(S) clients/server (#1987)
* Add new relay capabilities from and to WinRM(S)

* Remove winrm client

* Patch the winrmserver to add Negotiate parsing

* Patch the winrmsserver to add Negotiate parsing

* Add allow_reuse

---------

Co-authored-by: Aurélien CHALOT <aurelien.chalot@orangecyberdefense.com>
2025-09-08 09:53:42 -03:00
Gabriel Gonzalez 6864c8b470 rdp_check support IPv6 (#2023)
* Adding IP address family detection and support for both IPv4/6 to rdp_check example

* Avoid using 'ipaddress' module. Add flag '-6'

* Don't repeat [address] definition

* Creating 'utils.get_socket' and 'utils.get_address' for reusing these common functions. Using them in rdp_check

* Fixed 'utils.get_connected_socket' function name

* Add ability to set the scope_id with interface name - not only by its indes
2025-09-04 00:21:10 -03:00
NuclearFizzler 835623aea5 GetNPUser.py: Single targets now correctly outputs hash to file (#1867)
* GetNPUsers.py: Single targets now correctly outputs hash to file

* Close file objects when done

* GetNPUsers.py: Cleaned up file handling
2025-08-20 20:37:17 -03:00
Davide Ornaghi b6993a1e41 Added flag to drop SSP from Net-NTLMv1 auth (#1360)
* Added flag to drop SSP from Net-NTLMv1 auth

* Rebased with the latest version

* Removed whitespaces

* Removed duplicated code caused by merge

---------

Co-authored-by: Davide Ornaghi <ornaghi@intre.it>
Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>
2025-08-20 18:12:09 -03:00
Otavio Brito f66f82b8db [samedit.py] Added example script to edit local SAM hashes (#1761)
* Added example script samedit.py

* Rebased with latest version

* Replaced instances of "options.hash" with "options.hashes"

---------

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>
2025-08-20 17:46:53 -03:00
Ryan Kleffman 9282c9bb12 Add -machine-only and -request-machine flags to GetUserSPNs.py (#2011)
* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* GetUserSPN's update to test machineonly flag

* Better naming of argument

* Better naming of argument

* Logging of machineOnly code

* Logging of machineOnly code

* ArgParse Description

* ArgParse Description

* ArgParse Description

* ArgParse Description

* Update examples/GetUserSPNs.py

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>

* Update examples/GetUserSPNs.py

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>

* Update GetUserSPNs.py

Added `or self.__requestMachine is not None`

* Update GetUserSPNs.py

Restore old formatting

---------

Co-authored-by: alexisbalbachan <alexisbalbachan@gmail.com>
2025-08-14 00:39:07 -03:00
Alex 578733af71 Fix 2 critical bugs in ntlmrelayx (#2019)
* Fix getFileTime missing import

* Fix SSL settings
2025-08-10 22:14:44 -03:00
fulc2um 00f43cf714 Add badsuccessor attack example (#2010)
* added badsuccessor attack changes

* Added explicit error message for SUPERSEDED account in case of KDC_ERR_CLIENT_REVOKED error

* added a link to microsoft docs regarding dmsa set up; fixed a typo

* Added a prerequisite check with a message in case it is not met

* 1. Leveraged logging instead of prints
2. Unified ldaps parameters
3. Renamed PA_DMSA_KEY_PACKAGE to KRB_DMSA_KEY_PACKAGE
4. Refactored ldapConnection to utilize impacket.examples.utils.init_ldap_session
5. Removed "double try" for search_ous replacing with a single one with specified controls value
6. Additional minor fixes

* Adjusted argument handling for -allowed-principals and descriptions for other arguments

* 1. Modified build_security_descriptor function to fix permissions: previously modification of the entry was not impossible with INSUFF_RIGHTS
2. Added modify_dmsa function
3. Cleaned up unused imports

* Minor typo fix: KRB_DMSA_KEY_PACKAGE -> KERB_DMSA_KEY_PACKAGE

* Renamed PA_DMSA_KEY_PACKAGE -> KERB_DMSA_KEY_PACKAGE

* Changed security controls value in search_ous function from 0x15 -> 0x5

---------

Co-authored-by: fulc2um <autouser@localhost>
2025-08-08 17:01:17 -03:00
Raz Kissos 20002f79e5 [SMB] Massive Fixes, Features and Refactoring (#1894)
* Add documentation in the comments for clearer use of NT_CREATE_ANDX flags.
Then sort out some mismatching flags.

* Change default shareAccessMode in the retr file methods to allow read, write and delete.
I found it out when capturing network traffic and seeing I can manage to read files with open handles.
This fixes SHARE_ACCESS_DENIED errors when trying to read files with handles on them.
This is the logical thing to do when we open files for reading.
We do not want to block other processes from interacting with the file.
This may raise problems when reading files that are being written into / being deleted.
I still think this is the right move since we usually want to read the files no matter what.

* Add ability to read files with open handles - this is related to my previous commits.

* Add ability to read files that have open handles to them.
This is related to my older commits on the subject.

* Update smbconnection.py

Add method parameters to `getFile` to easily communicate with the underlying SMB API.

* Fix `shareAccessMode` when opening files for writing.
We obviously do not want to allow others to write to the file while we are writing to it.

* Extend `SMBConnection`'s method parameters for `getFile` and `putFile` methods.

* Add comments for `DesiredAccess`, `ShareAccess` and `CreateDisposition` values in SMBv2.

* Update smb3structs.py

* Fix missing values.

* [SMB] Define CIFS SMB Date and SMB Time according to `2.2.1.4 Time`.
This is done to assist future development of SetInfo operations on files and directories.

```
Date Conversion Example - Year Component:
-----------------------------------------

    2009 - 1980 = 29

            | (convert to binary)
            V

    0001 1101

            | (position data correctly by shifting)
            V

                    0001 1101
    <<                     9
        ---------------------
    =  0 0011 1010 0000 0000

            | (trim to correct size with bitwise AND of correct mask)
            V

        0 0011 1010 0000 0000
    &   1111 1110 0000 0000
        ---------------------
    =   0011 1010 0000 0000
```

* [SMB] Added CIFS DateTime objects helper methods to convert values to classes.

* [SMB] Feature: added support for set_file_info method using trans2.
By doing so I also fixed a bad structure definition in the SMBSetFileBasicInfo structure.
Now we can modify file information remotely ;)

* [SMBServer] Moved FileTime Conversion methods to the base SMB library.
Also converted the SMB DATETIME methods to use my SMB_DATE and SMB_TIME implementations.

* [SMBConnection] Added type hinting for (almost) all methods.
Also implemented setInfo method to use for setting file information.

* [TEST_SMB] Add tests for new setInfo method.

* [TEST_SMB] This is causing errors so I will wait for now.

* [SMBConnection] add support for default info class type in queryInfo method.

* [SMBConnection] Fix queryInfo to allow retrieval of more
fileInformationClasses other than the default one.

* [attrib] Added attrib example to showcase file attribute modifications using SMB.
for now only implemented query.

* [smbserver] fix missing pack operation in getSMBTime method.

* [attrib] Finished set action, thus finishing the attrib example script.

* [attrib] Final touches, adding output to set action as well.

* [attrib] Add option to set connection timeout.

* [smbclient] Add reconnect command.

* [smb] Fix accidental SMB_TIME creation with removing `+ 1980` to hours.

* [examples] Implement filetime.py
An example script that allows querying and modifying file timestamps using SMB.

* After merge, fix some syntax issues.

* Actually show subparser's descriptions now.

* [SMB] Removed type annotations. Improved comments. Cleaned imports.

* [SMB] Removed type annotations, improved comments.

* [SMB] Comment changes.

* [examples] Add handling of empty action, even though argparse should catch it.

* refactor: Fix PR requests.
2025-08-07 15:01:58 -03:00
Gabriel Gonzalez 849c74b7b9 Monkeypatches (#2003)
* Added monkeypatches.py; contains a couple of functions to modify for specific usecases/issues: monkeypatch_ssl_create_default_context and monkeypatch_readline_backend

* Revert "Added monkeypatches.py; contains a couple of functions to modify for specific usecases/issues: monkeypatch_ssl_create_default_context and monkeypatch_readline_backend"

This reverts commit 7049ded298.

* defining and running monkeypatch functions from the init of impacket.examples

* leveraging 'init_ldap_session' from addcomputer.py

* leveraging ssl monkeypatch in 'init_ldap_session'
2025-08-01 11:39:18 -03:00
alexisbalbachan 1f00d556ac Add user filter on findDelegation (rebased) (#1999)
* Rebase from PR 1184

* Filtering fixes

* Removed extra validations no longer needed after having a dynamic ldap filter
2025-07-17 05:01:34 -03:00
shellinvictus bf2d749f49 dacledit.py: -mask added + bugfix (#1912)
* examples/dacledit.py: added parameter -mask for custom rights

* examples/dacledit.py: fix bad mask parsing

---------

Co-authored-by: shellinvictus <shellinvictus@localhost>
2025-07-10 09:20:41 -03:00
Markb1337 337569b260 Added user-status functionality to the SAMHashes Class of the secrestdump.py (#1847)
* Added functionality to the SAMHashes Class of the secrestdump.py library to be able to print the user status for SAM dumps. There was already a user-status flag for the NTDS dumps, but not for the SAM dumps. Now, when directly calling secretsdump.py to make a SAM dump, the user can specify the -user-status flag, just like with the NTDS dump. Alternatively, when other tools are using the Secretsdump library, they can simply initiate the SAMHashes class with the printUserStatus flag set to True. The default is False, so if you don't specify anything when calling the Secretsdump Library it will do exactly as it did before. This should not break any existing tools.

* Added some extra checks to make sure the account is no longer marked as "locked" when the lockout duration has passed. In the previous interation, the "locked" mark was only removed after the locked account was used at least once after being unlocked.

---------

Co-authored-by: Mark Bregman <mark.bregman@fox-it.com>
2025-07-08 15:02:44 -03:00
Jannik Vieten 2e87adefcc smbserver: gracefully exit on KeyboardInterrupt (#1969) 2025-07-01 16:09:36 -03:00
Roman Karwacik b6b0daecb4 ntlmrelayx.py: RPC server and EPM (#1974)
* RPC Relay server

* Adds https://github.com/fortra/impacket/pull/1442

* Add EPM so e.g. printspooler can be relayed

* Fix log creation

* Fix copyright header

* RPCAttack: Save certificate to file instead of printing to console by default

* Removed unused RPC attack mode

* RPC relay server: keep relaying

* RPC relay server: Fix forgotten variable

* rpcrelayserver.py: Fixing client_address property

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>

* rpcrelayserver.py: replace constant by reference

* rpcrelayserver.py: keep relaying 2

* rpcrelayserver.py: disable multirelay

* rpcrelayserver.py: outsource target setting to negotiate_ntlm_session

* RPCRelayServer: Consuming targets only on NTLMSSP_AUTH_NEGOTIATE

* Opportunistic enhancement: consider finishedAttack target's scheme to retrieve target candidate

---------

Co-authored-by: Sylvain Heiniger <sploutchy@gmail.com>
Co-authored-by: S3cur3Th1sSh1t <27858067+S3cur3Th1sSh1t@users.noreply.github.com>
Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2025-06-23 12:46:06 -03:00
ICheer_No0M 0612d07895 Update owneredit.py (#1976)
Edit the description
2025-06-11 10:56:41 -03:00