rule win_nestegg_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.nestegg."
        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.nestegg"
        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 = { aa 8d442414 8bce 50 c744241000000000 e8???????? 8d4c240c }
            // n = 7, score = 200
            //   aa                   | stosb               byte ptr es:[edi], al
            //   8d442414             | lea                 eax, [esp + 0x14]
            //   8bce                 | mov                 ecx, esi
            //   50                   | push                eax
            //   c744241000000000     | mov                 dword ptr [esp + 0x10], 0
            //   e8????????           |                     
            //   8d4c240c             | lea                 ecx, [esp + 0xc]

        $sequence_1 = { 8bcf e8???????? 85c0 740c 8b4f08 }
            // n = 5, score = 200
            //   8bcf                 | mov                 ecx, edi
            //   e8????????           |                     
            //   85c0                 | test                eax, eax
            //   740c                 | je                  0xe
            //   8b4f08               | mov                 ecx, dword ptr [edi + 8]

        $sequence_2 = { 8d44241c 6a08 50 8bce e8???????? 8d4c2424 6a08 }
            // n = 7, score = 200
            //   8d44241c             | lea                 eax, [esp + 0x1c]
            //   6a08                 | push                8
            //   50                   | push                eax
            //   8bce                 | mov                 ecx, esi
            //   e8????????           |                     
            //   8d4c2424             | lea                 ecx, [esp + 0x24]
            //   6a08                 | push                8

        $sequence_3 = { 50 57 c784245803000000000000 896c2414 }
            // n = 4, score = 200
            //   50                   | push                eax
            //   57                   | push                edi
            //   c784245803000000000000     | mov    dword ptr [esp + 0x358], 0
            //   896c2414             | mov                 dword ptr [esp + 0x14], ebp

        $sequence_4 = { a0???????? b943000000 88842494010000 33c0 8dbc2495010000 8b542474 }
            // n = 6, score = 200
            //   a0????????           |                     
            //   b943000000           | mov                 ecx, 0x43
            //   88842494010000       | mov                 byte ptr [esp + 0x194], al
            //   33c0                 | xor                 eax, eax
            //   8dbc2495010000       | lea                 edi, [esp + 0x195]
            //   8b542474             | mov                 edx, dword ptr [esp + 0x74]

        $sequence_5 = { c20c00 8b4c240c 51 ff15???????? 5f 5e 33c0 }
            // n = 7, score = 200
            //   c20c00               | ret                 0xc
            //   8b4c240c             | mov                 ecx, dword ptr [esp + 0xc]
            //   51                   | push                ecx
            //   ff15????????         |                     
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   33c0                 | xor                 eax, eax

        $sequence_6 = { ffd6 a3???????? 8b842494000000 3bc3 740d 68???????? 50 }
            // n = 7, score = 200
            //   ffd6                 | call                esi
            //   a3????????           |                     
            //   8b842494000000       | mov                 eax, dword ptr [esp + 0x94]
            //   3bc3                 | cmp                 eax, ebx
            //   740d                 | je                  0xf
            //   68????????           |                     
            //   50                   | push                eax

        $sequence_7 = { 0bf0 8d442420 6800040000 50 e8???????? 8bd6 81f6429a0101 }
            // n = 7, score = 200
            //   0bf0                 | or                  esi, eax
            //   8d442420             | lea                 eax, [esp + 0x20]
            //   6800040000           | push                0x400
            //   50                   | push                eax
            //   e8????????           |                     
            //   8bd6                 | mov                 edx, esi
            //   81f6429a0101         | xor                 esi, 0x1019a42

        $sequence_8 = { 0f8485020000 8b0d???????? 389910030000 0f8573020000 e9???????? 83f803 7518 }
            // n = 7, score = 200
            //   0f8485020000         | je                  0x28b
            //   8b0d????????         |                     
            //   389910030000         | cmp                 byte ptr [ecx + 0x310], bl
            //   0f8573020000         | jne                 0x279
            //   e9????????           |                     
            //   83f803               | cmp                 eax, 3
            //   7518                 | jne                 0x1a

        $sequence_9 = { 8bb42414010000 8d442404 57 8d4c2410 50 51 }
            // n = 6, score = 200
            //   8bb42414010000       | mov                 esi, dword ptr [esp + 0x114]
            //   8d442404             | lea                 eax, [esp + 4]
            //   57                   | push                edi
            //   8d4c2410             | lea                 ecx, [esp + 0x10]
            //   50                   | push                eax
            //   51                   | push                ecx

    condition:
        7 of them and filesize < 221184
}