Commit Graph

40 Commits

Author SHA1 Message Date
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
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
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
Chris Thompson 43fe4ce7cb Add TDS 8.0 (Force Strict Encryption MSSQL Server setting) support to ntlmrelayx (#2122)
* Add support for TDS 8.0 when Force Strict Encryption = Yes

* Match log syntax

* Only use TDS 8.0 if Force Strict Encryption is set to Yes

* Add comments back and fix typos

* Use short timeout, remove excessive debug logs, add comments

* Testing changes to make TDS more broadly applicable by moving to tds.py

* Add TLS 1.2 cap and EPA channel binding for TDS 8.0

* Fix TDS 8.0 DONE parsing and TLS state handling

* Use negotiated TDS version for DONE rowcount parsing

* Align strict TDS login with modern LOGIN7 flow

* Keep relay TLS socket for strict TDS sessions

* Reassemble relay TDS packets over TLS

* tds: stop advertising UTF-8 support

* tds: fix relay login failure token packing

* mssqlrelay: fix PRELOGIN thread id encoding

* tds: preserve default LOGIN7 version in serializer

* tds: only retry strict fallback on connection close

* ntlmrelayx: support strict MSSQL SOCKS reuse

* Reassemble TDS frames on TLS-backed MSSQL reads

---------

Co-authored-by: Gabi Gonzalez <gabriel.gonzalez@fortra.com>
2026-04-21 09:33:52 -03:00
Gabriel Gonzalez 8c155a5b49 Add comprehensive unit tests for krb5.gssapi token parsing, factory selection, RC4/AES helpers, and wrap/MIC paths (#2138) 2026-03-06 16:53:46 -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
alexisbalbachan 101b62fda3 Structure.py: 'u' format calcUnpackSize fix for higher unicode codepoint values. (#1995)
* Fix calcUnpackSize for unicode format 'u' by searching for the real NULL-NULL terminator
Changed documentation about the 'u' format to clarify that it is UTF16-le

* Precompile regex and keep it cached.

* added test for #1992 , #1788

---------

Co-authored-by: Kali <adrian.manrique@gmail.com>
2025-11-25 12:38:36 -03:00
gabrielg5 c21ad14910 Fixed copyright notice in some tests scripts. 2024-09-02 11:05:17 -03:00
gabrielg5 27e7e7478d Updating copyright banner... 2024-08-28 17:52:57 -03:00
Gabriel Gonzalez 9b4a139405 Updated Copyright to 2023 2023-07-31 11:48:28 -03:00
Gabriel Gonzalez 8799a1a2c4 Update file banners to reflect Fortra ownership 2022-12-14 17:28:23 -03:00
0xdeaddood 7a18ef5c8b About to tag a release 2022-05-04 11:33:16 -03:00
Martin Gallo e868dba5bc DPAPI: Added some simple tests to blob decryption with and without entropy 2022-04-06 13:52:38 -07:00
0xdeaddood 6e288da406 CCache: Fixed unit tests on 2.7 so no errrors are thrown
Co-authored-by: Martin Gallo <mgallo@secureauth.com>
2022-03-10 11:51:47 -03:00
Martin Gallo 1c9624c0ff CCache: Added some unit tests
- Parsing v3 and v4 ccache files to check #1106 (and not support for v1 and v2)
- Parsing creds from kirbi to check #1254
- Checking #1166 parseFile function
2022-02-09 11:10:30 -08:00
Martin Gallo 51b66c71b3 Merge branch 'master' into test-refactor-catchup 2021-07-20 06:57:48 -07: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
Martin Gallo b3a608eb35 Tests: Removed test files PEP8 warnings 2021-07-07 18:26:09 -07:00
Martin Gallo 6bb5ea427b Tests: Continue refactor of test cases (#1112)
Continue refactor some of our test cases structure.

Main changes introduced are:
* Moved testing guide as a separate file and added some of the steps to configure the test environment.
* Leveraging unittest.main to catch command-line args and build the default suite.
* Only running GitHub actions workflow once for our own branches/PRs.
* Remote test config file can be specified via an env var now.
* Moved remote test config to a template and ignored config file.
2021-07-02 12:22:14 -03:00
0xdeaddood 142cacb649 Merge pull request #1074 from franferrax/master
WMI objects minor refactors, fixes, and offline parsing tests
2021-06-29 12:35:13 -03:00
Martin Gallo 658e0ab8e1 Tests: First batch of changes on refactoring test cases (#1102)
Tests: First batch of changes on refactoring test cases

This is the first part of a larger effort to refactor some of our test cases structure.

Main changes introduced are:
- Using pytest as the testing framework to organize and mark test cases.
- Replacing custom bash scripts with test cases discovery.
- Integrating pytest-cov plugin to easier coverage collection and reporting.
- Marking remote test cases to being able to pick those during run.
- Abstracted remote test cases configuration in a base class.
- Consolidating pytest, coverage and tox configuration in a single tox.ini file.
- Removed some Python 2.5 support and replaced custom compat checks with six.
- Replace unittest.TextTestRunner.run by unittest.main (cherry-picked from f5dab5ca76, thanks @franferrax !)
2021-06-25 11:19:52 -03:00
Martin Gallo 11f430437d Tests: PEP8 format on misc tests
Made some PEP8 arrangements on misc unit tests modules
2021-06-18 05:48:10 -07:00
Martin Gallo d659b7898b Tests: Adding coverage on passwords with @
We were missing the case when passwords had one or more '@' characters.
2021-06-18 05:36:34 -07:00
Francisco Ferrari Bihurriet f5dab5ca76 Replace unittest.TextTestRunner.run by unittest.main
In this way, tests return the execution status to the OS shell, making the tox run fail and report failures in GitHub (hopefully)
2021-06-08 02:43:53 -03:00
Martin Gallo a45f331360 Refactored the credentials parsing functions (#1058)
Similar to and on top of #1053, this moves the credentials/account parsing regex to an utils module and reduces duplicated code in example scripts.

The expected credential format is:
`<DOMAIN></USERNAME><:PASSWORD>`

Note that the regular expression used in `exchanger.py` was different (excluded ':' from the hostname) but I didn't found any reason to keep it different from all other scripts.

This PR:
- Moved credentials parsing routine to an utils module.
- Added unit tests for the new function.
- Using the new function across example scripts that accept a credential/account.
2021-04-22 10:02:29 -03:00
Martin Gallo adb230256d Refactored the target parsing functions (#1053)
In reviewing #1051 (and related #347) we found out that there's some ugly duplicated code that's better suited for an utils function.

The expected target format is:
`<DOMAIN></USERNAME><:PASSWORD>@HOSTNAME`

This PR:
- Moved target parsing routine to an utils module.
- Added unit tests for the new function.
- Using the new function across example scripts that accept a target.
2021-04-22 09:11:33 -03:00
asolino b2f5337b55 Calling coverage through python 2018-12-10 10:14:16 -03:00
Colin Hogben 0041cddd97 tests/misc: Make runalltestcases.sh report error if test(s) fail
Fix #539 for this subdirectory only
2018-12-06 21:54:09 +00:00
Colin Hogben 0bdf9bde19 tests/misc: Python2/3 fixes in test_krb5_crypto & test_dcerpc_v5_ndr 2018-12-06 21:09:45 +00:00
Colin Hogben 30f9f93f01 tests: Run misc tests instead of __main__ in related modules 2018-12-06 20:16:48 +00:00
Colin Hogben 50d5826c7e tests: Add misc/test_dcerpc_v5_ndr 2018-12-06 20:16:48 +00:00
Colin Hogben 45427f72dd tests: Add misc/test_dns 2018-12-06 20:16:48 +00:00
Colin Hogben 2258b10f4f tests: Add misc/test_ip6_address 2018-12-06 20:16:48 +00:00
Colin Hogben f09b9a69be tests: Add misc/test_krb5_crypto 2018-12-06 20:16:48 +00:00
Colin Hogben b4ba401c90 tests: Add misc/test_structure 2018-12-06 20:16:48 +00:00
Colin Hogben 579138ff3f tests: Add misc/test_crypto 2018-12-06 20:16:48 +00: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 b75d710e56 Adding DPAPI / Vaults related structures, testcase and example.
You can unlock masterkeys, credentials and vaults. For the three, you will specify the file name (using -file for
masterkeys and credentials, and -vpol and -vcrd for vaults).
If no other parameter is sent, the contents of these resource will be shown, with their encrypted data as well.
If you specify a -key blob (in the form of '0xabcdef...') that key will be used to decrypt the contents.
In the case of vaults, you might need to also provide the user's sid (and the user password will be asked).
For system secrets, instead of a password you will need to specify the system and security hives.

References: All of the work done by these guys. I just adapted their work to my needs.
https://www.passcape.com/index.php?section=docsys&cmd=details&id=28
https://github.com/jordanbtucker/dpapick
https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials (and everything else Ben did )
http://blog.digital-forensics.it/2016/01/windows-revaulting.html
https://www.passcape.com/windows_password_recovery_vault_explorer
https://www.passcape.com/windows_password_recovery_dpapi_master_key
2018-11-08 12:25:30 -03:00