diff --git a/bin/ssa-end-to-end-testing/modules/data/windows-security_debug.txt b/bin/ssa-end-to-end-testing/modules/data/windows-security_debug.txt new file mode 100644 index 0000000000..4b53f32b35 --- /dev/null +++ b/bin/ssa-end-to-end-testing/modules/data/windows-security_debug.txt @@ -0,0 +1,123 @@ +11/24/2021 02:28:14 AM +LogName=Security +SourceName=Microsoft Windows security auditing. +EventCode=4688 +EventType=0 +Type=Information +ComputerName=win-dc-725.attackrange.local +TaskCategory=Process Creation +OpCode=Info +RecordNumber=257876 +Keywords=Audit Success +Message=A new process has been created. + +Creator Subject: + Security ID: ATTACKRANGE\Administrator + Account Name: Administrator + Account Domain: ATTACKRANGE + Logon ID: 0x55E621 + +Target Subject: + Security ID: NULL SID + Account Name: - + Account Domain: - + Logon ID: 0x0 + +Process Information: + New Process ID: 0xca4 + New Process Name: C:\Windows\System32\cmd.exe + Token Elevation Type: %%1936 + Mandatory Label: Mandatory Label\High Mandatory Level + Creator Process ID: 0x13a4 + Creator Process Name: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe + Process Command Line: "C:\Windows\system32\cmd.exe" /c "pypykatz live registry" + +Token Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy. + +Type 1 is a full token with no privileges removed or groups disabled. A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account. + +Type 2 is an elevated token with no privileges removed or groups disabled. An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator. An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group. + +Type 3 is a limited token with administrative privileges removed and administrative groups disabled. The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator. +11/24/2021 02:28:15 AM +LogName=Security +SourceName=Microsoft Windows security auditing. +EventCode=4688 +EventType=0 +Type=Information +ComputerName=win-dc-725.attackrange.local +TaskCategory=Process Creation +OpCode=Info +RecordNumber=257875 +Keywords=Audit Success +Message=A new process has been created. + +Creator Subject: + Security ID: ATTACKRANGE\Administrator + Account Name: Administrator + Account Domain: ATTACKRANGE + Logon ID: 0x55E621 + +Target Subject: + Security ID: NULL SID + Account Name: - + Account Domain: - + Logon ID: 0x0 + +Process Information: + New Process ID: 0x62c + New Process Name: C:\Windows\System32\reg.exe + Token Elevation Type: %%1936 + Mandatory Label: Mandatory Label\High Mandatory Level + Creator Process ID: 0xf6c + Creator Process Name: C:\Windows\System32\cmd.exe + Process Command Line: reg save HKLM\security C:\Users\ADMINI~1\AppData\Local\Temp\security + +Token Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy. + +Type 1 is a full token with no privileges removed or groups disabled. A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account. + +Type 2 is an elevated token with no privileges removed or groups disabled. An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator. An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group. + +Type 3 is a limited token with administrative privileges removed and administrative groups disabled. The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator. +11/24/2021 02:28:16 AM +LogName=Security +SourceName=Microsoft Windows security auditing. +EventCode=4688 +EventType=0 +Type=Information +ComputerName=win-dc-725.attackrange.local +TaskCategory=Process Creation +OpCode=Info +RecordNumber=257874 +Keywords=Audit Success +Message=A new process has been created. + +Creator Subject: + Security ID: ATTACKRANGE\Administrator + Account Name: Administrator + Account Domain: ATTACKRANGE + Logon ID: 0x55E621 + +Target Subject: + Security ID: NULL SID + Account Name: - + Account Domain: - + Logon ID: 0x0 + +Process Information: + New Process ID: 0x1258 + New Process Name: C:\Windows\System32\reg.exe + Token Elevation Type: %%1936 + Mandatory Label: Mandatory Label\High Mandatory Level + Creator Process ID: 0xf6c + Creator Process Name: C:\Windows\System32\cmd.exe + Process Command Line: reg save HKLM\system C:\Users\ADMINI~1\AppData\Local\Temp\system + +Token Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy. + +Type 1 is a full token with no privileges removed or groups disabled. A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account. + +Type 2 is an elevated token with no privileges removed or groups disabled. An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator. An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group. + +Type 3 is a limited token with administrative privileges removed and administrative groups disabled. The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator. diff --git a/bin/ssa-end-to-end-testing/modules/data_manipulation.py b/bin/ssa-end-to-end-testing/modules/data_manipulation.py index 06e62bf159..5f08f1a0c1 100644 --- a/bin/ssa-end-to-end-testing/modules/data_manipulation.py +++ b/bin/ssa-end-to-end-testing/modules/data_manipulation.py @@ -6,7 +6,12 @@ import fileinput import os import re import io +import logging + +# Logger +logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) +LOGGER = logging.getLogger(__name__) class DataManipulation: def manipulate_timestamp(self, file_path, sourcetype, source): @@ -50,4 +55,5 @@ class DataManipulation: new_time = self.difference + event_time return new_time.strftime("%m/%d/%Y %I:%M:%S %p") except Exception as e: + LOGGER.error("Error in timestamp replacement occured: " + str(e)) return match.group() diff --git a/bin/ssa-end-to-end-testing/modules/test_ssa_detections.py b/bin/ssa-end-to-end-testing/modules/test_ssa_detections.py index 1c7d8992e3..1c21291c7a 100644 --- a/bin/ssa-end-to-end-testing/modules/test_ssa_detections.py +++ b/bin/ssa-end-to-end-testing/modules/test_ssa_detections.py @@ -20,7 +20,7 @@ SLEEP_TIME_SEND_DATA = 30 WAIT_CYCLE = 20 MAX_EXECUTION_TIME_LIMIT = 600 # per detection test -TEST_DATASET = 'windows-security_small.txt' +TEST_DATASET = 'windows-security_debug.txt' class SSADetectionTesting: diff --git a/bin/ssa-end-to-end-testing/modules/utils.py b/bin/ssa-end-to-end-testing/modules/utils.py index 14111281e8..8e9d21ad6d 100644 --- a/bin/ssa-end-to-end-testing/modules/utils.py +++ b/bin/ssa-end-to-end-testing/modules/utils.py @@ -108,23 +108,27 @@ def read_data(file_path): data_manipulation = DataManipulation() modified_file = data_manipulation.manipulate_timestamp(file_path, 'xmlwineventlog', 'WinEventLog:Security') data = [] - event = "" date_rex = r'\d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2} [AP]M' count = len(open(modified_file).readlines()) + i = 0 - tmp_counter = 0 - for line in fileinput.input(files=modified_file): + file = fileinput.input(files=modified_file) + event = file[0] + start_position = 0 + + for i in range(1, count): + line = file[i] i = i + 1 - if event.strip() != "" and re.match(date_rex, line): + if re.match(date_rex, line): data.append(event) - tmp_counter = 0 + start_position = i event = line else: - tmp_counter = tmp_counter + 1 event = event + line - if i == count and tmp_counter > 10: - data.append(event) + + data.append(event) + fileinput.close() return data diff --git a/bin/ssa-end-to-end-testing/run_ssa_smoketest.py b/bin/ssa-end-to-end-testing/run_ssa_smoketest.py index 396b4d8ea6..14cc9f2e97 100644 --- a/bin/ssa-end-to-end-testing/run_ssa_smoketest.py +++ b/bin/ssa-end-to-end-testing/run_ssa_smoketest.py @@ -67,11 +67,11 @@ def main(args): ssa_detection_testing = SSADetectionTesting(env, tenant, token) if not fast: test_result_passed = ssa_detection_testing.test_dsp_pipeline() + # disabled for debugging + # if not test_result_passed: + # sys.exit(1) - if not test_result_passed: - sys.exit(1) - - # # test SSA detections + # test SSA detections test_results = [] test_passed = True for test_file in test_files_ssa: diff --git a/detections/endpoint/ssa___applying_stolen_credentials_via_mimikatz_modules.yml b/detections/endpoint/ssa___applying_stolen_credentials_via_mimikatz_modules.yml index 83940d73f0..4beb8f3c3b 100644 --- a/detections/endpoint/ssa___applying_stolen_credentials_via_mimikatz_modules.yml +++ b/detections/endpoint/ssa___applying_stolen_credentials_via_mimikatz_modules.yml @@ -83,3 +83,4 @@ tags: risk_score: 90 risk_severity: high security_domain: endpoint + diff --git a/detections/endpoint/ssa___attempted_credential_dump_from_registry_via_reg_exe.yml b/detections/endpoint/ssa___attempted_credential_dump_from_registry_via_reg_exe.yml index 12fa8c3a98..d9a68ecbaf 100644 --- a/detections/endpoint/ssa___attempted_credential_dump_from_registry_via_reg_exe.yml +++ b/detections/endpoint/ssa___attempted_credential_dump_from_registry_via_reg_exe.yml @@ -66,3 +66,4 @@ tags: risk_score: 63 risk_severity: low security_domain: endpoint + diff --git a/detections/endpoint/ssa___sdelete_application_execution.yml b/detections/endpoint/ssa___sdelete_application_execution.yml index d86c3b6f60..032a4ca12f 100644 --- a/detections/endpoint/ssa___sdelete_application_execution.yml +++ b/detections/endpoint/ssa___sdelete_application_execution.yml @@ -83,4 +83,5 @@ tags: type: Process role: - Child Process + \ No newline at end of file diff --git a/detections/endpoint/ssa___wevtutil_usage_to_disable_logs.yml b/detections/endpoint/ssa___wevtutil_usage_to_disable_logs.yml index cd77f947a9..17b950bb38 100644 --- a/detections/endpoint/ssa___wevtutil_usage_to_disable_logs.yml +++ b/detections/endpoint/ssa___wevtutil_usage_to_disable_logs.yml @@ -75,3 +75,4 @@ tags: risk_score: 63 risk_severity: high security_domain: endpoint +