rule win_nefilim_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.nefilim."
        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.nefilim"
        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 = { 8810 40 49 75f7 8b4dfc 5f 33cd }
            // n = 7, score = 200
            //   8810                 | mov                 byte ptr [eax], dl
            //   40                   | inc                 eax
            //   49                   | dec                 ecx
            //   75f7                 | jne                 0xfffffff9
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   5f                   | pop                 edi
            //   33cd                 | xor                 ecx, ebp

        $sequence_1 = { 83c420 ff15???????? 833d????????04 7e1c }
            // n = 4, score = 200
            //   83c420               | add                 esp, 0x20
            //   ff15????????         |                     
            //   833d????????04       |                     
            //   7e1c                 | jle                 0x1e

        $sequence_2 = { 8d442414 68???????? 50 ffd6 85c0 0f84ae010000 8b442414 }
            // n = 7, score = 200
            //   8d442414             | lea                 eax, [esp + 0x14]
            //   68????????           |                     
            //   50                   | push                eax
            //   ffd6                 | call                esi
            //   85c0                 | test                eax, eax
            //   0f84ae010000         | je                  0x1b4
            //   8b442414             | mov                 eax, dword ptr [esp + 0x14]

        $sequence_3 = { c1e606 033485a0f94000 8b45f8 8b00 8906 }
            // n = 5, score = 200
            //   c1e606               | shl                 esi, 6
            //   033485a0f94000       | add                 esi, dword ptr [eax*4 + 0x40f9a0]
            //   8b45f8               | mov                 eax, dword ptr [ebp - 8]
            //   8b00                 | mov                 eax, dword ptr [eax]
            //   8906                 | mov                 dword ptr [esi], eax

        $sequence_4 = { 33ff 8d742418 e8???????? 6a01 }
            // n = 4, score = 200
            //   33ff                 | xor                 edi, edi
            //   8d742418             | lea                 esi, [esp + 0x18]
            //   e8????????           |                     
            //   6a01                 | push                1

        $sequence_5 = { 50 ffd6 85c0 0f84cf020000 f68424a000000010 8d8424cc000000 }
            // n = 6, score = 200
            //   50                   | push                eax
            //   ffd6                 | call                esi
            //   85c0                 | test                eax, eax
            //   0f84cf020000         | je                  0x2d5
            //   f68424a000000010     | test                byte ptr [esp + 0xa0], 0x10
            //   8d8424cc000000       | lea                 eax, [esp + 0xcc]

        $sequence_6 = { 50 ff35???????? ff35???????? ff74241c ff15???????? 8b44241c 8b4c2418 }
            // n = 7, score = 200
            //   50                   | push                eax
            //   ff35????????         |                     
            //   ff35????????         |                     
            //   ff74241c             | push                dword ptr [esp + 0x1c]
            //   ff15????????         |                     
            //   8b44241c             | mov                 eax, dword ptr [esp + 0x1c]
            //   8b4c2418             | mov                 ecx, dword ptr [esp + 0x18]

        $sequence_7 = { e8???????? 83c41c e9???????? e8???????? 8bd8 59 }
            // n = 6, score = 200
            //   e8????????           |                     
            //   83c41c               | add                 esp, 0x1c
            //   e9????????           |                     
            //   e8????????           |                     
            //   8bd8                 | mov                 ebx, eax
            //   59                   | pop                 ecx

        $sequence_8 = { 66890c453cf94000 40 ebe8 33c0 8945e4 }
            // n = 5, score = 200
            //   66890c453cf94000     | mov                 word ptr [eax*2 + 0x40f93c], cx
            //   40                   | inc                 eax
            //   ebe8                 | jmp                 0xffffffea
            //   33c0                 | xor                 eax, eax
            //   8945e4               | mov                 dword ptr [ebp - 0x1c], eax

        $sequence_9 = { ff74242c 8944242c e8???????? ff74242c e8???????? be00010000 56 }
            // n = 7, score = 200
            //   ff74242c             | push                dword ptr [esp + 0x2c]
            //   8944242c             | mov                 dword ptr [esp + 0x2c], eax
            //   e8????????           |                     
            //   ff74242c             | push                dword ptr [esp + 0x2c]
            //   e8????????           |                     
            //   be00010000           | mov                 esi, 0x100
            //   56                   | push                esi

    condition:
        7 of them and filesize < 142336
}