Commit Graph

1250 Commits

Author SHA1 Message Date
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
Asa Reynolds 6175e924fc update harmj0y blog link (#1978)
replace outdated link with current version
2025-06-11 10:43:48 -03:00
Vincent Yang 80c4dba1c9 Fix smbexec getting stuck (#1963) 2025-05-29 02:51:23 -03:00
Gabriel Gonzalez fde4265abd Adding "-dc-host" parameter to dacledit.py, owneredit.py, rbcd.py. Reintroduced SessionError:"STATUS_NOT_SUPPORTED" in function _get_machine_name now that all these examples have "-dc-host" parameter. (#1940) 2025-05-08 10:48:19 -03:00
Muhammad Ibrahim 756ca96e4a Added Support for LDAPS When Retrieving LAPS Password from Windows Server 2025 (#1942)
* Added Support for LDAPS When Using Windows Server 2025

* set ldaps_flag as optional in ldap_login()

---------

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2025-04-30 17:49:57 -03:00
Gabriel Gonzalez 34cdb1b972 Techdebt examples bootstrapping fixes (#1935)
* Fixing findDelegation.py - wrong ldap_login parameter name

* Fixing GetUserSPNs.py - wrong parse_identity parameter value

* Fixing rpcmap.py - wrong parse_identity parameter value
2025-03-31 14:01:20 -03:00
Gabriel Gonzalez ae0ec300f8 Techdebt examples bootstrapping v2 (#1928)
* Standardized examples logger init method

* Fixing missing import

* Standardized examples init_ldap_session function #1

* Calling new shared function _ldap3_kerberos_login from example addcomputer

* Removed considering -debug in each example. Now it's handled in utils.

* Standardized EMPTY_LM_HASH in impacket.examples.utils

* Unify parse_identity function (phase 1)

* Standardized parse_identity

* Renamed "_ldap3_kerberos_login" to "ldap3_kerberos_login" (as it is called from outside)

* Standardize "logger" init in regsecrets.py

* Standardized LDAP login into a single function in utils.py:ldap_login
2025-03-26 22:58:39 -03:00
Vincent Yang 0711a41e5f Fix mssqlinstance.py forgot print notfound (#1929) 2025-03-26 10:58:09 -03:00
Julien Egloff 8b4566b12f Adding regsecrets to impacket (#1898)
Co-authored-by: laxa <laxa@ddracepro.net>
2025-03-14 17:20:46 -03:00
p0rtL6 678cd0abbe Add the Option to Dump Ntlm Hashes in Ntlmrelayx (#1904)
* Add option to dump relayed hashes to console (ntlmrelayx)

* Add Documentation

* Simplify print statements

* Update README.md

Reverted changes in the README.md file in preparation for merge.

---------

Co-authored-by: p0rtL6 <p0rtl.pue@gmail.com>
Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2025-03-11 09:09:21 -03:00
Packet Phantom ead516a120 Display created ProcessId using wmiexec.py (#1814)
* drop python2 support in wmiexec.py

* display ProcessId to user
2025-02-26 21:23:01 -03:00
Narmjep 168e1aefb6 small grammar fix (#1896) 2025-02-18 08:40:04 -03:00
Julien Egloff 075f2b10a7 Use logging.info to handle -ts switch properly (#1884)
Co-authored-by: laxa <laxa@ddracepro.net>
2025-02-06 10:09:53 -03:00
Jannik Vieten ac02e0ee49 changepasswd.py: improved error handling (#1865) 2025-01-09 09:17:05 -03:00
marcobarlottini c1a53aaa13 feat in net.py: add functionality to enable and disable user accounts (#1801)
* feat in net.py: add functionality to enable and disable user accounts

* fix: do not overwrite flags when enabling/disabling accounts

* call function create account with according flags in net.py

* refactor keep uac flags out of parameters of enable,disable function definitions
2024-12-20 16:36:08 -03:00
trietend e9a47ffc2b allow to pass commands to mssqlclient.py via command line (#1770)
* allow to pass commands to mssqlclient.py via command line

* Changed parameter name and nargs value as suggested

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

* Update examples/mssqlclient.py

---------

Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2024-12-06 08:26:10 -03:00
Gabriel Gonzalez ec32e73dfe Checking for 'value' != None before creating IWbemClass properties (#1854)
* Checking for 'value' != None before creating IWbemClass properties

* wmiquery - printing exception stack trace only if error is not 'S_FALSE'
2024-12-05 11:21:00 -03:00
q-roland 463693ea04 SCCM Management Point and Distribution Point relay attacks implementation (#1832)
* Adding SCCM Policies attack and SCCM Distribution Point attack

* Fixing typo in error log message

* Handle packages one at a time for DP attack ; uniformise coding style ; update requirements.txt
2024-11-25 09:26:39 -03:00
Fluffy_Kaiju 3ce41be452 docs(smbexec): update doc dead link (#1850)
* Update the blog link to web.archive.org
2024-11-20 17:32:16 -03:00
Jannik Vieten 835e17550b Fixed warnings with Python 3.12 (#1695)
* fixed SyntaxWarnings due to invalid escape sequence

* fixed DeprecationWarning since datetime.datetime.utcnow() is deprecated in Python 3.12+

* fixed DeprecationWarning since datetime.datetime.utcfromtimestamp() is deprecated in Python 3.12+
2024-10-24 09:00:11 -03:00
gabrielg5 d97e773022 Removing examples warned in v0.11 2024-08-29 11:58:19 -03:00
gabrielg5 27e7e7478d Updating copyright banner... 2024-08-28 17:52:57 -03:00
marcobarlottini 9956d4529e bugfix in net.py: show user account enabled or not enabled (#1797) 2024-08-27 17:47:40 -03:00
adrian manrique 0630989669 removed pyreadline dependency (#1800)
* removed pyreadline dependency

* replaced pyreadline by pyreadline3

* Update setup.py
2024-08-27 14:02:40 -03:00
shikatano 2b2977a1b4 added ability to set the RENEW ticket option to renew a TGT (#1585) 2024-08-26 09:29:36 -03:00
alexisbalbachan 089603e07e Update getST.py (#1794)
impacket #1650: Fixes encoding unicode errors while performing S4U
2024-08-23 15:57:01 -03:00
Spork 3f5378ac64 feat: add principalType as new option (#1749)
* feat: add principalType as new option

* fix: exception if non exsistent principalType is given
2024-08-22 12:48:57 -03:00
Didier A f98c987043 winregistry.py: handle value name containting backslash character (#1767)
* winregistry: handle value name containting backslash character

* Update examples/registry-read.py

* Update impacket/winregistry.py

* Update impacket/winregistry.py

* Update impacket/winregistry.py

* Update impacket/winregistry.py

---------

Co-authored-by: DidierA <1620015+didiera@users.noreply.github.com>
Co-authored-by: Gabriel Gonzalez <gabriel.gonzalez@fortra.com>
2024-08-19 16:57:05 -03:00
Gabriel Gonzalez 5d881eceff Logging multirelay status on ntlmrelayx.py (#1789)
* Logging multirelay status on ntlmrelayx.py

* Logging multirelay status just enabled / disabled
2024-08-16 16:11:25 -03:00
Charlie Bromberg 9eb25b3b35 Handled SID not found in LDAP error (#1393) 2024-08-15 10:14:42 -03:00
Gabriel Gonzalez e52791288d smbserver examples log to console (#1791)
* Setting "log_file" property to "None" for smbserver configuration file ~ will print to console

* Setting "log_file" property to "None" for smbrelayx.py
2024-08-12 20:54:08 -03:00
Korznikov Alexander 829239e334 tstool.py update & kerberos issue fix (#1420)
* kerberos issue fix & refactoring

* tstool.py: resolve SID to Username
2024-08-07 02:19:46 -03:00
Gabriel Gonzalez 2571ce44d2 Support for adding REG_MULTI_SZ values through reg.py (#1785)
* Support for adding REG_MULTI_SZ values through reg.py

* Fixing default value for "-vd" in reg.py

* Fixing 2x null-bytes handling for REG_MULTI_SZ values in rrp.py

* Fixing check of 2x null-bytes ending REG_MULTI_SZ values

* Fixing how REG_MULTI_SZ are printed to stdout (query, add) - replacing \0 with \n

* Fixing output message when adding a new value in the registry using the "add" command of reg.py
2024-08-06 13:09:06 -03:00
Gabriel Gonzalez 2a0603a7d2 Adding parameter "-outputfile" to set smbserver log file. (#1784)
* Adding parameter "-outputfile" to set smbserver log file.

* Fixing log object
2024-08-05 15:30:09 -03:00
joeldeleep 0f64d63a46 Samrdump.py updated (#1622)
* Update samrdump.py

Added AdminComment while dumping. This will ensure to dump the Description field in querydispinfo or queruser

* Update samrdump.py
2024-07-31 13:23:53 -03:00
Alvin Smith 36e48bdcfd Update: example/lookupsid.py with Kerberos auth option (#1656)
* Update: example/lookupsid.py with Kerberos auth option

* Update: example/lookupsid.py with Kerberos auth option by adding '-k'

---------

Co-authored-by: Alvin Smith <alv1n.5mith.is@protonmail.com>
2024-07-31 13:07:41 -03:00
pfiatde 8cb0b0af4e Update reg.py (#1753) 2024-07-23 12:10:13 -03:00