rule win_enfal_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.enfal."
        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.enfal"
        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 = { ff15???????? 68???????? 50 8945ec ffd6 68???????? 8903 }
            // n = 7, score = 200
            //   ff15????????         |                     
            //   68????????           |                     
            //   50                   | push                eax
            //   8945ec               | mov                 dword ptr [ebp - 0x14], eax
            //   ffd6                 | call                esi
            //   68????????           |                     
            //   8903                 | mov                 dword ptr [ebx], eax

        $sequence_1 = { 51 8d8d68ffffff 51 8d8de8fcffff }
            // n = 4, score = 200
            //   51                   | push                ecx
            //   8d8d68ffffff         | lea                 ecx, [ebp - 0x98]
            //   51                   | push                ecx
            //   8d8de8fcffff         | lea                 ecx, [ebp - 0x318]

        $sequence_2 = { ff7508 53 ff5620 85c0 7403 }
            // n = 5, score = 200
            //   ff7508               | push                dword ptr [ebp + 8]
            //   53                   | push                ebx
            //   ff5620               | call                dword ptr [esi + 0x20]
            //   85c0                 | test                eax, eax
            //   7403                 | je                  5

        $sequence_3 = { 53 56 8b750c 8d85f8fdffff }
            // n = 4, score = 200
            //   53                   | push                ebx
            //   56                   | push                esi
            //   8b750c               | mov                 esi, dword ptr [ebp + 0xc]
            //   8d85f8fdffff         | lea                 eax, [ebp - 0x208]

        $sequence_4 = { e8???????? 8b4b1c be???????? 8dbd9cfeffff }
            // n = 4, score = 200
            //   e8????????           |                     
            //   8b4b1c               | mov                 ecx, dword ptr [ebx + 0x1c]
            //   be????????           |                     
            //   8dbd9cfeffff         | lea                 edi, [ebp - 0x164]

        $sequence_5 = { f3ab 66ab 8065ff00 6800040000 }
            // n = 4, score = 200
            //   f3ab                 | rep stosd           dword ptr es:[edi], eax
            //   66ab                 | stosw               word ptr es:[edi], ax
            //   8065ff00             | and                 byte ptr [ebp - 1], 0
            //   6800040000           | push                0x400

        $sequence_6 = { 66a5 a4 be???????? 8dbd60ffffff }
            // n = 4, score = 200
            //   66a5                 | movsw               word ptr es:[edi], word ptr [esi]
            //   a4                   | movsb               byte ptr es:[edi], byte ptr [esi]
            //   be????????           |                     
            //   8dbd60ffffff         | lea                 edi, [ebp - 0xa0]

        $sequence_7 = { 8945f0 e8???????? 83f812 59 750e 807f0152 7528 }
            // n = 7, score = 200
            //   8945f0               | mov                 dword ptr [ebp - 0x10], eax
            //   e8????????           |                     
            //   83f812               | cmp                 eax, 0x12
            //   59                   | pop                 ecx
            //   750e                 | jne                 0x10
            //   807f0152             | cmp                 byte ptr [edi + 1], 0x52
            //   7528                 | jne                 0x2a

        $sequence_8 = { 743d eb20 57 e8???????? 83f807 59 }
            // n = 6, score = 200
            //   743d                 | je                  0x3f
            //   eb20                 | jmp                 0x22
            //   57                   | push                edi
            //   e8????????           |                     
            //   83f807               | cmp                 eax, 7
            //   59                   | pop                 ecx

        $sequence_9 = { 50 ff75fc ff55d8 85c0 0f8486000000 8d85d4feffff 56 }
            // n = 7, score = 200
            //   50                   | push                eax
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   ff55d8               | call                dword ptr [ebp - 0x28]
            //   85c0                 | test                eax, eax
            //   0f8486000000         | je                  0x8c
            //   8d85d4feffff         | lea                 eax, [ebp - 0x12c]
            //   56                   | push                esi

    condition:
        7 of them and filesize < 65536
}