ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.
Python active-directorycloud-securitydefensive-validationfastapigood-first-issuemitre-attackopsecreactred-teamreportingsecurity
fix(credential): remove unused pyasn1 imports from golden_ticket and mock ticketer in cwd test
Mafifrizi696611b21a72
diff --git a/ares/modules/credential/golden_ticket.py b/ares/modules/credential/golden_ticket.pyindex 36c30f4..4cf03c0 100644--- a/ares/modules/credential/golden_ticket.py+++ b/ares/modules/credential/golden_ticket.py@@ -339,37 +339,9 @@ class GoldenTicketModule(BaseModule[GoldenTicketParams, ModuleResult]):Uses impacket.krb5.ticket + CCache to build a valid TGT from the krbtgt hash."""try:- from impacket.krb5.asn1 import AS_REP, EncTicketPart, TGS_REP- from impacket.krb5.ccache import CCache- from impacket.krb5.crypto import Key, _enctype_table- from impacket.krb5.constants import (- EncryptionTypes, PrincipalNameType, ApplicationTagNumbers- )- from impacket.krb5.types import Principal, KerberosTime- from impacket.krb5 import constants- from pyasn1.codec.ber import decoder, encoder- from pyasn1.type.univ import noValue- import datetime, struct, os as _os+ import os as _osdomain_upper = domain.upper()- nt_hash = bytes.fromhex(nt_part)-- # Use impacket.krb5.kerberosv5 ticketer equivalent- # Build ticket using impacket's built-in ticketer module- # This is the stable library approach used in modern impacket- from impacket.krb5.kerberosv5 import getKerberosTGT- from impacket.krb5.types import Principal-- user_principal = Principal(- username,- type=constants.PrincipalNameType.NT_PRINCIPAL.value,- )-- # Build a valid Golden Ticket via impacket's Ticketer class- # which is the internal library used by ticketer.py- from impacket.krb5.pac import PACTYPE, PAC_INFO_BUFFER, PAC_CREDENTIAL_DATA- from impacket.krb5 import crypto as krb5crypto- import tempfile# Use the TICKETER approach from impacket.examples.ticketer# but call the internal class directly (not via subprocess)diff --git a/tests/unit/modules/test_safety_remediation.py b/tests/unit/modules/test_safety_remediation.pyindex 5e2d85a..28da6db 100644--- a/tests/unit/modules/test_safety_remediation.py+++ b/tests/unit/modules/test_safety_remediation.py@@ -137,8 +137,26 @@ def test_golden_ticket_does_not_mutate_process_cwd():mod.before_request = AsyncMock()mod.noise.jitter.sleep = AsyncMock()+ mock_ticketer_cls = MagicMock()+ mock_instance = MagicMock()+ mock_ticketer_cls.return_value = mock_instance++ def fake_run():+ opts = mock_ticketer_cls.call_args[1]["options"]+ with open(opts.filename, "wb") as f:+ f.write(b"ccache_data")++ mock_instance.run = fake_run+cwd_before = os.getcwd()- with patch("os.chdir") as mock_chdir:+ with patch("os.chdir") as mock_chdir, patch.dict(+ "sys.modules",+ {+ "impacket": MagicMock(),+ "impacket.examples": MagicMock(),+ "impacket.examples.ticketer": MagicMock(TICKETER=mock_ticketer_cls),+ },+ ):# Run golden ticket forgeasyncio.run(mod.run(domain="corp.local",