rule win_kwampirs_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-05-04"
        version = "1"
        description = "Detects win.kwampirs."
        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.kwampirs"
        malpedia_rule_date = "20260422"
        malpedia_hash = "a182e35da64e6d71cb55f125c4d4225196523f14"
        malpedia_version = "20260504"
        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 = { 8bec 81ec580c0000 a1???????? 33c5 8945f8 8b4508 53 }
            // n = 7, score = 800
            //   8bec                 | mov                 ebp, esp
            //   81ec580c0000         | sub                 esp, 0xc58
            //   a1????????           |                     
            //   33c5                 | xor                 eax, ebp
            //   8945f8               | mov                 dword ptr [ebp - 8], eax
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   53                   | push                ebx

        $sequence_1 = { 8d45f0 64a300000000 8965e8 8bf9 33db }
            // n = 5, score = 800
            //   8d45f0               | lea                 eax, [ebp - 0x10]
            //   64a300000000         | mov                 dword ptr fs:[0], eax
            //   8965e8               | mov                 dword ptr [ebp - 0x18], esp
            //   8bf9                 | mov                 edi, ecx
            //   33db                 | xor                 ebx, ebx

        $sequence_2 = { 81ec580c0000 a1???????? 33c5 8945f8 8b4508 }
            // n = 5, score = 800
            //   81ec580c0000         | sub                 esp, 0xc58
            //   a1????????           |                     
            //   33c5                 | xor                 eax, ebp
            //   8945f8               | mov                 dword ptr [ebp - 8], eax
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]

        $sequence_3 = { c745fcfeffffff 8b45e0 85c0 7409 50 }
            // n = 5, score = 800
            //   c745fcfeffffff       | mov                 dword ptr [ebp - 4], 0xfffffffe
            //   8b45e0               | mov                 eax, dword ptr [ebp - 0x20]
            //   85c0                 | test                eax, eax
            //   7409                 | je                  0xb
            //   50                   | push                eax

        $sequence_4 = { e8???????? b001 8b4df0 64890d00000000 59 }
            // n = 5, score = 800
            //   e8????????           |                     
            //   b001                 | mov                 al, 1
            //   8b4df0               | mov                 ecx, dword ptr [ebp - 0x10]
            //   64890d00000000       | mov                 dword ptr fs:[0], ecx
            //   59                   | pop                 ecx

        $sequence_5 = { 33c9 b80d000000 ba02000000 f7e2 }
            // n = 4, score = 800
            //   33c9                 | xor                 ecx, ecx
            //   b80d000000           | mov                 eax, 0xd
            //   ba02000000           | mov                 edx, 2
            //   f7e2                 | mul                 edx

        $sequence_6 = { 50 6a01 56 8b0f 51 e8???????? }
            // n = 6, score = 800
            //   50                   | push                eax
            //   6a01                 | push                1
            //   56                   | push                esi
            //   8b0f                 | mov                 ecx, dword ptr [edi]
            //   51                   | push                ecx
            //   e8????????           |                     

        $sequence_7 = { 6a01 56 8b0f 51 e8???????? }
            // n = 5, score = 800
            //   6a01                 | push                1
            //   56                   | push                esi
            //   8b0f                 | mov                 ecx, dword ptr [edi]
            //   51                   | push                ecx
            //   e8????????           |                     

        $sequence_8 = { c745fcfeffffff 8b45e0 85c0 7409 }
            // n = 4, score = 800
            //   c745fcfeffffff       | mov                 dword ptr [ebp - 4], 0xfffffffe
            //   8b45e0               | mov                 eax, dword ptr [ebp - 0x20]
            //   85c0                 | test                eax, eax
            //   7409                 | je                  0xb

        $sequence_9 = { 83c418 85c0 7512 8b07 }
            // n = 4, score = 800
            //   83c418               | add                 esp, 0x18
            //   85c0                 | test                eax, eax
            //   7512                 | jne                 0x14
            //   8b07                 | mov                 eax, dword ptr [edi]

    condition:
        7 of them and filesize < 2695168
}