rule win_hive_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.hive."
        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.hive"
        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 = { 31c0 b91d000000 31d2 31db }
            // n = 4, score = 300
            //   31c0                 | inc                 eax
            //   b91d000000           | movzx               edx, dh
            //   31d2                 | add                 eax, ecx
            //   31db                 | shl                 eax, 6

        $sequence_1 = { 7f1e 0fbae000 73ed 90 }
            // n = 4, score = 200
            //   7f1e                 | lea                 eax, [0x59eee0]
            //   0fbae000             | mov                 dword ptr [esp], eax
            //   73ed                 | mov                 dword ptr [esp + 4], edx
            //   90                   | mov                 dword ptr [esp + 8], ebp

        $sequence_2 = { 7f07 ba01000000 eb19 83fa02 7307 }
            // n = 5, score = 200
            //   7f07                 | xor                 edx, edx
            //   ba01000000           | xor                 ebx, ebx
            //   eb19                 | mov                 ecx, edx
            //   83fa02               | mov                 ecx, 1
            //   7307                 | mov                 ecx, edx

        $sequence_3 = { 89c2 e8???????? b801000000 e8???????? 90 }
            // n = 5, score = 200
            //   89c2                 | movzx               eax, bl
            //   e8????????           |                     
            //   b801000000           | add                 eax, edx
            //   e8????????           |                     
            //   90                   | add                 edx, ecx

        $sequence_4 = { 31c0 31c9 31d2 bb08000000 be20000000 31ff }
            // n = 6, score = 200
            //   31c0                 | mov                 ebx, 7
            //   31c9                 | mov                 esi, 0x65
            //   31d2                 | xor                 edi, edi
            //   bb08000000           | jmp                 0x1e
            //   be20000000           | xor                 ecx, ecx
            //   31ff                 | xor                 edx, edx

        $sequence_5 = { 89d1 e8???????? b802000000 e8???????? }
            // n = 4, score = 200
            //   89d1                 | shl                 edx, 6
            //   e8????????           |                     
            //   b802000000           | movzx               eax, bl
            //   e8????????           |                     

        $sequence_6 = { 31d3 8d1c18 8d5b3a 0f1f00 }
            // n = 4, score = 200
            //   31d3                 | mov                 word ptr [esp + 0x42], 0x4163
            //   8d1c18               | jg                  0x20
            //   8d5b3a               | bt                  eax, 0
            //   0f1f00               | jae                 0xffffffef

        $sequence_7 = { 81c4b0000000 c3 e8???????? 90 }
            // n = 4, score = 200
            //   81c4b0000000         | inc                 eax
            //   c3                   | movzx               ecx, bh
            //   e8????????           |                     
            //   90                   | add                 ecx, eax

        $sequence_8 = { 31c0 31c9 31d2 bb07000000 be65000000 31ff eb0e }
            // n = 7, score = 200
            //   31c0                 | add                 esp, 0xb0
            //   31c9                 | ret                 
            //   31d2                 | nop                 
            //   bb07000000           | jg                  0x20
            //   be65000000           | bt                  eax, 0
            //   31ff                 | jae                 0xffffffef
            //   eb0e                 | nop                 

        $sequence_9 = { 31c9 31d2 bb04000000 beb8000000 }
            // n = 4, score = 200
            //   31c9                 | mov                 edx, 1
            //   31d2                 | jmp                 0x29
            //   bb04000000           | cmp                 edx, 2
            //   beb8000000           | jae                 0x1c

        $sequence_10 = { 89d1 e8???????? b901000000 e8???????? }
            // n = 4, score = 200
            //   89d1                 | inc                 eax
            //   e8????????           |                     
            //   b901000000           | movzx               edx, dh
            //   e8????????           |                     

        $sequence_11 = { 31c9 31d2 bb01000000 beae000000 }
            // n = 4, score = 200
            //   31c9                 | jg                  0x20
            //   31d2                 | bt                  eax, 0
            //   bb01000000           | jae                 0xffffffef
            //   beae000000           | nop                 

        $sequence_12 = { 01c1 83c101 83f90c 0f820fffffff }
            // n = 4, score = 100
            //   01c1                 | je                  0x274
            //   83c101               | add                 eax, eax
            //   83f90c               | inc                 eax
            //   0f820fffffff         | add                 al, bh

        $sequence_13 = { 01c1 c1e106 400fb6d6 01ca }
            // n = 4, score = 100
            //   01c1                 | add                 ecx, eax
            //   c1e106               | shl                 ecx, 6
            //   400fb6d6             | movzx               eax, dl
            //   01ca                 | add                 eax, ecx

        $sequence_14 = { 89bc2480000000 8b7918 8b491c 894c247c }
            // n = 4, score = 100
            //   89bc2480000000       | movzx               eax, bl
            //   8b7918               | add                 eax, edx
            //   8b491c               | dec                 ebp
            //   894c247c             | test                edi, edi

        $sequence_15 = { 01c8 89c1 c1e91f ffc9 }
            // n = 4, score = 100
            //   01c8                 | movzx               eax, bl
            //   89c1                 | add                 eax, edx
            //   c1e91f               | add                 edx, eax
            //   ffc9                 | mov                 eax, 0x3ffffff

        $sequence_16 = { 01c2 b8ffffff03 21c5 21c3 }
            // n = 4, score = 100
            //   01c2                 | inc                 eax
            //   b8ffffff03           | movzx               edx, dh
            //   21c5                 | add                 edx, ecx
            //   21c3                 | add                 ecx, eax

        $sequence_17 = { 89bc2480000000 8d05c0eb5800 890424 89542404 }
            // n = 4, score = 100
            //   89bc2480000000       | xor                 edx, edx
            //   8d05c0eb5800         | xor                 ebx, ebx
            //   890424               | add                 esp, 0xb0
            //   89542404             | ret                 

        $sequence_18 = { 01c0 4000f8 0fb6c0 48898424b0000000 }
            // n = 4, score = 100
            //   01c0                 | add                 eax, eax
            //   4000f8               | inc                 eax
            //   0fb6c0               | add                 al, bh
            //   48898424b0000000     | movzx               eax, al

        $sequence_19 = { 01ca c1e206 0fb6c3 01d0 }
            // n = 4, score = 100
            //   01ca                 | mov                 ecx, eax
            //   c1e206               | shr                 ecx, 0x1f
            //   0fb6c3               | dec                 ecx
            //   01d0                 | inc                 ecx

        $sequence_20 = { 01c1 c1e106 0fb6c2 01c8 }
            // n = 4, score = 100
            //   01c1                 | jb                  0xfffffe99
            //   c1e106               | mov                 edx, 5
            //   0fb6c2               | add                 ecx, eax
            //   01c8                 | add                 ecx, 1

        $sequence_21 = { 01c8 c1e006 400fb6cf 01c1 }
            // n = 4, score = 100
            //   01c8                 | and                 ecx, eax
            //   c1e006               | inc                 ecx
            //   400fb6cf             | mov                 dword ptr [edi + 0x14], ecx
            //   01c1                 | add                 eax, ecx

    condition:
        7 of them and filesize < 7946240
}