rule win_kwampirs_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        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 = "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 = { b80d000000 ba02000000 f7e2 0f90c1 }
            // n = 4, score = 800
            //   b80d000000           | mov                 eax, 0xd
            //   ba02000000           | mov                 edx, 2
            //   f7e2                 | mul                 edx
            //   0f90c1               | seto                cl

        $sequence_1 = { 56 8b0f 51 e8???????? 83c418 85c0 7512 }
            // n = 7, score = 800
            //   56                   | push                esi
            //   8b0f                 | mov                 ecx, dword ptr [edi]
            //   51                   | push                ecx
            //   e8????????           |                     
            //   83c418               | add                 esp, 0x18
            //   85c0                 | test                eax, eax
            //   7512                 | jne                 0x14

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

        $sequence_3 = { 668955f4 33d2 668955f6 e8???????? 83c40c 33d2 }
            // n = 6, score = 800
            //   668955f4             | mov                 word ptr [ebp - 0xc], dx
            //   33d2                 | xor                 edx, edx
            //   668955f6             | mov                 word ptr [ebp - 0xa], dx
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   33d2                 | xor                 edx, edx

        $sequence_4 = { 8be5 5d c3 32c0 8b4df0 64890d00000000 59 }
            // n = 7, score = 800
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   32c0                 | xor                 al, al
            //   8b4df0               | mov                 ecx, dword ptr [ebp - 0x10]
            //   64890d00000000       | mov                 dword ptr fs:[0], ecx
            //   59                   | pop                 ecx

        $sequence_5 = { b827000000 ba02000000 f7e2 0f90c1 f7d9 }
            // n = 5, score = 800
            //   b827000000           | mov                 eax, 0x27
            //   ba02000000           | mov                 edx, 2
            //   f7e2                 | mul                 edx
            //   0f90c1               | seto                cl
            //   f7d9                 | neg                 ecx

        $sequence_6 = { 33c5 50 8d45f0 64a300000000 8965e8 8bf9 33db }
            // n = 7, score = 800
            //   33c5                 | xor                 eax, ebp
            //   50                   | push                eax
            //   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_7 = { 33d2 668955f6 e8???????? 83c40c 33d2 }
            // n = 5, score = 800
            //   33d2                 | xor                 edx, edx
            //   668955f6             | mov                 word ptr [ebp - 0xa], dx
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   33d2                 | xor                 edx, edx

        $sequence_8 = { c3 32c0 8b4df0 64890d00000000 59 5f 5e }
            // n = 7, score = 800
            //   c3                   | ret                 
            //   32c0                 | xor                 al, al
            //   8b4df0               | mov                 ecx, dword ptr [ebp - 0x10]
            //   64890d00000000       | mov                 dword ptr fs:[0], ecx
            //   59                   | pop                 ecx
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi

        $sequence_9 = { 56 8b0f 51 e8???????? 83c418 }
            // n = 5, score = 800
            //   56                   | push                esi
            //   8b0f                 | mov                 ecx, dword ptr [edi]
            //   51                   | push                ecx
            //   e8????????           |                     
            //   83c418               | add                 esp, 0x18

    condition:
        7 of them and filesize < 2695168
}