From 3f047b987e46dccd76146bd6dfcd4b542444a5ff Mon Sep 17 00:00:00 2001 From: Samirbous <64742097+Samirbous@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:36:28 +0200 Subject: [PATCH] [New Rule] Service Creation via Local Kerberos Authentication (#1941) * [New Rule] Suspicious Service Creation via Local Kerberos Relay over LDAP This rule will catch also the suspicious service that was created leveraging the imported kerberos ticket https://gist.github.com/tyranid/c24cfd1bd141d14d4925043ee7e03c82 which makes triage easier : DATA : ``` "sequences" : [ { "join_keys" : [ "6a3c3ef2-208f-4d6f-90ee-b34f4e3fd160", "0xefac5f" ], "events" : [ { "_index" : ".ds-logs-system.security-default-2022.04.12-000003", "_id" : "XAy1YoABQhClK0XGpqaL", "_source" : { "agent" : { "name" : "02694w-win10", "id" : "77a829ec-a564-44d5-9bc4-61eeefbf783a", "type" : "filebeat", "ephemeral_id" : "6c751494-97a3-46aa-bab2-5baf01d17d04", "version" : "8.0.0" }, "process" : { "name" : "-", "pid" : 0, "executable" : "-" }, "winlog" : { "computer_name" : "02694w-win10.threebeesco.com", "process" : { "pid" : 688, "thread" : { "id" : 5160 } }, "keywords" : [ "Audit Success" ], "logon" : { "id" : "0x0", "type" : "Network" }, "channel" : "Security", "event_data" : { "LogonGuid" : "{82d3503b-9dac-ab6d-b045-8877b5aab051}", "TargetOutboundDomainName" : "-", "VirtualAccount" : "%%1843", "LogonType" : "3", "TransmittedServices" : "-", "SubjectLogonId" : "0x0", "LmPackageName" : "-", "TargetOutboundUserName" : "-", "KeyLength" : "0", "RestrictedAdminMode" : "-", "TargetLogonId" : "0xefac5f", "SubjectUserName" : "-", "TargetLinkedLogonId" : "0x0", "ElevatedToken" : "%%1842", "SubjectDomainName" : "-", "ImpersonationLevel" : "%%1833", "TargetUserName" : "Administrator", "TargetDomainName" : "THREEBEESCO.COM", "LogonProcessName" : "Kerberos", "SubjectUserSid" : "S-1-0-0", "TargetUserSid" : "S-1-5-21-308926384-506822093-3341789130-500", "AuthenticationPackageName" : "Kerberos" }, "opcode" : "Info", "version" : 2, "record_id" : "59330", "task" : "Logon", "event_id" : "4624", "provider_guid" : "{54849625-5478-4994-a5ba-3e3b0328c30d}", "activity_id" : "{e22af019-58dd-0002-43f0-2ae2dd58d801}", "api" : "wineventlog", "provider_name" : "Microsoft-Windows-Security-Auditing" }, "log" : { "level" : "information" }, "elastic_agent" : { "id" : "77a829ec-a564-44d5-9bc4-61eeefbf783a", "version" : "8.0.0", "snapshot" : false }, "source" : { "port" : 50494, "ip" : "127.0.0.1", "domain" : "-" }, "message" : """An account was successfully logged on. Subject: Security ID: S-1-0-0 Account Name: - Account Domain: - Logon ID: 0x0 Logon Information: Logon Type: 3 Restricted Admin Mode: - Virtual Account: No Elevated Token: Yes Impersonation Level: Impersonation New Logon: Security ID: S-1-5-21-308926384-506822093-3341789130-500 Account Name: Administrator Account Domain: THREEBEESCO.COM Logon ID: 0xEFAC5F Linked Logon ID: 0x0 Network Account Name: - Network Account Domain: - Logon GUID: {82d3503b-9dac-ab6d-b045-8877b5aab051} Process Information: Process ID: 0x0 Process Name: - Network Information: Workstation Name: - Source Network Address: 127.0.0.1 Source Port: 50494 Detailed Authentication Information: Logon Process: Kerberos Authentication Package: Kerberos Transited Services: - Package Name (NTLM only): - Key Length: 0 This event is generated when a logon session is created. It is generated on the computer that was accessed. The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe. The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network). The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on. The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases. The impersonation level field indicates the extent to which a process in the logon session can impersonate. The authentication information fields provide detailed information about this specific logon request. - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event. - Transited services indicate which intermediate services have participated in this logon request. - Package name indicates which sub-protocol was used among the NTLM protocols. - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.""", "input" : { "type" : "winlog" }, "@timestamp" : "2022-04-25T21:09:04.559Z", "ecs" : { "version" : "1.12.0" }, "related" : { "ip" : [ "127.0.0.1" ], "user" : [ "Administrator" ] }, "data_stream" : { "namespace" : "default", "type" : "logs", "dataset" : "system.security" }, "host" : { "hostname" : "02694w-win10", "os" : { "build" : "18363.815", "kernel" : "10.0.18362.815 (WinBuild.160101.0800)", "name" : "Windows 10 Enterprise", "family" : "windows", "type" : "windows", "version" : "10.0", "platform" : "windows" }, "ip" : [ "fe80::7587:a5c1:5a7b:68f6", "172.16.66.25" ], "name" : "02694w-win10.threebeesco.com", "id" : "6a3c3ef2-208f-4d6f-90ee-b34f4e3fd160", "mac" : [ "00:50:56:03:c6:93" ], "architecture" : "x86_64" }, "event" : { "agent_id_status" : "verified", "ingested" : "2022-04-25T21:51:53Z", "code" : "4624", "provider" : "Microsoft-Windows-Security-Auditing", "kind" : "event", "created" : "2022-04-25T21:51:15.561Z", "action" : "logged-in", "category" : [ "authentication" ], "type" : [ "start" ], "dataset" : "system.security", "outcome" : "success" }, "user" : { "domain" : "THREEBEESCO.COM", "name" : "Administrator", "id" : "S-1-5-21-308926384-506822093-3341789130-500" } } }, { "_index" : ".ds-logs-system.security-default-2022.04.12-000003", "_id" : "Xwy1YoABQhClK0XGpqaL", "_source" : { "agent" : { "name" : "02694w-win10", "id" : "77a829ec-a564-44d5-9bc4-61eeefbf783a", "ephemeral_id" : "6c751494-97a3-46aa-bab2-5baf01d17d04", "type" : "filebeat", "version" : "8.0.0" }, "winlog" : { "computer_name" : "02694w-win10.threebeesco.com", "process" : { "pid" : 688, "thread" : { "id" : 5160 } }, "keywords" : [ "Audit Success" ], "logon" : { "id" : "0xefac5f" }, "channel" : "Security", "event_data" : { "ServiceAccount" : "LocalSystem", "SubjectUserName" : "Administrator", "ServiceStartType" : "3", "ServiceName" : "KrbSCM", "ServiceType" : "0x10", "SubjectDomainName" : "3B", "SubjectLogonId" : "0xefac5f", "SubjectUserSid" : "S-1-5-21-308926384-506822093-3341789130-500", "ServiceFileName" : "\"C:\\Users\\lgreen\\Downloads\\KrbRelayUp.exe\" system 1" }, "opcode" : "Info", "record_id" : "59331", "task" : "Security System Extension", "event_id" : "4697", "provider_guid" : "{54849625-5478-4994-a5ba-3e3b0328c30d}", "activity_id" : "{e22af019-58dd-0002-43f0-2ae2dd58d801}", "api" : "wineventlog", "provider_name" : "Microsoft-Windows-Security-Auditing" }, "log" : { "level" : "information" }, "elastic_agent" : { "id" : "77a829ec-a564-44d5-9bc4-61eeefbf783a", "version" : "8.0.0", "snapshot" : false }, "message" : """A service was installed in the system. Subject: Security ID: S-1-5-21-308926384-506822093-3341789130-500 Account Name: Administrator Account Domain: 3B Logon ID: 0xEFAC5F Service Information: Service Name: KrbSCM Service File Name: "C:\Users\lgreen\Downloads\KrbRelayUp.exe" system 1 Service Type: 0x10 Service Start Type: 3 Service Account: LocalSystem""", "input" : { "type" : "winlog" }, "@timestamp" : "2022-04-25T21:09:04.561Z", "ecs" : { "version" : "1.12.0" }, "related" : { "user" : [ "Administrator" ] }, "data_stream" : { "namespace" : "default", "type" : "logs", "dataset" : "system.security" }, "service" : { "name" : "KrbSCM", "type" : "Win32 Own Process" }, "host" : { "hostname" : "02694w-win10", "os" : { "build" : "18363.815", "kernel" : "10.0.18362.815 (WinBuild.160101.0800)", "name" : "Windows 10 Enterprise", "family" : "windows", "type" : "windows", "version" : "10.0", "platform" : "windows" }, "ip" : [ "fe80::7587:a5c1:5a7b:68f6", "172.16.66.25" ], "name" : "02694w-win10.threebeesco.com", "id" : "6a3c3ef2-208f-4d6f-90ee-b34f4e3fd160", "mac" : [ "00:50:56:03:c6:93" ], "architecture" : "x86_64" }, "event" : { "agent_id_status" : "verified", "ingested" : "2022-04-25T21:51:53Z", "code" : "4697", "provider" : "Microsoft-Windows-Security-Auditing", "created" : "2022-04-25T21:51:15.561Z", "kind" : "event", "action" : "service-installed", "category" : [ "iam", "configuration" ], "type" : [ "admin", "change" ], "dataset" : "system.security", "outcome" : "success" }, "user" : { "domain" : "3B", "name" : "Administrator", "id" : "S-1-5-21-308926384-506822093-3341789130-500" } } } ] ```` * Update privilege_escalation_krbrelayup_service_creation.toml * removed duplicate SubjectLogonId from non ecs fields list --- ...scalation_krbrelayup_service_creation.toml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 rules/windows/privilege_escalation_krbrelayup_service_creation.toml diff --git a/rules/windows/privilege_escalation_krbrelayup_service_creation.toml b/rules/windows/privilege_escalation_krbrelayup_service_creation.toml new file mode 100644 index 000000000..b2fbedc4d --- /dev/null +++ b/rules/windows/privilege_escalation_krbrelayup_service_creation.toml @@ -0,0 +1,76 @@ +[metadata] +creation_date = "2022/04/27" +maturity = "production" +updated_date = "2022/04/27" + +[rule] +author = ["Elastic"] +description = """ +Identifies a suspicious local successful logon event where the Logon Package is Kerberos, the remote address is set to +localhost, followed by a sevice creation from the same LogonId. This may indicate an attempt to leverage a Kerberos +relay attack variant that can be used to elevate privilege locally from a domain joined user to local System privileges. +""" +from = "now-9m" +index = ["winlogbeat-*", "logs-system.*"] +language = "eql" +license = "Elastic License v2" +name = "Service Creation via Local Kerberos Authentication" +references = [ + "https://github.com/Dec0ne/KrbRelayUp", + "https://googleprojectzero.blogspot.com/2021/10/using-kerberos-for-authentication-relay.html", + "https://github.com/cube0x0/KrbRelay", + "https://gist.github.com/tyranid/c24cfd1bd141d14d4925043ee7e03c82", +] +risk_score = 73 +rule_id = "e4e31051-ee01-4307-a6ee-b21b186958f4" +severity = "high" +tags = ["Elastic", "Host", "Windows", "Threat Detection", "Privilege Escalation", "Credential Access"] +type = "eql" + +query = ''' +sequence by host.id with maxspan=5m + [authentication where + + /* event 4624 need to be logged */ + event.action == "logged-in" and event.outcome == "success" and + + /* authenticate locally using relayed kerberos Ticket */ + winlog.event_data.AuthenticationPackageName :"Kerberos" and winlog.logon.type == "Network" and + cidrmatch(source.ip, "127.0.0.0/8", "::1") and source.port > 0] by winlog.event_data.TargetLogonId + + [any where + /* event 4697 need to be logged */ + event.action : "service-installed"] by winlog.event_data.SubjectLogonId +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1543" +name = "Create or Modify System Process" +reference = "https://attack.mitre.org/techniques/T1543/" +[[rule.threat.technique.subtechnique]] +id = "T1543.003" +name = "Windows Service" +reference = "https://attack.mitre.org/techniques/T1543/003/" + + + +[rule.threat.tactic] +id = "TA0004" +name = "Privilege Escalation" +reference = "https://attack.mitre.org/tactics/TA0004/" +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1558" +name = "Steal or Forge Kerberos Tickets" +reference = "https://attack.mitre.org/techniques/T1558/" + + +[rule.threat.tactic] +id = "TA0006" +name = "Credential Access" +reference = "https://attack.mitre.org/tactics/TA0006/" +