rule win_royalcli_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.royalcli."
        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.royalcli"
        malpedia_rule_date = "20260916"
        malpedia_hash = "53a643781c18e08f4a50949af60172d837a0b6f6"
        malpedia_version = "20260917"
        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 = { 85c0 0f84cf000000 8b3d???????? 50 ffd7 6a00 6880000000 }
            // n = 7, score = 100
            //   85c0                 | test                eax, eax
            //   0f84cf000000         | je                  0xd5
            //   8b3d????????         |                     
            //   50                   | push                eax
            //   ffd7                 | call                edi
            //   6a00                 | push                0
            //   6880000000           | push                0x80

        $sequence_1 = { ffd6 8d8df4f6ffff 51 ffd6 }
            // n = 4, score = 100
            //   ffd6                 | call                esi
            //   8d8df4f6ffff         | lea                 ecx, [ebp - 0x90c]
            //   51                   | push                ecx
            //   ffd6                 | call                esi

        $sequence_2 = { 55 8bec 81ec30090000 a1???????? 33c5 8945f8 8b4508 }
            // n = 7, score = 100
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   81ec30090000         | sub                 esp, 0x930
            //   a1????????           |                     
            //   33c5                 | xor                 eax, ebp
            //   8945f8               | mov                 dword ptr [ebp - 8], eax
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]

        $sequence_3 = { 8d459c 50 c644759c00 68???????? 8d959cf7ffff c644759d00 }
            // n = 6, score = 100
            //   8d459c               | lea                 eax, [ebp - 0x64]
            //   50                   | push                eax
            //   c644759c00           | mov                 byte ptr [ebp + esi*2 - 0x64], 0
            //   68????????           |                     
            //   8d959cf7ffff         | lea                 edx, [ebp - 0x864]
            //   c644759d00           | mov                 byte ptr [ebp + esi*2 - 0x63], 0

        $sequence_4 = { 83c404 8d95ccfeffff 52 6a14 8985b0f9ffff }
            // n = 5, score = 100
            //   83c404               | add                 esp, 4
            //   8d95ccfeffff         | lea                 edx, [ebp - 0x134]
            //   52                   | push                edx
            //   6a14                 | push                0x14
            //   8985b0f9ffff         | mov                 dword ptr [ebp - 0x650], eax

        $sequence_5 = { 356699aa55 03c2 8db078563412 81f66699aa55 33ff 03f1 }
            // n = 6, score = 100
            //   356699aa55           | xor                 eax, 0x55aa9966
            //   03c2                 | add                 eax, edx
            //   8db078563412         | lea                 esi, [eax + 0x12345678]
            //   81f66699aa55         | xor                 esi, 0x55aa9966
            //   33ff                 | xor                 edi, edi
            //   03f1                 | add                 esi, ecx

        $sequence_6 = { 721a 8b3c06 3b38 7508 83e904 83c004 }
            // n = 6, score = 100
            //   721a                 | jb                  0x1c
            //   8b3c06               | mov                 edi, dword ptr [esi + eax]
            //   3b38                 | cmp                 edi, dword ptr [eax]
            //   7508                 | jne                 0xa
            //   83e904               | sub                 ecx, 4
            //   83c004               | add                 eax, 4

        $sequence_7 = { 6a00 57 e8???????? 83c40c 8d85a4feffff }
            // n = 5, score = 100
            //   6a00                 | push                0
            //   57                   | push                edi
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   8d85a4feffff         | lea                 eax, [ebp - 0x15c]

        $sequence_8 = { 741d 50 ff15???????? b801000000 5f 5e 5b }
            // n = 7, score = 100
            //   741d                 | je                  0x1f
            //   50                   | push                eax
            //   ff15????????         |                     
            //   b801000000           | mov                 eax, 1
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   5b                   | pop                 ebx

        $sequence_9 = { 8b4508 8bc8 83e01f c1f905 8b0c8dc04b4100 c1e006 8d44010c }
            // n = 7, score = 100
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   8bc8                 | mov                 ecx, eax
            //   83e01f               | and                 eax, 0x1f
            //   c1f905               | sar                 ecx, 5
            //   8b0c8dc04b4100       | mov                 ecx, dword ptr [ecx*4 + 0x414bc0]
            //   c1e006               | shl                 eax, 6
            //   8d44010c             | lea                 eax, [ecx + eax + 0xc]

    condition:
        7 of them and filesize < 204800
}