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 = "2026-05-04" 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 = "20260422" malpedia_hash = "a182e35da64e6d71cb55f125c4d4225196523f14" malpedia_version = "20260504" 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 = { 8d8dbffdffff e8???????? 8bf0 83c404 85f6 0f8488000000 68ff000000 } // n = 7, score = 100 // 8d8dbffdffff | lea ecx, [ebp - 0x241] // e8???????? | // 8bf0 | mov esi, eax // 83c404 | add esp, 4 // 85f6 | test esi, esi // 0f8488000000 | je 0x8e // 68ff000000 | push 0xff $sequence_1 = { 33ff 33c9 33f6 84db 744c 90 } // n = 6, score = 100 // 33ff | xor edi, edi // 33c9 | xor ecx, ecx // 33f6 | xor esi, esi // 84db | test bl, bl // 744c | je 0x4e // 90 | nop $sequence_2 = { 83e01f c1f905 8b0c8d80502500 c1e006 8d440104 8020fe ff36 } // n = 7, score = 100 // 83e01f | and eax, 0x1f // c1f905 | sar ecx, 5 // 8b0c8d80502500 | mov ecx, dword ptr [ecx*4 + 0x255080] // c1e006 | shl eax, 6 // 8d440104 | lea eax, [ecx + eax + 4] // 8020fe | and byte ptr [eax], 0xfe // ff36 | push dword ptr [esi] $sequence_3 = { 0fb6730c 83c40c 56 83c30d 8d85d8fcffff 53 } // n = 6, score = 100 // 0fb6730c | movzx esi, byte ptr [ebx + 0xc] // 83c40c | add esp, 0xc // 56 | push esi // 83c30d | add ebx, 0xd // 8d85d8fcffff | lea eax, [ebp - 0x328] // 53 | push ebx $sequence_4 = { 03049580502500 eb05 b8???????? f6400420 } // n = 4, score = 100 // 03049580502500 | add eax, dword ptr [edx*4 + 0x255080] // eb05 | jmp 7 // b8???????? | // f6400420 | test byte ptr [eax + 4], 0x20 $sequence_5 = { 83c102 2bc8 8817 7434 } // n = 4, score = 100 // 83c102 | add ecx, 2 // 2bc8 | sub ecx, eax // 8817 | mov byte ptr [edi], dl // 7434 | je 0x36 $sequence_6 = { 013d???????? 89410c e8???????? 833800 a3???????? bf03000000 7530 } // n = 7, score = 100 // 013d???????? | // 89410c | mov dword ptr [ecx + 0xc], eax // e8???????? | // 833800 | cmp dword ptr [eax], 0 // a3???????? | // bf03000000 | mov edi, 3 // 7530 | jne 0x32 $sequence_7 = { ebde 8bc8 83e01f c1f905 8b0c8d80502500 c1e006 0fbe440104 } // n = 7, score = 100 // ebde | jmp 0xffffffe0 // 8bc8 | mov ecx, eax // 83e01f | and eax, 0x1f // c1f905 | sar ecx, 5 // 8b0c8d80502500 | mov ecx, dword ptr [ecx*4 + 0x255080] // c1e006 | shl eax, 6 // 0fbe440104 | movsx eax, byte ptr [ecx + eax + 4] $sequence_8 = { c0f803 2403 02c9 0ac8 8a45e0 241f 884def } // n = 7, score = 100 // c0f803 | sar al, 3 // 2403 | and al, 3 // 02c9 | add cl, cl // 0ac8 | or cl, al // 8a45e0 | mov al, byte ptr [ebp - 0x20] // 241f | and al, 0x1f // 884def | mov byte ptr [ebp - 0x11], cl $sequence_9 = { 8b0c8d80502500 83e01f c1e006 f644080401 74cd } // n = 5, score = 100 // 8b0c8d80502500 | mov ecx, dword ptr [ecx*4 + 0x255080] // 83e01f | and eax, 0x1f // c1e006 | shl eax, 6 // f644080401 | test byte ptr [eax + ecx + 4], 1 // 74cd | je 0xffffffcf 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. Changes regarding references should be proposed on the Malpedia library page.
Your suggestion will be reviewed before being published. Thank you for contributing!
YYYY-MM-DD
YYYY-MM
YYYY