import "pe" import "math" rule Mimikatz_Memory_Rule_1 { meta: description = "Detect the risk of Malware Mimikatz Rule 1" strings: $s1 = "sekurlsa::msv" fullword ascii $s2 = "sekurlsa::wdigest" fullword ascii $s4 = "sekurlsa::kerberos" fullword ascii $s5 = "sekurlsa::tspkg" fullword ascii $s6 = "sekurlsa::livessp" fullword ascii $s7 = "sekurlsa::ssp" fullword ascii $s8 = "sekurlsa::logonPasswords" fullword ascii $s9 = "sekurlsa::process" fullword ascii $s10 = "ekurlsa::minidump" fullword ascii $s11 = "sekurlsa::pth" fullword ascii $s12 = "sekurlsa::tickets" fullword ascii $s13 = "sekurlsa::ekeys" fullword ascii $s14 = "sekurlsa::dpapi" fullword ascii $s15 = "sekurlsa::credman" fullword ascii condition: 1 of them } rule Mimikatz_Memory_Rule_2 { meta: description = "Detect the risk of Malware Mimikatz Rule 2" strings: $s0 = "sekurlsa::" ascii $x1 = "cryptprimitives.pdb" ascii $x2 = "Now is t1O" ascii fullword $x4 = "ALICE123" ascii $x5 = "BOBBY456" ascii condition: $s0 and 2 of ($x*) } rule mimikatz { meta: description = "Detect the risk of Malware Mimikatz Rule 3" strings: $exe_x86_1 = { 89 71 04 89 [0-3] 30 8d 04 bd } $exe_x86_2 = { 8b 4d e? 8b 45 f4 89 75 e? 89 01 85 ff 74 } $exe_x64_1 = { 33 ff 4? 89 37 4? 8b f3 45 85 c? 74} $exe_x64_2 = { 4c 8b df 49 [0-3] c1 e3 04 48 [0-3] 8b cb 4c 03 [0-3] d8 } $sys_x86 = { a0 00 00 00 24 02 00 00 40 00 00 00 [0-4] b8 00 00 00 6c 02 00 00 40 00 00 00 } $sys_x64 = { 88 01 00 00 3c 04 00 00 40 00 00 00 [0-4] e8 02 00 00 f8 02 00 00 40 00 00 00 } condition: (all of ($exe_x86_*)) or (all of ($exe_x64_*)) or (any of ($sys_*)) } rule wce { meta: description = "Detect the risk of Malware Mimikatz Rule 4" strings: $hex_legacy = { 8b ff 55 8b ec 6a 00 ff 75 0c ff 75 08 e8 [0-3] 5d c2 08 00 } $hex_x86 = { 8d 45 f0 50 8d 45 f8 50 8d 45 e8 50 6a 00 8d 45 fc 50 [0-8] 50 72 69 6d 61 72 79 00 } $hex_x64 = { ff f3 48 83 ec 30 48 8b d9 48 8d 15 [0-16] 50 72 69 6d 61 72 79 00 } condition: any of them } rule power_pe_injection { meta: description = "Detect the risk of Malware Mimikatz Rule 5" strings: $str_loadlib = "0x53, 0x48, 0x89, 0xe3, 0x48, 0x83, 0xec, 0x20, 0x66, 0x83, 0xe4, 0xc0, 0x48, 0xb9" condition: $str_loadlib } rule Mimikatz_Logfile { meta: description = "Detect the risk of Malware Mimikatz Rule 6" strings: $s1 = "SID :" ascii fullword $s2 = "* NTLM :" ascii fullword $s3 = "Authentication Id :" ascii fullword $s4 = "wdigest :" ascii fullword condition: all of them } rule Mimikatz_Strings { meta: description = "Detect the risk of Malware Mimikatz Rule 7" strings: $x1 = "sekurlsa::logonpasswords" fullword wide ascii $x2 = "List tickets in MIT/Heimdall ccache" fullword ascii wide $x3 = "kuhl_m_kerberos_ptt_file ; LsaCallKerberosPackage %08x" fullword ascii wide $x4 = "* Injecting ticket :" fullword wide ascii $x5 = "mimidrv.sys" fullword wide ascii $x6 = "Lists LM & NTLM credentials" fullword wide ascii $x7 = "\\_ kerberos -" fullword wide ascii $x8 = "* unknow :" fullword wide ascii $x9 = "\\_ *Password replace ->" fullword wide ascii $x10 = "KIWI_MSV1_0_PRIMARY_CREDENTIALS KO" ascii wide $x11 = "\\\\.\\mimidrv" wide ascii $x12 = "Switch to MINIDUMP :" fullword wide ascii $x13 = "[masterkey] with password: %s (%s user)" fullword wide $x14 = "Clear screen (doesn't work with redirections, like PsExec)" fullword wide $x15 = "** Session key is NULL! It means allowtgtsessionkey is not set to 1 **" fullword wide $x16 = "[masterkey] with DPAPI_SYSTEM (machine, then user): " fullword wide condition: ( ( uint16(0) == 0x5a4d and 1 of ($x*) ) or ( 3 of them ) ) and not pe.imphash() == "77eaeca738dd89410a432c6bd6459907" } rule AppInitHook { meta: description = "Detect the risk of Malware Mimikatz Rule 8" strings: $s0 = "\\Release\\AppInitHook.pdb" ascii $s1 = "AppInitHook.dll" fullword ascii $s2 = "mimikatz.exe" fullword wide $s3 = "]X86Instruction->OperandSize >= Operand->Length" fullword wide $s4 = "mhook\\disasm-lib\\disasm.c" fullword wide $s5 = "mhook\\disasm-lib\\disasm_x86.c" fullword wide $s6 = "VoidFunc" fullword ascii condition: uint16(0) == 0x5a4d and filesize < 500KB and 4 of them } rule HKTL_Mimikatz_SkeletonKey_in_memory_Aug20_1 { meta: description = "Detect the risk of Malware Mimikatz Rule 9" strings: $x1 = { 60 ba 4f ca c7 44 24 34 dc 46 6c 7a c7 44 24 38 03 3c 17 81 c7 44 24 3c 94 c0 3d f6 } condition: 1 of them } rule HKTL_mimikatz_memssp_hookfn { meta: description = "Detect the risk of Malware Mimikatz Rule 10" strings: $xc1 = { 48 81 EC A8 00 00 00 C7 84 24 88 00 00 00 ?? ?? ?? ?? C7 84 24 8C 00 00 00 ?? ?? ?? ?? C7 84 24 90 00 00 00 ?? ?? ?? 00 C7 84 24 80 00 00 00 61 00 00 00 C7 44 24 40 5B 00 25 00 C7 44 24 44 30 00 38 00 C7 44 24 48 78 00 3A 00 C7 44 24 4C 25 00 30 00 C7 44 24 50 38 00 78 00 C7 44 24 54 5D 00 20 00 C7 44 24 58 25 00 77 00 C7 44 24 5C 5A 00 5C 00 C7 44 24 60 25 00 77 00 C7 44 24 64 5A 00 09 00 C7 44 24 68 25 00 77 00 C7 44 24 6C 5A 00 0A 00 C7 44 24 70 00 00 00 00 48 8D 94 24 80 00 00 00 48 8D 8C 24 88 00 00 00 48 B8 A0 7D ?? ?? ?? ?? 00 00 FF D0 } condition: $xc1 } rule mimikatz_lsass_mdmp_file { meta: description = "Detect the risk of Malware Mimikatz Rule 11" strings: $lsass = "System32\\lsass.exe" wide nocase condition: (uint32(0) == 0x504d444d) and $lsass } rule mimikatz_kirbi_ticket { meta: description = "Detect the risk of Malware Mimikatz Rule 12" strings: $asn1 = { 76 82 ?? ?? 30 82 ?? ?? a0 03 02 01 05 a1 03 02 01 16 } condition: $asn1 at 0 } rule lsadump { meta: description = "Detect the risk of Malware Mimikatz Rule 13" remarks = "LSA dump programe (bootkey/syskey) - pwdump and others" strings: $str_sam_inc = "\\Domains\\Account" ascii nocase $str_sam_exc = "\\Domains\\Account\\Users\\Names\\" ascii nocase $hex_api_call = {(41 b8 | 68) 00 00 00 02 [0-64] (68 | ba) ff 07 0f 00 } $str_msv_lsa = { 4c 53 41 53 52 56 2e 44 4c 4c 00 [0-32] 6d 73 76 31 5f 30 2e 64 6c 6c 00 } $hex_bkey = { 4b 53 53 4d [20-70] 05 00 01 00} condition: ($str_sam_inc and not $str_sam_exc) or $hex_api_call or $str_msv_lsa or $hex_bkey } rule mimilove { meta: description = "Detect the risk of Malware Mimikatz Rule 14" strings: $s1 = "$http://blog.gentilkiwi.com/mimikatz 0" fullword ascii $s2 = "mimilove.exe" fullword wide $s3 = " '## v ##' https://blog.gentilkiwi.com/mimikatz (oe.eo)" fullword wide $s4 = "ERROR wmain ; OpenProcess (0x%08x)" fullword wide $s5 = "ERROR mimilove_lsasrv ; kull_m_memory_copy / KIWI_MSV1_0_LOGON_SESSION_TABLE_50 (0x%08x)" fullword wide $s6 = "ERROR mimilove_lsasrv ; LogonSessionTable is NULL" fullword wide $s7 = "ERROR mimilove_kerberos ; kull_m_memory_copy / KERB_HASHPASSWORD_5 (0x%08x)" fullword wide $s8 = "ERROR mimilove_kerberos ; kull_m_memory_copy / KIWI_KERBEROS_LOGON_SESSION_50 (0x%08x)" fullword wide $s9 = "ERROR mimilove_kerberos ; KerbLogonSessionList is NULL" fullword wide $s10 = "ERROR mimilove_kerberos ; kull_m_memory_copy / KIWI_KERBEROS_KEYS_LIST_5 (0x%08x)" fullword wide $s11 = "ERROR kull_m_kernel_ioctl_handle ; DeviceIoControl (0x%08x) : 0x%08x" fullword wide $s12 = "UndefinedLogonType" fullword wide $s13 = "ERROR wmain ; GetVersionEx (0x%08x)" fullword wide $s14 = "ERROR mimilove_lsasrv ; kull_m_memory_copy / KIWI_MSV1_0_PRIMARY_CREDENTIALS (0x%08x)" fullword wide $s15 = "ERROR mimilove_lsasrv ; kull_m_memory_copy / KIWI_MSV1_0_CREDENTIALS (0x%08x)" fullword wide $s16 = "KERBEROS Credentials (no tickets, sorry)" fullword wide $s17 = "Copyright (c) 2007 - 2021 gentilkiwi (Benjamin DELPY)" fullword wide $s18 = "benjamin@gentilkiwi.com0" fullword ascii $s19 = " * Username : %wZ" fullword wide $s20 = "http://subca.ocsp-certum.com01" fullword ascii $op0 = { 89 45 cc 6a 34 8d 45 cc 50 8d 45 c4 8d 4d 80 50 } $op1 = { 89 45 b8 c7 45 bc f7 ff ff ff 89 5d d4 89 5d f4 } $op2 = { 89 45 d4 c7 45 d8 f8 ff ff ff 89 7d f0 89 7d f4 } condition: uint16(0) == 0x5a4d and filesize < 100KB and ( 8 of them and all of ($op*) ) } rule mimi_anti { meta: description = "Detect the risk of Malware Mimikatz Rule 15" strings: $s1 = "curity>true" fullword ascii $s4 = "Copyright (c) 2007 - 2020 bIJ9xgPw5o (eTZHxXXY 52DdH)" fullword wide $s5 = "GcircTRv" fullword ascii $s6 = "acossqrt" fullword ascii $s7 = "baagqqq" fullword ascii $s8 = "nnmdjjj" fullword ascii $s9 = "jklmnop" fullword ascii $s10 = "onoffalsey" fullword ascii $s11 = "NCKeyD`true" fullword ascii $s13 = "mimikatz" fullword wide $s14 = "Copyright (c) 2007 - 2019 gentilkiwi (Benjamin DELPY)" fullword wide $s15 = "mimikatz for Windows" fullword wide $s16 = "U:\"QS6" fullword ascii $s17 = "fjN.TRl" fullword ascii $s18 = "^f:\"Oh" fullword ascii $s19 = "QZ0S.aLe" fullword ascii $s20 = "3%i:^3" fullword ascii condition: uint16(0) == 0x5a4d and filesize < 18000KB and 8 of them } rule mimi_anti2 { meta: description = "Detect the risk of Malware Mimikatz Rule 17" strings: $s1 = "mimikatz.exe" fullword wide $s2 = "curity>true" fullword ascii $s6 = "mimikatz" fullword wide $s7 = "Copyright (c) 2007 - 2019 gentilkiwi (Benjamin DELPY)" fullword wide $s8 = "msncucx" fullword ascii $s9 = "ashcjsm" fullword ascii $s10 = "lsmcpst" fullword ascii $s11 = "iRNG9+ >" fullword ascii $s12 = "mzhn9+ " fullword ascii $s13 = "mimikatz for Windows" fullword wide $s14 = "yDT:\\pE" fullword ascii $s15 = "RiRC 512 and math.entropy(pe.sections[pe.section_index(".data")].raw_data_offset, 512 ) >= 7 } private rule cobaltstrike_beacon_raw { strings: $s1 = "%d is an x64 process (can't inject x86 content)" fullword $s2 = "Failed to impersonate logged on user %d (%u)" fullword $s3 = "powershell -nop -exec bypass -EncodedCommand \"%s\"" fullword $s4 = "IEX (New-Object Net.Webclient).DownloadString('http://127.0.0.1:%u/'); %s" fullword $s5 = "could not run command (w/ token) because of its length of %d bytes!" fullword $s6 = "could not write to process memory: %d" fullword $s7 = "%s.4%08x%08x%08x%08x%08x.%08x%08x%08x%08x%08x%08x%08x.%08x%08x%08x%08x%08x%08x%08x.%08x%08x%08x%08x%08x%08x%08x.%x%x.%s" fullword $s8 = "Could not connect to pipe (%s): %d" fullword $b1 = "beacon.dll" fullword $b2 = "beacon.x86.dll" fullword $b3 = "beacon.x64.dll" fullword condition: uint16(0) == 0x5a4d and filesize < 1000KB and ( any of ($b*) or 5 of ($s*) ) } private rule cobaltstrike_beacon_exe { condition: cobaltstrike_template_exe and filesize > 100KB and filesize < 500KB and pe.sections[pe.section_index(".data")].raw_data_size > 200000 and math.entropy(pe.sections[pe.section_index(".data")].raw_data_offset + 1024, 150000 ) >= 7 } private rule cobaltstrike_beacon_b64 { strings: $s1a = "JWQgaXMgYW4geDY0IHByb2Nlc3MgKGNhbid0IGluam" $s1b = "ZCBpcyBhbiB4NjQgcHJvY2VzcyAoY2FuJ3QgaW5qZW" $s1c = "IGlzIGFuIHg2NCBwcm9jZXNzIChjYW4ndCBpbmplY3" $s2a = "RmFpbGVkIHRvIGltcGVyc29uYXRlIGxvZ2dlZCBvbi" $s2b = "YWlsZWQgdG8gaW1wZXJzb25hdGUgbG9nZ2VkIG9uIH" $s2c = "aWxlZCB0byBpbXBlcnNvbmF0ZSBsb2dnZWQgb24gdX" $s3a = "cG93ZXJzaGVsbCAtbm9wIC1leGVjIGJ5cGFzcyAtRW" $s3b = "b3dlcnNoZWxsIC1ub3AgLWV4ZWMgYnlwYXNzIC1Fbm" $s3c = "d2Vyc2hlbGwgLW5vcCAtZXhlYyBieXBhc3MgLUVuY2" $s4a = "SUVYIChOZXctT2JqZWN0IE5ldC5XZWJjbGllbnQpLk" $s4b = "RVggKE5ldy1PYmplY3QgTmV0LldlYmNsaWVudCkuRG" $s4c = "WCAoTmV3LU9iamVjdCBOZXQuV2ViY2xpZW50KS5Eb3" condition: filesize < 1000KB and 5 of ($s*) } rule hacktool_windows_cobaltstrike_beacon { meta: description = "Detect the risk of Malware Cobalt Strike Rule 2" condition: cobaltstrike_beacon_b64 or cobaltstrike_beacon_raw or cobaltstrike_beacon_exe } rule hacktool_windows_cobaltstrike_postexploitation { meta: description = "Detect the risk of Malware Cobalt Strike Rule 3" strings: $s1 = "\\devcenter\\aggressor\\external\\" condition: filesize > 10KB and filesize < 1000KB and all of ($s*) } rule hacktool_windows_cobaltstrike_powershell { meta: description = "Detect the risk of Malware Cobalt Strike Rule 4" strings: $ps1 = "Set-StrictMode -Version 2" $ps2 = "func_get_proc_address" $ps3 = "func_get_delegate_type" $ps4 = "FromBase64String" $ps5 = "VirtualAlloc" $ps6 = "var_code" $ps7 = "var_buffer" $ps8 = "var_hthread" condition: $ps1 at 0 and filesize < 1000KB and 7 of ($ps*) } rule beacon32 { meta: description = "Detect the risk of Malware Cobalt Strike Rule 5" strings: $name = "%c%c%c%c%c%c%c%c%cMSSE-%d-server" condition: uint16(0) == 0x5A4D and pe.entry_point == 0x8b0 and filesize > 277KB and filesize < 304KB and $name } rule ps { meta: description = "Detect the risk of Malware Cobalt Strike Rule 6" strings: $str1 = "$var_va.Invoke([IntPtr]::Zero, $var_code.Length, 0x3000, 0x40)" $str2 = "[System.Runtime.InteropServices.Marshal]::Copy($var_code, 0, $var_buffer, $var_code.length)" condition: uint16(0) != 0x5A4D and $str1 and $str2 } rule CobaltStrike_hta_pe { meta: description = "Detect the risk of Malware Cobalt Strike Rule 7" strings: $reg1 = /var_tempexe = var_basedir & \"\\\" & \"[A-z]{1,20}.exe\"\s*Set var_stream = var_obj.CreateTextFile\(var_tempexe, true , false\)/ condition: uint16(0) != 0x5A4D and $reg1 } rule hta_VBS { meta: description = "Detect the risk of Malware Cobalt Strike Rule 8" strings: $str = "myAr\"&\"ray \"&Chr(61)&\" Array\"&Chr(40)&Chr(45)&\"4\"&Chr(44)&Chr(45)&\"24\"&Chr(44)&Chr(45)&\"119\"&Chr(44)" condition: uint16(0) != 0x5A4D and $str } rule hta_ps1 { meta: description = "Detect the risk of Malware Cobalt Strike Rule 9" strings: $str = "var_shell.run \"powershell -nop -w hidden -encodedcommand JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8A" condition: uint16(0) != 0x5A4D and $str } rule hacktool_windows_cobaltstrike_powershell_2 { meta: description = "Detect the risk of Malware Cobalt Strike Rule 10" strings: $ps1 = "'System.dll'" ascii $ps2 = "Set-StrictMode -Version 2" ascii $ps3 = "GetProcAddress" ascii $ps4 = "start-job" ascii $ps5 = "VirtualAlloc" ascii condition: $ps2 at 0 and filesize < 1000KB and all of ($ps*) } rule hacktool_windows_cobaltstrike_in_memory { meta: description = "Detect the risk of Malware Cobalt Strike Rule 11" strings: $s1 = "IEX (New-Object Net.Webclient).DownloadString('http://127.0.0.1:%u/'); %s" $s2 = "powershell -nop -exec bypass -EncodedCommand \"%s\"" $s3 = "%d is an x86 process (can't inject x64 content)" $s4 = "%d.%d %s %s %s %s" $s5 = "could not upload file: %d" $s7 = "KVK...................................0.-.n" $s8 = "%d is an x64 process (can't inject x86 content)" $op1 = {C7 45 F0 0? 00 00 00 E9 BF A3 BC FF} condition: 6 of them } rule cobaltstrike_beacon_in_memory { meta: description = "Detect the risk of Malware Cobalt Strike Rule 12" strings: $s1 = "beacon.x64.dll" fullword $s2 = "F %I64d %02d/%02d/%02d %02d:%02d:%02d %s" fullword condition: all of them } rule APT_CobaltStrike_Beacon_Indicator { meta: description = "Detect the risk of Malware Cobalt Strike Rule 13" strings: $v1 = { 73 70 72 6E 67 00 } $v2 = { 69 69 69 69 69 69 69 69 } condition: uint16(0) == 0x5a4d and filesize < 300KB and all of them } rule CobaltStrike_ShellCode { meta: description = "Detect the risk of Malware Cobalt Strike Rule 14" strings: $ = {8B 58 24 01 D3 66 8B 0C 4B 8B 58 1C 01 D3 8B 04 8B} $ = {68 6E 65 74 00 68 77 69 6E 69 54 68 4C 77 26 07 FF D5} condition: any of them } rule CobaltStrike_Payload { meta: description ="Detect the risk of Malware Cobalt Strike Rule 15" strings: $ = "%c%c%c%c%c%c%c%c%cMSSE-%d-server" fullword ascii $ = {B9 AA 26 00 00 31 D2 C7 44 24 28 5C 00 00 00 C7 44 24 24 65 00 00 00 C7 44 24 20 70 00 00 00 C7 44 24 1C 69 00 00 00 C7 44 24 18 70 00 00 00 F7 F1 C7 44 24 14 5C 00 00 00 C7 44 24 10 2E 00 00 00 C7 44 24 0C 5C 00 00 00 C7 44 24 08 5C 00 00 00 C7 44 24 04 44 40 40 00 C7 04 24 F0 53 40 00 89 54 24} condition: any of them } rule CobaltStrike_Malicious_HTA { meta: description = "Detect the risk of Malware Cobalt Strike Rule 16" strings: $var_shell = "CreateObject(\"Wscript.Shell\")" nocase $RunPowerShell = "powershell -nop -w hidden -encodedcommand " nocase $DropFile = ".Write Chr(CLng(\"&H\" & Mid(" nocase $Obfuscator = "&\"Long\"&Chr(44)&" nocase $Script = "