rule win_rook_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.rook."
        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.rook"
        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 = { 0fb6843050d10400 c1e008 0bd8 498bc2 48c1e808 0fb6c8 c1e308 }
            // n = 7, score = 100
            //   0fb6843050d10400     | inc                 ebp
            //   c1e008               | test                esi, esi
            //   0bd8                 | jle                 0x10ad
            //   498bc2               | inc                 ecx
            //   48c1e808             | dec                 esi
            //   0fb6c8               | dec                 eax
            //   c1e308               | lea                 edx, [esp + 0x60]

        $sequence_1 = { 488d1d3b030200 eb07 488d1d1a030200 4883a4249800000000 4084f6 740b b903000000 }
            // n = 7, score = 100
            //   488d1d3b030200       | je                  0xeea
            //   eb07                 | inc                 ecx
            //   488d1d1a030200       | lea                 edx, [ecx - 0x1d]
            //   4883a4249800000000     | dec    eax
            //   4084f6               | mov                 dword ptr [esp + 0x54], eax
            //   740b                 | dec                 eax
            //   b903000000           | mov                 ecx, ebx

        $sequence_2 = { 48894778 488d05ae720300 c7476801000000 48c7477003000000 48898790000000 c7878000000001000000 }
            // n = 6, score = 100
            //   48894778             | mov                 esi, edx
            //   488d05ae720300       | jg                  0x539
            //   c7476801000000       | dec                 esp
            //   48c7477003000000     | mov                 ebp, dword ptr [ebp + 0x58]
            //   48898790000000       | dec                 esp
            //   c7878000000001000000     | lea    esi, [0xffff8db1]

        $sequence_3 = { 8bc3 48c1e808 0fb6c8 420fb6843170940500 33d0 410fb6c2 }
            // n = 6, score = 100
            //   8bc3                 | or                  ebx, ecx
            //   48c1e808             | inc                 ebp
            //   0fb6c8               | add                 ebx, ebx
            //   420fb6843170940500     | mov    ecx, dword ptr [edi + eax*4 + 0x48b80]
            //   33d0                 | dec                 eax
            //   410fb6c2             | mov                 eax, edx

        $sequence_4 = { 488bf9 488d15c7ba0000 b914000000 e8???????? }
            // n = 4, score = 100
            //   488bf9               | lea                 ecx, [0x9241]
            //   488d15c7ba0000       | dec                 eax
            //   b914000000           | add                 ebx, 0x80000
            //   e8????????           |                     

        $sequence_5 = { 4883eb01 7582 4183c9ff 41b801000000 498bd4 8bcf ff15???????? }
            // n = 7, score = 100
            //   4883eb01             | mov                 edx, 1
            //   7582                 | fld                 qword ptr [eax]
            //   4183c9ff             | add                 byte ptr [esi - 0x49ffff23], ch
            //   41b801000000         | fld                 qword ptr [eax]
            //   498bd4               | add                 byte ptr [esi - 0x41ffff23], dh
            //   8bcf                 | fld                 qword ptr [eax]
            //   ff15????????         |                     

        $sequence_6 = { 488bd8 4885c0 74e2 488bd6 488bc8 ff15???????? 488bcb }
            // n = 7, score = 100
            //   488bd8               | xor                 edx, edx
            //   4885c0               | dec                 eax
            //   74e2                 | mov                 dword ptr [esp + 0x20], eax
            //   488bd6               | inc                 ecx
            //   488bc8               | mov                 eax, 0x120
            //   ff15????????         |                     
            //   488bcb               | dec                 eax

        $sequence_7 = { 8bc3 48c1e810 0fb6c8 8bc6 48c1e818 458b8496a0a20500 48c1eb18 }
            // n = 7, score = 100
            //   8bc3                 | dec                 eax
            //   48c1e810             | lea                 eax, [0x510ca]
            //   0fb6c8               | mov                 eax, 0x30
            //   8bc6                 | dec                 eax
            //   48c1e818             | cmove               ebx, eax
            //   458b8496a0a20500     | dec                 eax
            //   48c1eb18             | lea                 eax, [0x3f12f]

        $sequence_8 = { 8bd9 4c8d0dddce0000 b904000000 4c8d05c9ce0000 488d15b2bb0000 e8???????? }
            // n = 6, score = 100
            //   8bd9                 | dec                 esp
            //   4c8d0dddce0000       | lea                 eax, [0x1f871]
            //   b904000000           | and                 ecx, 0x3f
            //   4c8d05c9ce0000       | dec                 eax
            //   488d15b2bb0000       | mov                 eax, edx
            //   e8????????           |                     

        $sequence_9 = { 8b8c82b0e20000 4803ca ffe1 4d8bc2 e9???????? 4d8bc2 }
            // n = 6, score = 100
            //   8b8c82b0e20000       | ret                 
            //   4803ca               | dec                 eax
            //   ffe1                 | lea                 ecx, [0x4bb39]
            //   4d8bc2               | dec                 eax
            //   e9????????           |                     
            //   4d8bc2               | mov                 ebx, dword ptr [esp + 0x288]

    condition:
        7 of them and filesize < 843776
}