rule elf_mirai_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects elf.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/elf.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 = { 66894104 7406 66c741064000 c6410911 }
            // n = 4, score = 300
            //   66894104             | mov                 word ptr [ecx + 4], ax
            //   7406                 | je                  8
            //   66c741064000         | mov                 word ptr [ecx + 6], 0x40
            //   c6410911             | mov                 byte ptr [ecx + 9], 0x11

        $sequence_1 = { 8d429f 3c19 7705 8d42e0 }
            // n = 4, score = 300
            //   8d429f               | lea                 eax, [edx - 0x61]
            //   3c19                 | cmp                 al, 0x19
            //   7705                 | ja                  7
            //   8d42e0               | lea                 eax, [edx - 0x20]

        $sequence_2 = { 807c242b00 66894304 7406 66c743064000 }
            // n = 4, score = 300
            //   807c242b00           | cmp                 byte ptr [esp + 0x2b], 0
            //   66894304             | mov                 word ptr [ebx + 4], ax
            //   7406                 | je                  8
            //   66c743064000         | mov                 word ptr [ebx + 6], 0x40

        $sequence_3 = { c7433400000000 894330 c6433801 c6433903 }
            // n = 4, score = 300
            //   c7433400000000       | mov                 dword ptr [ebx + 0x34], 0
            //   894330               | mov                 dword ptr [ebx + 0x30], eax
            //   c6433801             | mov                 byte ptr [ebx + 0x38], 1
            //   c6433903             | mov                 byte ptr [ebx + 0x39], 3

        $sequence_4 = { c1ea03 89d0 c1e005 01d0 }
            // n = 4, score = 300
            //   c1ea03               | shr                 edx, 3
            //   89d0                 | mov                 eax, edx
            //   c1e005               | shl                 eax, 5
            //   01d0                 | add                 eax, edx

        $sequence_5 = { c1ea02 8d1492 29d0 83f804 }
            // n = 4, score = 300
            //   c1ea02               | shr                 edx, 2
            //   8d1492               | lea                 edx, [edx + edx*4]
            //   29d0                 | sub                 eax, edx
            //   83f804               | cmp                 eax, 4

        $sequence_6 = { 66c1e808 d0e8 8d04c0 28c2 }
            // n = 4, score = 300
            //   66c1e808             | shr                 ax, 8
            //   d0e8                 | shr                 al, 1
            //   8d04c0               | lea                 eax, [eax + eax*8]
            //   28c2                 | sub                 dl, al

        $sequence_7 = { c1e005 01d0 89ca 29c2 }
            // n = 4, score = 300
            //   c1e005               | shl                 eax, 5
            //   01d0                 | add                 eax, edx
            //   89ca                 | mov                 edx, ecx
            //   29c2                 | sub                 edx, eax

    condition:
        7 of them and filesize < 2228224
}