rule win_squirrelwaffle_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.squirrelwaffle."
        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.squirrelwaffle"
        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 = { 83fa10 722f 8b8dc8fdfeff 42 8bc1 }
            // n = 5, score = 700
            //   83fa10               | cmp                 edx, 0x10
            //   722f                 | jb                  0x31
            //   8b8dc8fdfeff         | mov                 ecx, dword ptr [ebp - 0x10238]
            //   42                   | inc                 edx
            //   8bc1                 | mov                 eax, ecx

        $sequence_1 = { 6a08 e8???????? e9???????? b301 83fe10 }
            // n = 5, score = 700
            //   6a08                 | push                8
            //   e8????????           |                     
            //   e9????????           |                     
            //   b301                 | mov                 bl, 1
            //   83fe10               | cmp                 esi, 0x10

        $sequence_2 = { c645d800 e8???????? c745fc00000000 8b75ec 8b7dd8 83fe10 }
            // n = 6, score = 700
            //   c645d800             | mov                 byte ptr [ebp - 0x28], 0
            //   e8????????           |                     
            //   c745fc00000000       | mov                 dword ptr [ebp - 4], 0
            //   8b75ec               | mov                 esi, dword ptr [ebp - 0x14]
            //   8b7dd8               | mov                 edi, dword ptr [ebp - 0x28]
            //   83fe10               | cmp                 esi, 0x10

        $sequence_3 = { 837e1410 8bc6 7202 8b06 8d8d84f7ffff 51 }
            // n = 6, score = 700
            //   837e1410             | cmp                 dword ptr [esi + 0x14], 0x10
            //   8bc6                 | mov                 eax, esi
            //   7202                 | jb                  4
            //   8b06                 | mov                 eax, dword ptr [esi]
            //   8d8d84f7ffff         | lea                 ecx, [ebp - 0x87c]
            //   51                   | push                ecx

        $sequence_4 = { 8bce ff5004 8b75e4 8935???????? 8d4dec ff15???????? }
            // n = 6, score = 700
            //   8bce                 | mov                 ecx, esi
            //   ff5004               | call                dword ptr [eax + 4]
            //   8b75e4               | mov                 esi, dword ptr [ebp - 0x1c]
            //   8935????????         |                     
            //   8d4dec               | lea                 ecx, [ebp - 0x14]
            //   ff15????????         |                     

        $sequence_5 = { 8d8da0f9ffff 83c801 89857cf7ffff e8???????? }
            // n = 4, score = 700
            //   8d8da0f9ffff         | lea                 ecx, [ebp - 0x660]
            //   83c801               | or                  eax, 1
            //   89857cf7ffff         | mov                 dword ptr [ebp - 0x884], eax
            //   e8????????           |                     

        $sequence_6 = { 2bc8 b8ffffff7f 2b45f8 3bc1 0f8255010000 8bfb 83cf0f }
            // n = 7, score = 700
            //   2bc8                 | sub                 ecx, eax
            //   b8ffffff7f           | mov                 eax, 0x7fffffff
            //   2b45f8               | sub                 eax, dword ptr [ebp - 8]
            //   3bc1                 | cmp                 eax, ecx
            //   0f8255010000         | jb                  0x15b
            //   8bfb                 | mov                 edi, ebx
            //   83cf0f               | or                  edi, 0xf

        $sequence_7 = { 837b1410 7202 8b1b 3bd0 772a 8d0411 894710 }
            // n = 7, score = 700
            //   837b1410             | cmp                 dword ptr [ebx + 0x14], 0x10
            //   7202                 | jb                  4
            //   8b1b                 | mov                 ebx, dword ptr [ebx]
            //   3bd0                 | cmp                 edx, eax
            //   772a                 | ja                  0x2c
            //   8d0411               | lea                 eax, [ecx + edx]
            //   894710               | mov                 dword ptr [edi + 0x10], eax

        $sequence_8 = { 8d8d40ffffff 6a02 50 e8???????? 837d3410 8d5520 }
            // n = 6, score = 700
            //   8d8d40ffffff         | lea                 ecx, [ebp - 0xc0]
            //   6a02                 | push                2
            //   50                   | push                eax
            //   e8????????           |                     
            //   837d3410             | cmp                 dword ptr [ebp + 0x34], 0x10
            //   8d5520               | lea                 edx, [ebp + 0x20]

        $sequence_9 = { 83c802 50 51 ff15???????? 8bd8 83c40c 85db }
            // n = 7, score = 700
            //   83c802               | or                  eax, 2
            //   50                   | push                eax
            //   51                   | push                ecx
            //   ff15????????         |                     
            //   8bd8                 | mov                 ebx, eax
            //   83c40c               | add                 esp, 0xc
            //   85db                 | test                ebx, ebx

    condition:
        7 of them and filesize < 147456
}