Actor(s): Mirage
RoyalDNS is a DNS based backdoor used by APT15 that persistences on a system through a service called 'Nwsapagent'.
rule win_royal_dns_auto { meta: author = "Felix Bilstein - yara-signator at cocacoding dot com" date = "2023-01-25" version = "1" description = "Detects win.royal_dns." info = "autogenerated rule brought to you by yara-signator" tool = "yara-signator v0.6.0" signator_config = "callsandjumps;datarefs;binvalue" malpedia_reference = "https://malpedia.caad.fkie.fraunhofer.de/details/win.royal_dns" malpedia_rule_date = "20230124" malpedia_hash = "2ee0eebba83dce3d019a90519f2f972c0fcf9686" malpedia_version = "20230125" malpedia_license = "CC BY-SA 4.0" malpedia_sharing = "TLP:WHITE" /* DISCLAIMER * The strings used in this rule have been automatically selected from the * disassembly of memory dumps and unpacked files, using YARA-Signator. * The code and documentation is published here: * https://github.com/fxb-cocacoding/yara-signator * As Malpedia is used as data source, please note that for a given * number of families, only single samples are documented. * This likely impacts the degree of generalization these rules will offer. * Take the described generation method also into consideration when you * apply the rules in your use cases and assign them confidence levels. */ strings: $sequence_0 = { 7543 8d95b0f7ffff 8d85a1f1ffff e8???????? eb30 } // n = 5, score = 100 // 7543 | jne 0x45 // 8d95b0f7ffff | lea edx, [ebp - 0x850] // 8d85a1f1ffff | lea eax, [ebp - 0xe5f] // e8???????? | // eb30 | jmp 0x32 $sequence_1 = { e8???????? 83c40c 8bc6 eb15 8d8da1f1ffff } // n = 5, score = 100 // e8???????? | // 83c40c | add esp, 0xc // 8bc6 | mov eax, esi // eb15 | jmp 0x17 // 8d8da1f1ffff | lea ecx, [ebp - 0xe5f] $sequence_2 = { 8a8d8ff1ffff 80e1f5 02c0 0ac1 b908000000 be???????? } // n = 6, score = 100 // 8a8d8ff1ffff | mov cl, byte ptr [ebp - 0xe71] // 80e1f5 | and cl, 0xf5 // 02c0 | add al, al // 0ac1 | or al, cl // b908000000 | mov ecx, 8 // be???????? | $sequence_3 = { 898594fcffff 8d85d9feffff 83c404 8d5001 8a08 40 84c9 } // n = 7, score = 100 // 898594fcffff | mov dword ptr [ebp - 0x36c], eax // 8d85d9feffff | lea eax, [ebp - 0x127] // 83c404 | add esp, 4 // 8d5001 | lea edx, [eax + 1] // 8a08 | mov cl, byte ptr [eax] // 40 | inc eax // 84c9 | test cl, cl $sequence_4 = { 0fb6730c 83c40c 56 83c30d } // n = 4, score = 100 // 0fb6730c | movzx esi, byte ptr [ebx + 0xc] // 83c40c | add esp, 0xc // 56 | push esi // 83c30d | add ebx, 0xd $sequence_5 = { 51 ffd6 5b b801000000 } // n = 4, score = 100 // 51 | push ecx // ffd6 | call esi // 5b | pop ebx // b801000000 | mov eax, 1 $sequence_6 = { 5d c3 8d85e0fcffff 50 68???????? } // n = 5, score = 100 // 5d | pop ebp // c3 | ret // 8d85e0fcffff | lea eax, [ebp - 0x320] // 50 | push eax // 68???????? | $sequence_7 = { 894208 393d???????? 7c11 6860ea0000 } // n = 4, score = 100 // 894208 | mov dword ptr [edx + 8], eax // 393d???????? | // 7c11 | jl 0x13 // 6860ea0000 | push 0xea60 $sequence_8 = { 8d1cbd04000000 53 e8???????? 8bf0 83c404 } // n = 5, score = 100 // 8d1cbd04000000 | lea ebx, [edi*4 + 4] // 53 | push ebx // e8???????? | // 8bf0 | mov esi, eax // 83c404 | add esp, 4 $sequence_9 = { 51 ff15???????? 85c0 0f8597000000 8b85f8f5ffff 8d95f0f5ffff } // n = 6, score = 100 // 51 | push ecx // ff15???????? | // 85c0 | test eax, eax // 0f8597000000 | jne 0x9d // 8b85f8f5ffff | mov eax, dword ptr [ebp - 0xa08] // 8d95f0f5ffff | lea edx, [ebp - 0xa10] condition: 7 of them and filesize < 204800 }
import "pe" rule win_royal_dns_w0 { meta: author = "Florian Roth" description = "Detects malware from APT 15 report by NCC Group" reference = "https://goo.gl/HZ5XMN" date = "2018-03-10" hash = "bc937f6e958b339f6925023bc2af375d669084e9551fd3753e501ef26e36b39d" malpedia_reference = "https://malpedia.caad.fkie.fraunhofer.de/details/win.royal_dns" malpedia_version = "20180312" malpedia_license = "CC BY-NC-SA 4.0" malpedia_sharing = "TLP:WHITE" strings: $x1 = "del c:\\windows\\temp\\r.exe /f /q" fullword ascii $x2 = "%s\\r.exe" fullword ascii $s1 = "rights.dll" fullword ascii $s2 = "\"%s\">>\"%s\"\\s.txt" fullword ascii $s3 = "Nwsapagent" fullword ascii $s4 = "%s\\r.bat" fullword ascii $s5 = "%s\\s.txt" fullword ascii $s6 = "runexe" fullword ascii condition: 1 of ($x*) or 2 of them }
rule win_royal_dns_w1 { meta: author = "David Cannings" description = "DLL implant, originally rights.dll and runs as a service" hash = "bc937f6e958b339f6925023bc2af375d669084e9551fd3753e501ef26e36b39d" malpedia_reference = "https://malpedia.caad.fkie.fraunhofer.de/details/win.royal_dns" malpedia_version = "20180312" malpedia_license = "CC BY-NC-SA 4.0" malpedia_sharing = "TLP:WHITE" strings: /* 56 push esi B8 A7 C6 67 4E mov eax, 4E67C6A7h 83 C1 02 add ecx, 2 BA 04 00 00 00 mov edx, 4 57 push edi 90 nop */ // JSHash implementation (Justin Sobel's hash algorithm) $opcodes_jshash = { B8 A7 C6 67 4E 83 C1 02 BA 04 00 00 00 57 90 } /* 0F B6 1C 03 movzx ebx, byte ptr [ebx+eax] 8B 55 08 mov edx, [ebp+arg_0] 30 1C 17 xor [edi+edx], bl 47 inc edi 3B 7D 0C cmp edi, [ebp+arg_4] 72 A4 jb short loc_10003F31 */ // Encode loop, used to "encrypt" data before DNS request $opcodes_encode = { 0F B6 1C 03 8B 55 08 30 1C 17 47 3B 7D 0C } /* 68 88 13 00 00 push 5000 # Also seen 3000, included below FF D6 call esi ; Sleep 4F dec edi 75 F6 jnz short loc_10001554 */ // Sleep loop $opcodes_sleep_loop = { 68 (88|B8) (13|0B) 00 00 FF D6 4F 75 F6 } // Generic strings $ = "Nwsapagent" fullword $ = "\"%s\">>\"%s\"\\s.txt" $ = "myWObject" fullword $ = "del c:\\windows\\temp\\r.exe /f /q" $ = "del c:\\windows\\temp\\r.ini /f /q" condition: 3 of them }
If your designated proposal does not fit in any other category, feel free to write a free-text in the comment field below.
Please propose all changes regarding references on the Malpedia library page
Your suggestion will be reviewed before being published. Thank you for contributing!
YYYY-MM-DD
YYYY-MM
YYYY