Commit Graph

55 Commits

Author SHA1 Message Date
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
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
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
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
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 27e7e7478d Updating copyright banner... 2024-08-28 17:52:57 -03:00
Charlie Bromberg 3760dfc639 [ticketer.py] Sapphire tickets (#1411)
* Adding -impersonate flag to ingest S4U2self+U2U TGT

* Functional version

* Commenting out duration customization for sapphire

* Fixes #1605

* Adding AD_IF_RELEVANT reference

* Fixing undefined tgt session key and wrong cname for impersonation

* Adding missing and ignored params
2023-10-04 19:24:32 -03:00
Gabriel Gonzalez 9b4a139405 Updated Copyright to 2023 2023-07-31 11:48:28 -03:00
0xdeaddood 1af76e13a3 Changed default PAC
- The default ticket structure contains the new PACs: PAC_ATTRIBUTES_INFO and PAC_REQUESTOR.
- Added option old-pac to forge tickets with the old structure. It will exclude PAC_ATTRIBUTES_INFO and PAC_REQUESTOR.
2023-05-05 22:47:16 -03:00
0xdeaddood 0e975eed71 Including new PAC functions under the extra-pac option 2023-05-05 18:39:57 -03:00
0xdeaddood f7fc9df286 Removed use of LDAP_SID
Added a new SID structure [MS-DTYP] 2.4.2.2
2023-05-05 12:41:29 -03:00
Dramelac 0d31fc350e Fix typo 2023-04-28 10:19:46 +02:00
Dramelac 46ffe05227 Change description on the extra-pac option 2023-03-19 11:21:31 +01:00
Dramelac bf4cc2dd2f Merge branch 'master' into add-pac-ticketer 2023-03-19 11:11:26 +01:00
alexisbalbachan f0ac44bd7b Merge pull request #1270 from Dramelac/master
Fix ticketer duration to support default 10 hours tickets
2023-03-16 11:25:32 -03:00
Gabriel Gonzalez 8799a1a2c4 Update file banners to reflect Fortra ownership 2022-12-14 17:28:23 -03:00
Dramelac 1fe2bbb336 Change default PAC 2022-09-07 17:27:45 +02:00
Dramelac 2b79d364b4 Ticketer extra-pac implementation (UPN_DNS_FULL, ATTRIBUTES, REQUESTOR) 2022-09-01 17:47:50 +02:00
Dramelac e6fd0a9ec8 Fix ticketer duration to support default 10 hours tickets 2022-02-25 16:42:38 +01:00
Martin Gallo cd4fe47cfc Arrange tagline, copyright and license notes across all source files
This was a pending change to:
- Use the same tagline, copyright and license notice across files.
- Remove authors' contacts that are no longer valid (due to affiliation changes).
- Update repository location.
- Update license file with missing licenses (althought those were already in source files).

This doesn't include any change on the source code, nor any change on current copyright or licenses. Just formatting and phrasing to make our and distro's maintainers life easier.
2021-07-20 10:04:27 -03:00
Arseniy Sharoglazov 919055c0fe Fixing a bug appeared after the optimization of NDR parser 2020-08-04 20:21:13 +03:00
Patrick Welzel e3032a5149 add option to examples/ticketer.py to read key directly from a UNIX Keytab
Parses Keytab file and extracts matching key for SPN automatically.
This makes Silver Ticket attacks on unix more convenient. ;)
2020-02-23 23:07:07 +01:00
asolino 8d4c91481b Print Library's installation path by default when -debug is specified 2020-02-05 19:52:39 -03:00
0xdeaddood 3b41d48e07 Add the timestamp option to several scripts
- GetADUsers.py, GETNPUsers.py, getST.py, getTGT.py, goldenPac.py, secretsdump.py, ticketer.py
2019-12-18 11:34:56 -03:00
asolino 553881b9da Merge branch 'master' into python36 2018-12-05 12:16:54 -03:00
asolino c328de8252 Changing Copyright notice 2018-12-05 12:14:55 -03:00
asolino 7eeff437c7 More code cleanup homework
- Optimizing imports
- Removing unused variables
- Still a lot to do.
- Test cases passing OK
2018-12-04 17:07:52 -03:00
asolino ec77ea3d06 Code cleanup homework
- Optimizing imports
- Removing unused variables
- Still a lot to do.
- Test cases passing OK
2018-12-04 14:47:16 -03:00
asolino 19334ddf54 Merge branch 'master' into python36 2018-11-19 12:30:38 -03:00
Viktor Szakats 3f29d8dcdb fix/secure URLs
* also remove/fix some whitespace such as tabs
  and spaces at EOL
2018-11-18 19:47:09 +00:00
asolino 8ff82b5e13 ticketer.py port to Python3 2018-10-09 12:46:19 -03:00
derUnbekannt 260cf20a06 Fixed an issue in which invalid parameters were passed to the "getKerberosTGT" function. 2018-05-04 23:30:04 -03:00
asolino 0b28d94832 Using raise the right way + removing print from traceback.print_exc() 2018-05-03 21:21:36 -03:00
asolino 8368e73c14 Requesting a ST when -request is used for silver ticket creation
* This functionality was missed when this feature was implemented in https://github.com/CoreSecurity/impacket/pull/354.
2018-04-25 22:35:34 -04:00
asolino c5a388168c Encrypting the TGS-REP with the right Key Usage (especially for AES)
* When encrypting the kdcRep['enc-part']['cipher'] part you have to use the following Key Usages depending on
the type of answer being generated. Per RFC 4120, section 7.5.1:
If it is a AS-REP -> Key Usage 3
If it is a TGS-REP -> Key Usage 8
When silver tickets functionality was implemented [here](https://github.com/CoreSecurity/impacket/pull/354),
this wasn't taken into account that all the answers, regardless of being a AS-REP or TGS-REP were encrypted with Key Usage 3.

You might wonder why RC4 silver tickets where working?
RFC4757 section 3 has the answer. The Key Usages for RC4 are different by the ones defined in RFC4120 and,
for example, for the AS-REP the Key Usage to be used is 8 (instead of 3). Thus, all the RC4 testings were
passing, until @ropnop tested it with AES keys (where the Key Usage numbers to be used are the ones in
RFC 4120), causing the decryption checks when saving the ticket in ccache format to trigger and error
due to invalid checksum.

The issue in https://github.com/CoreSecurity/impacket/issues/443#issuecomment-384430424 should be fixed. Please test.
2018-04-25 22:08:00 -04:00
Matan Hart 6c69cc468d fixed small mistakes in extrasid 2018-04-12 18:47:45 +03:00
Matan Hart 27dc1c93dc Added support for multiple ExtraSids
Hola @asolino!
I added an option to provide multiple SIDs to be included in the `ExtraSid` field inside the PAC.
This addition is important to avoid some DC logs (well summarized by @HarmJ0y here - http://www.harmj0y.net/blog/redteaming/mimikatz-and-dcsync-and-extrasids-oh-my/).
2018-04-03 18:36:51 +03:00
luz.paz 0e96b60b92 Misc. typos
Found via `codespell -q 3 -I ../impacket-word-whitelist.txt` through downstream `curl`
2018-03-16 09:42:21 -04:00
asolino c61fbb8d6b Fixed wrong sname construction 2018-01-25 10:49:08 -03:00
asolino 58c2aecfad Copyright updated 2018-01-20 18:28:01 -03:00
asolino 811d715525 We want the server to include the target port as well
* Important when writing service tickets that needs the port specified (e.g. MSSQLSvc)
2018-01-20 18:10:20 -03:00
asolino cf84ee5e4d ASN1 encoding errors fixed
* Fixes by @bransh / @br4nsh. Now everything seems to be working
2018-01-20 16:50:12 -03:00
Matan Hart f37454710f Few changes to create accurate service ticket
Changed some flags to suit service tickets (inspired by mimikatz).
2017-11-30 19:21:31 +02:00
Matan Hart 2dfca05889 Implemented silver ticket creation in ticketer.py
Added few changes I forgot to put from the initial commit
2017-11-29 15:41:00 +02:00
Matan Hart 3a2dc9cd40 Implemented silver ticket creation in ticketer.py
Noticed that TGS/Silver Ticket forging in ticketer.py is still in ToDo.
Added optional -spn flag to support service ticket signing.
2017-11-28 15:20:38 +02:00
asolino 3d88b7682a Adding backward compatibility till pyasn-0.2.3 (at least) + supporting 0.4.2 2017-11-23 19:59:30 -03:00
asolino c001138f76 Small changes to make it compatible with pyasn1-0.3.7.
- IMPORTANT: This is not backward compatible with old pyasn1 versions. Be sure you run 0.3.7.
2017-11-23 15:40:18 -03:00
asolino 0cc150e599 Setting some parameters as required
* Since they are required ;)
2017-04-21 12:48:07 -03:00
Martin Gallo 4152e128b8 Replaced shebang with a virtualenv friendly one
Replaced all instances of `#!/usr/bin/python` with `#!/usr/bin/env python` so impacket's examples and scripts can be run inside a virtualenv without having to call python.
2017-01-11 12:43:54 -03:00
asolino c049506e43 Minor cosmetic changes 2016-09-13 23:54:50 -03:00