SYMBOLCOMMON_NAMEaka. SYNONYMS
win.royal_dns (Back to overview)

Royal DNS

Actor(s): Mirage

VTCollection    

RoyalDNS is a DNS based backdoor used by APT15 that persistences on a system through a service called 'Nwsapagent'.

References
2020-01-01SecureworksSecureWorks
BRONZE PALACE
BS2005 Enfal Mirage RoyalCli Royal DNS APT15
2018-03-16Github (nccgroup)NCC Group PLC
Royal APT - APT15 Repository
BS2005 MS Exchange Tool RoyalCli Royal DNS APT15
2018-03-10NCC GroupRob Smallridge
APT15 is alive and strong: An analysis of RoyalCli and RoyalDNS
BS2005 MS Exchange Tool RoyalCli Royal DNS APT15
Yara Rules
[TLP:WHITE] win_royal_dns_auto (20241030 | Detects win.royal_dns.)
rule win_royal_dns_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2024-10-31"
        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 = "20241030"
        malpedia_hash = "26e26953c49c8efafbf72a38076855d578e0a2e4"
        malpedia_version = "20241030"
        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 = { e8???????? 83c404 83bd80f1ffff05 7c12 8b8d7cf1ffff 51 ff15???????? }
            // n = 7, score = 100
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   83bd80f1ffff05       | cmp                 dword ptr [ebp - 0xe80], 5
            //   7c12                 | jl                  0x14
            //   8b8d7cf1ffff         | mov                 ecx, dword ptr [ebp - 0xe84]
            //   51                   | push                ecx
            //   ff15????????         |                     

        $sequence_1 = { 83c004 8985e8faffff 3bc1 0f8725010000 }
            // n = 4, score = 100
            //   83c004               | add                 eax, 4
            //   8985e8faffff         | mov                 dword ptr [ebp - 0x518], eax
            //   3bc1                 | cmp                 eax, ecx
            //   0f8725010000         | ja                  0x12b

        $sequence_2 = { ffd6 68???????? 8d95f0fdffff 52 ffd6 57 8d85f0fdffff }
            // n = 7, score = 100
            //   ffd6                 | call                esi
            //   68????????           |                     
            //   8d95f0fdffff         | lea                 edx, [ebp - 0x210]
            //   52                   | push                edx
            //   ffd6                 | call                esi
            //   57                   | push                edi
            //   8d85f0fdffff         | lea                 eax, [ebp - 0x210]

        $sequence_3 = { 75f9 8b4dfc 2bc2 8d540801 8b45f8 8910 }
            // n = 6, score = 100
            //   75f9                 | jne                 0xfffffffb
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   2bc2                 | sub                 eax, edx
            //   8d540801             | lea                 edx, [eax + ecx + 1]
            //   8b45f8               | mov                 eax, dword ptr [ebp - 8]
            //   8910                 | mov                 dword ptr [eax], edx

        $sequence_4 = { 0f84ad010000 83f8ff 0f84a4010000 85c0 0f849c010000 }
            // n = 5, score = 100
            //   0f84ad010000         | je                  0x1b3
            //   83f8ff               | cmp                 eax, -1
            //   0f84a4010000         | je                  0x1aa
            //   85c0                 | test                eax, eax
            //   0f849c010000         | je                  0x1a2

        $sequence_5 = { 56 8d85e8fdffff 68???????? 50 e8???????? 83c40c 8d8df0feffff }
            // n = 7, score = 100
            //   56                   | push                esi
            //   8d85e8fdffff         | lea                 eax, [ebp - 0x218]
            //   68????????           |                     
            //   50                   | push                eax
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   8d8df0feffff         | lea                 ecx, [ebp - 0x110]

        $sequence_6 = { 8d95d8fcffff 6a00 52 e8???????? 0fb6730c }
            // n = 5, score = 100
            //   8d95d8fcffff         | lea                 edx, [ebp - 0x328]
            //   6a00                 | push                0
            //   52                   | push                edx
            //   e8????????           |                     
            //   0fb6730c             | movzx               esi, byte ptr [ebx + 0xc]

        $sequence_7 = { 53 6a00 6800040000 8d85f4fbffff c785dcfaffff10000000 }
            // n = 5, score = 100
            //   53                   | push                ebx
            //   6a00                 | push                0
            //   6800040000           | push                0x400
            //   8d85f4fbffff         | lea                 eax, [ebp - 0x40c]
            //   c785dcfaffff10000000     | mov    dword ptr [ebp - 0x524], 0x10

        $sequence_8 = { 8b4608 52 83c00c 50 83c711 57 e8???????? }
            // n = 7, score = 100
            //   8b4608               | mov                 eax, dword ptr [esi + 8]
            //   52                   | push                edx
            //   83c00c               | add                 eax, 0xc
            //   50                   | push                eax
            //   83c711               | add                 edi, 0x11
            //   57                   | push                edi
            //   e8????????           |                     

        $sequence_9 = { be50000000 56 51 8d95d9feffff 52 }
            // n = 5, score = 100
            //   be50000000           | mov                 esi, 0x50
            //   56                   | push                esi
            //   51                   | push                ecx
            //   8d95d9feffff         | lea                 edx, [ebp - 0x127]
            //   52                   | push                edx

    condition:
        7 of them and filesize < 204800
}
[TLP:WHITE] win_royal_dns_w0   (20180312 | Detects malware from APT 15 report by NCC Group)
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
}
[TLP:WHITE] win_royal_dns_w1   (20180312 | DLL implant, originally rights.dll and runs as a service)
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
}
Download all Yara Rules