rule win_mirai_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.mirai."
        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.mirai"
        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 = { e8???????? 83c428 8bc3 8a08 3a0f 751a 84c9 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   83c428               | add                 esp, 0x28
            //   8bc3                 | mov                 eax, ebx
            //   8a08                 | mov                 cl, byte ptr [eax]
            //   3a0f                 | cmp                 cl, byte ptr [edi]
            //   751a                 | jne                 0x1c
            //   84c9                 | test                cl, cl

        $sequence_1 = { c21000 55 8bec 51 51 894df8 8d45fc }
            // n = 7, score = 100
            //   c21000               | ret                 0x10
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   51                   | push                ecx
            //   51                   | push                ecx
            //   894df8               | mov                 dword ptr [ebp - 8], ecx
            //   8d45fc               | lea                 eax, [ebp - 4]

        $sequence_2 = { c1c308 c1c20a 03d8 33f3 03473c 33f2 03c6 }
            // n = 7, score = 100
            //   c1c308               | rol                 ebx, 8
            //   c1c20a               | rol                 edx, 0xa
            //   03d8                 | add                 ebx, eax
            //   33f3                 | xor                 esi, ebx
            //   03473c               | add                 eax, dword ptr [edi + 0x3c]
            //   33f2                 | xor                 esi, edx
            //   03c6                 | add                 eax, esi

        $sequence_3 = { e8???????? 8b86fc040000 83c404 899e0c040000 3bc3 7409 50 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   8b86fc040000         | mov                 eax, dword ptr [esi + 0x4fc]
            //   83c404               | add                 esp, 4
            //   899e0c040000         | mov                 dword ptr [esi + 0x40c], ebx
            //   3bc3                 | cmp                 eax, ebx
            //   7409                 | je                  0xb
            //   50                   | push                eax

        $sequence_4 = { 8d4603 50 56 8d4c2428 51 52 e8???????? }
            // n = 7, score = 100
            //   8d4603               | lea                 eax, [esi + 3]
            //   50                   | push                eax
            //   56                   | push                esi
            //   8d4c2428             | lea                 ecx, [esp + 0x28]
            //   51                   | push                ecx
            //   52                   | push                edx
            //   e8????????           |                     

        $sequence_5 = { c1f91b 0bc1 8b4dfc 8984cd68ffffff 8b45fc 8b84c564ffffff d1e0 }
            // n = 7, score = 100
            //   c1f91b               | sar                 ecx, 0x1b
            //   0bc1                 | or                  eax, ecx
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   8984cd68ffffff       | mov                 dword ptr [ebp + ecx*8 - 0x98], eax
            //   8b45fc               | mov                 eax, dword ptr [ebp - 4]
            //   8b84c564ffffff       | mov                 eax, dword ptr [ebp + eax*8 - 0x9c]
            //   d1e0                 | shl                 eax, 1

        $sequence_6 = { 8b4d08 8b8170040000 83c40c 83f801 741c 50 68???????? }
            // n = 7, score = 100
            //   8b4d08               | mov                 ecx, dword ptr [ebp + 8]
            //   8b8170040000         | mov                 eax, dword ptr [ecx + 0x470]
            //   83c40c               | add                 esp, 0xc
            //   83f801               | cmp                 eax, 1
            //   741c                 | je                  0x1e
            //   50                   | push                eax
            //   68????????           |                     

        $sequence_7 = { 8be5 5d c3 46 6a2f 56 897508 }
            // n = 7, score = 100
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   46                   | inc                 esi
            //   6a2f                 | push                0x2f
            //   56                   | push                esi
            //   897508               | mov                 dword ptr [ebp + 8], esi

        $sequence_8 = { be01000000 83c408 3933 7e27 90 8b4d00 8b14b1 }
            // n = 7, score = 100
            //   be01000000           | mov                 esi, 1
            //   83c408               | add                 esp, 8
            //   3933                 | cmp                 dword ptr [ebx], esi
            //   7e27                 | jle                 0x29
            //   90                   | nop                 
            //   8b4d00               | mov                 ecx, dword ptr [ebp]
            //   8b14b1               | mov                 edx, dword ptr [ecx + esi*4]

        $sequence_9 = { 894dfc ff75fc 8b4dfc e8???????? 8b4dfc 8b4910 8d0448 }
            // n = 7, score = 100
            //   894dfc               | mov                 dword ptr [ebp - 4], ecx
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   e8????????           |                     
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   8b4910               | mov                 ecx, dword ptr [ecx + 0x10]
            //   8d0448               | lea                 eax, [eax + ecx*2]

    condition:
        7 of them and filesize < 7086080
}