Skip to content

Commit 84ebce4

Browse files
committed
Merge remote-tracking branch 'ThePorgs/main' into fork/blackarrowsec/inline-secretsdump
# Conflicts: # examples/secretsdump.py # impacket/examples/secretsdump.py
2 parents 8c20988 + 299bb63 commit 84ebce4

File tree

319 files changed

+15071
-5281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+15071
-5281
lines changed

.github/workflows/build_and_test.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,11 @@ jobs:
4848
strategy:
4949
fail-fast: false
5050
matrix:
51-
python-version: ["3.7", "3.8", "3.9", "3.10"]
51+
python-version: ["3.9", "3.10","3.11","3.12"]
5252
experimental: [false]
5353
os: [ubuntu-latest]
5454
include:
55-
- python-version: "3.6"
56-
experimental: false
57-
os: ubuntu-20.04
58-
- python-version: "3.11-dev"
55+
- python-version: "3.13-dev"
5956
experimental: true
6057
os: ubuntu-latest
6158
continue-on-error: ${{ matrix.experimental }}

ChangeLog.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,105 @@ Project owner's main page is at www.coresecurity.com.
55
Complete list of changes can be found at:
66
https://github.com/fortra/impacket/commits/master
77

8+
## Impacket v0.12.0 (Sep 2024):
9+
1. Library improvements
10+
* Fixed broken hRSetServiceObjectSecurity method (@rkivys)
11+
* Removed dsinternals dependency (@anadrianmanrique)
12+
* Fixed srvs.hNetrShareEnum returning erronous shares (@cnotin)
13+
* Fixed lmhash computing to support non standard characters in the password (@anadrianmanrique)
14+
* Assorted fixes when processing Unicode data (@alexisbalbachan)
15+
* Added `[MS-GKDI]` Group Key Distribution Protocol implementation (@zblurx)
16+
* Fixed incorrect padding in SMBSessionSetupAndX_Extended_ResponseData (@rtpt-erikgeiser)
17+
* Upgraded dependency pyreadline -> pyreadline3 (@anadrianmanrique)
18+
* SMB Server:
19+
* Added query information level 0x0109 for smb1 "SMB_QUERY_FILE_STREAM_INFO" (@Adamkadaban)
20+
* Fixed filename encoding in queryPathInformation (@JerAxxxxxxx)
21+
* Fixed NextEntryOffset for large directory listings (@robnanola)
22+
* Fixed server returning an empty folder when cutting and pasting recursive directories (@robnanola)
23+
* DHCP: Fixed encoding issues (@ujwalkomarla)
24+
25+
3. Examples improvements
26+
* [secretsdump.py](examples/secretsdump.py):
27+
* Double DC Sync performance for DCs supporting SID lookups (@tomspencer)
28+
* Added ability to skip dumping of SAM or SECURITY hives when performing remote operations (@RazzburyPi)
29+
* Added ability to specify users to skip when dumping NTDS (@RazzburyPi)
30+
* [ticketer.py](examples/ticketer.py):
31+
* Support to create Sapphire tickets (@ShutdownRepo)
32+
* [GetUserSPNs.py](examples/GetUserSPNs.py), [getTGT.py](examples/getTGT.py):
33+
* Support for Kerberoasting without pre-authentication and ST request through AS-REQ (@ShutdownRepo)
34+
* [wmiexec.py](examples/wmiexec.py):
35+
* Fix kerberos with remoteHost & add '-target-ip'(@XiaoliChan)
36+
* [ntlmrelayx.py](examples/ntlmrelayx.py):
37+
* Added the creation of a new machine account through SMB (@BlWasp)
38+
* NTLMRelayX Multirelay fixes for target handling, added --keep-relaying flag (@alexisbalbachan)
39+
* Logging multirelay status when triggering the example (@gabrielg5)
40+
* Write certificates to file rather than outputting b64 to console (@RazzburyPi)
41+
* Improved ability to continue relaying to ADCS web enrollment endpoint in order to request multiple certificates for different users (@RazzburyPi)
42+
* Fixed compatibility issue with other SMB clients connecting to the SOCKS proxy created by ntlmrelayx (@jfjallid)
43+
* Allow configuration of the SOCKS5 address and port (@rtpt-erikgeiser)
44+
* Fixed implementation of MSSQLShell (@gabrielg5)
45+
* Logging notification of received connections in all relay servers (@gabrielg5)
46+
* Add domain and username to interactive Ldap shell message (@minniear)
47+
* Enhanced MSSQLShell in NTLMRelayX leveraging TcpShell & output messages (@gabrielg5)
48+
* LDAP Attack: Bugfixes when parsing responses (@SAERXCIT)
49+
* [getST.py](examples/getST.py):
50+
* Added -self, -altservice and -u2u for S4U2self abuse, S4U2self+u2u, and service substitution (@ShutdownRepo)
51+
* Added ability to set the RENEW ticket option to renew a TGT (@shikatano)
52+
* Fixed unicode encoding error when using the -impersonate flag (@alexisbalbachan)
53+
* [getTGT.py](examples/getTGT.py):
54+
* Added principalType as new parameter (@DevSpork)
55+
* [reg.py](examples/reg.py):
56+
* Start remote registry as unprivileged user in reg.py (@dadevel)
57+
* Allow adding Binary values (@dc3l1ne)
58+
* Add missing Null byte for REG_SZ values (@PfiatDe)
59+
* Support for adding REG_MULTI_SZ values through (@garbrielg5)
60+
* [smbclient.py](examples/smbclient.py):
61+
* Added ability to provide an output file that the smbclient mini shell will write commands and output to (@RazzburyPi)
62+
* Fixed path parse issue when running `tree` command (@trietend)
63+
* [smbserver.py](examples/smbserver.py):
64+
* Added parameter "-outputfile" to set smbserver log file(gabrielg5)
65+
* [DumpNTLMInfo.py](examples/DumpNTLMInfo.py):
66+
* Allow execution on non-default ports (@jeffmcjunkin)
67+
* Fixed KeyError exception when running with a Windows 2003 target (@XiaoliChan)
68+
* [findDelegation.py](examples/findDelegation.py):
69+
* Added new column to show if SPN exists (@p0dalirius)
70+
* [mssqlclient.py](examples/mssqlclient.py):
71+
* Added `-target-ip` parameter to allow Kerberos authentication without much change in the DNS configuration of the local machine (@Palkovsky)
72+
* [mssqlshell.py](examples/mssqlshell.py):
73+
* Switching back to original DB after running `enum_impersonate` command (@exploide)
74+
* Fixed logging in printReplies showing error messages (@gabrielg5)
75+
* [registry-read.py](examples/registry-read.py):
76+
* Fixed scenario where value name contains backlash (@DidierA)
77+
* [net.py](examples/net.py):
78+
* Fixed User "Account Active" property value (@marcobarlottini)
79+
* Fixed log messages printing variables in the wrong order (@Cyb3rC3lt)
80+
* [rbcd.py](examples/rbcd.py):
81+
* Handled SID not found in LDAP error (@ShutdownRepo)
82+
* [GetUserSPNs.py](examples/GetUserSPNs.py):
83+
* Updated the help information for -outputfile to be consistent with -save (@scarvell)
84+
* [ntfs-read.py](examples/ntfs-read.py):
85+
* Minor refactor in ntfs-read.py to make it more human-readable (@NtAlexio2)
86+
* [ldap_shell.py](examples/ldap_shell.py):
87+
* Added support for dirsync and whoami commands (@nurfed1)
88+
* [lookupsid.py](examples/lookupsid.py):
89+
* Now supports kerberos auth (@A1vinSmith)
90+
* [samrdump.py](examples/samrdump.py):
91+
* Will fetch AdminComment using MSRPC (@joeldeleep)
92+
* [tstool.py](examples/tstool.py):
93+
* Added support for kerberos auth, resolves SIDs (@nopernik)
94+
95+
4. New examples
96+
* [describeTicket.py](examples/describeTicket.py): Ticket describer and decrypter. (@ShutdownRepo)
97+
* [GetADComputers.py](examples/GetADComputers.py): Query's DC via LDAP and returns the COMPUTER objects and the useful attributes such as full dns name, operating system name and version. (@F-Masood)
98+
* [GetLAPSPassword.py](examples/GetLAPSPassword.py): Extract LAPS passwords from LDAP (@zblurx and @dru1d-foofus)
99+
* [dacledit.py](examples/dacledit.py): This script can be used to read, write, remove, backup, restore ACEs (Access Control Entries) in an object DACL (Discretionary Access Control List). (@ShutdownRepo) (@BlWasp_) (@Wlayzz)
100+
* [owneredit.py](examples/owneredit.py): Added this script to abuse WriteOwner (ADS_RIGHT_WRITE_OWNER) access rights. This allows to take ownership of another object, and then edit that object's DACL (@ShutdownRepo) (@BlWasp_)
101+
102+
As always, thanks a lot to all these contributors that make this library better every day (up to now):
103+
104+
@tomspencer @anadrianmanrique @ShutdownRepo @dadevel @gjhami @NtAlexio2 @F-Masood @BlWasp @gabrielg5 @XiaoliChan @omry99 @Wlayzz @themaks @alexisbalbachan @RazzburyPi @jeffmcjunkin @p0dalirius @dc3l1ne @jfjallid @Palkovsky @rtpt-erikgeiser @trietend @zblurx @dru1d-foofus @PfiatDe @DidierA @marcobarlottini @PeterGabaldon @m8r1us @5yn @tzuralon @Adamkadaban @scarvell @JerAxxxxxxx @ujwalkomarla @robnanola @SAERXCIT @nurfed1 @A1vinSmith @joeldeleep @nopernik
105+
106+
8107
## Impacket v0.11.0 (Aug 2023):
9108
1. Library improvements
10109
* Added new Kerberos error codes (@ly4k).
@@ -623,7 +722,7 @@ As always, thanks a lot to all these contributors that make this library better
623722
UUIDs used and that information is included as well. This could be helpful when reading a portmap output and to
624723
develop new functionality to interact against a target interface.
625724
* `smbexec.py`: Another alternative to psexec. Less capabilities but might work on tight AV environments. Based on the
626-
technique described at https://www.optiv.com/blog/owning-computers-without-shell-access. It also
725+
technique described at https://web.archive.org/web/20190515131124/https://www.optiv.com/blog/owning-computers-without-shell-access. It also
627726
supports instantiating a local smbserver to receive the output of the commandos executed for those situations
628727
where no share is available on the other end.
629728
* `smbrelayx.py`: It now also listens on port 80 and forwards/reflects the credentials accordingly.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Impacket
44
[![Latest Version](https://img.shields.io/pypi/v/impacket.svg)](https://pypi.python.org/pypi/impacket/)
55
[![Build and test Impacket](https://github.com/fortra/impacket/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/fortra/impacket/actions/workflows/build_and_test.yml)
66

7-
FORTRA. Copyright (C) 2023 Fortra. All rights reserved.
7+
Copyright Fortra, LLC and its affiliated companies. All rights reserved.
88

99
Impacket was originally created by [SecureAuth](https://www.secureauth.com/labs/open-source-tools/impacket), and now maintained by Fortra's Core Security.
1010

@@ -50,17 +50,17 @@ Getting Impacket
5050

5151
### Latest version
5252

53-
* Impacket v0.11.0
53+
* Impacket v0.12.0
5454

5555
[![Python versions](https://img.shields.io/pypi/pyversions/impacket.svg)](https://pypi.python.org/pypi/impacket/)
5656

5757
[Current and past releases](https://github.com/fortra/impacket/releases)
5858

5959
### Development version
6060

61-
* Impacket v0.12.0-dev (**[master branch](https://github.com/fortra/impacket/tree/master)**)
61+
* Impacket v0.13.0-dev (**[master branch](https://github.com/fortra/impacket/tree/master)**)
6262

63-
[![Python versions](https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8%20|%203.9%20|%203.10-blue.svg)](https://github.com/fortra/impacket/tree/master)
63+
[![Python versions](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-blue.svg)](https://github.com/fortra/impacket/tree/master)
6464

6565

6666
Setup

examples/DumpNTLMInfo.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env python
22
# Impacket - Collection of Python classes for working with network protocols.
33
#
4-
# Copyright (C) 2023 Fortra. All rights reserved.
4+
# Copyright Fortra, LLC and its affiliated companies
5+
#
6+
# All rights reserved.
57
#
68
# This software is provided under a slightly modified version
79
# of the Apache Software License. See the accompanying LICENSE file
@@ -479,16 +481,17 @@ def _get_my_name(self):
479481

480482

481483
class DumpNtlm:
482-
def __init__(self, ip, hostname, port) -> None:
484+
def __init__(self, ip, hostname, port, protocol) -> None:
483485
self.target = ip
484486
self.hostname = hostname
485487
self._sess_port = int(port)
488+
self._protocol = protocol
486489
self._timeout = 60
487490

488491
def DisplayInfo(self):
489-
if self._sess_port in [139, 445]:
492+
if self._protocol == 'SMB':
490493
self.DisplaySmbInfo()
491-
elif self._sess_port in [135]:
494+
elif self._protocol == 'RPC':
492495
self.DisplayRpcInfo()
493496

494497
def DisplayRpcInfo(self):
@@ -628,34 +631,42 @@ def __convert_size(self, size_bytes):
628631
if __name__ == '__main__':
629632

630633
print(version.BANNER)
631-
logger.init()
632634

633635
parser = argparse.ArgumentParser(add_help = True, description = "Do ntlm authentication and parse information.")
634636
parser.add_argument('target', action='store', help='<targetName or address>')
635637
parser.add_argument('-debug', action='store_true', help='Turn DEBUG output ON')
638+
parser.add_argument('-ts', action='store_true', help='Adds timestamp to every logging output')
636639
parser.add_argument('-target-ip', action='store', metavar="ip address",
637640
help='IP Address of the target machine. If omitted it will use whatever was specified as target. '
638641
'This is useful when target is the NetBIOS name and you cannot resolve it')
639-
parser.add_argument('-port', choices=['135', '139', '445'], nargs='?', default='445', metavar="destination port",
640-
help='Destination port to connect to SMB/RPC Server')
642+
parser.add_argument('-port', type=int, default=445, metavar="destination port",
643+
help='Destination port to connect to SMB/RPC Server')
644+
parser.add_argument('-protocol', choices=['SMB', 'RPC'], nargs='?', metavar="protocol",
645+
help='Protocol to use (SMB or RPC). Default is SMB, port 135 uses RPC normally.')
641646

642647
if len(sys.argv) == 1:
643648
parser.print_help()
644649
sys.exit(1)
645650

646651
options = parser.parse_args()
647-
648-
if options.debug is True:
649-
logging.getLogger().setLevel(logging.DEBUG)
650-
logging.debug(version.getInstallationPath())
651-
else:
652-
logging.getLogger().setLevel(logging.INFO)
652+
logger.init(options.ts, options.debug)
653+
654+
if options.port == 135:
655+
if not options.protocol:
656+
options.protocol = 'RPC'
657+
logging.info("Port 135 specified; using RPC protocol by default. Use `-protocol SMB` to force SMB protocol.")
658+
elif options.protocol == 'SMB':
659+
logging.info("Port 135 specified with SMB protocol. Are you sure you don't want `-protocol RPC`?")
660+
elif not options.protocol:
661+
options.protocol = 'SMB'
662+
logging.info("Defaulting to SMB protocol.")
653663

654664
try:
655665
if options.target_ip is not None:
656-
dumper = DumpNtlm(options.target_ip, options.target, int(options.port))
666+
dumper = DumpNtlm(options.target_ip, options.target, int(options.port), options.protocol)
657667
else:
658-
dumper = DumpNtlm(options.target, options.target, int(options.port))
668+
dumper = DumpNtlm(options.target, options.target, int(options.port), options.protocol)
669+
logging.info("Using target: %s, IP: %s, Port: %d, Protocol: %s" % (options.target, options.target_ip or options.target, options.port, options.protocol) )
659670
dumper.DisplayInfo()
660671
except Exception as e:
661672
if logging.getLogger().level == logging.DEBUG:

examples/Get-GPPPassword.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env python3
22
# Impacket - Collection of Python classes for working with network protocols.
33
#
4-
# Copyright (C) 2023 Fortra. All rights reserved.
4+
# Copyright Fortra, LLC and its affiliated companies
5+
#
6+
# All rights reserved.
57
#
68
# This software is provided under a slightly modified version
79
# of the Apache Software License. See the accompanying LICENSE file
@@ -255,19 +257,6 @@ def parse_target(args):
255257

256258
return domain, username, password, address, lmhash, nthash
257259

258-
259-
def init_logger(args):
260-
# Init the example's logger theme and debug level
261-
logger.init(args.ts)
262-
if args.debug is True:
263-
logging.getLogger().setLevel(logging.DEBUG)
264-
# Print the Library's installation path
265-
logging.debug(version.getInstallationPath())
266-
else:
267-
logging.getLogger().setLevel(logging.INFO)
268-
logging.getLogger("impacket.smbserver").setLevel(logging.ERROR)
269-
270-
271260
def init_smb_session(args, domain, username, password, address, lmhash, nthash):
272261
smbClient = SMBConnection(address, args.target_ip, sess_port=int(args.port))
273262
dialect = smbClient.getDialect()
@@ -293,7 +282,7 @@ def init_smb_session(args, domain, username, password, address, lmhash, nthash):
293282
if __name__ == '__main__':
294283
print(version.BANNER)
295284
args = parse_args()
296-
init_logger(args)
285+
logger.init(args.ts, args.debug)
297286

298287
if args.target.upper() == "LOCAL":
299288
if args.xmlfile is not None:

0 commit comments

Comments
 (0)