rule win_kerrdown_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.kerrdown."
        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.kerrdown"
        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 = { c0e206 c0e902 80e10f 02c8 8a45eb 243f 884de5 }
            // n = 7, score = 200
            //   c0e206               | shl                 dl, 6
            //   c0e902               | shr                 cl, 2
            //   80e10f               | and                 cl, 0xf
            //   02c8                 | add                 cl, al
            //   8a45eb               | mov                 al, byte ptr [ebp - 0x15]
            //   243f                 | and                 al, 0x3f
            //   884de5               | mov                 byte ptr [ebp - 0x1b], cl

        $sequence_1 = { c60100 b9???????? c745fc00000000 c745d801000000 894de0 0f1f4000 }
            // n = 6, score = 200
            //   c60100               | mov                 byte ptr [ecx], 0
            //   b9????????           |                     
            //   c745fc00000000       | mov                 dword ptr [ebp - 4], 0
            //   c745d801000000       | mov                 dword ptr [ebp - 0x28], 1
            //   894de0               | mov                 dword ptr [ebp - 0x20], ecx
            //   0f1f4000             | nop                 dword ptr [eax]

        $sequence_2 = { 8b3d???????? 83c40c 8b0d???????? 83ff10 8935???????? b8???????? 0f43c1 }
            // n = 7, score = 200
            //   8b3d????????         |                     
            //   83c40c               | add                 esp, 0xc
            //   8b0d????????         |                     
            //   83ff10               | cmp                 edi, 0x10
            //   8935????????         |                     
            //   b8????????           |                     
            //   0f43c1               | cmovae              eax, ecx

        $sequence_3 = { 0f1f4000 8a19 48 8945dc 80fb3d }
            // n = 5, score = 200
            //   0f1f4000             | nop                 dword ptr [eax]
            //   8a19                 | mov                 bl, byte ptr [ecx]
            //   48                   | dec                 eax
            //   8945dc               | mov                 dword ptr [ebp - 0x24], eax
            //   80fb3d               | cmp                 bl, 0x3d

        $sequence_4 = { c747140f000000 b8cd220000 837f1410 897dd4 897710 }
            // n = 5, score = 200
            //   c747140f000000       | mov                 dword ptr [edi + 0x14], 0xf
            //   b8cd220000           | mov                 eax, 0x22cd
            //   837f1410             | cmp                 dword ptr [edi + 0x14], 0x10
            //   897dd4               | mov                 dword ptr [ebp - 0x2c], edi
            //   897710               | mov                 dword ptr [edi + 0x10], esi

        $sequence_5 = { ff7518 6a00 ff15???????? 837d1c10 8d4d08 ff7518 0f434d08 }
            // n = 7, score = 200
            //   ff7518               | push                dword ptr [ebp + 0x18]
            //   6a00                 | push                0
            //   ff15????????         |                     
            //   837d1c10             | cmp                 dword ptr [ebp + 0x1c], 0x10
            //   8d4d08               | lea                 ecx, [ebp + 8]
            //   ff7518               | push                dword ptr [ebp + 0x18]
            //   0f434d08             | cmovae              ecx, dword ptr [ebp + 8]

        $sequence_6 = { 68???????? 66a5 ff15???????? 5f 85c0 }
            // n = 5, score = 200
            //   68????????           |                     
            //   66a5                 | movsw               word ptr es:[edi], word ptr [esi]
            //   ff15????????         |                     
            //   5f                   | pop                 edi
            //   85c0                 | test                eax, eax

        $sequence_7 = { e8???????? 43 3bde 7ced 8bc7 8b4df4 64890d00000000 }
            // n = 7, score = 200
            //   e8????????           |                     
            //   43                   | inc                 ebx
            //   3bde                 | cmp                 ebx, esi
            //   7ced                 | jl                  0xffffffef
            //   8bc7                 | mov                 eax, edi
            //   8b4df4               | mov                 ecx, dword ptr [ebp - 0xc]
            //   64890d00000000       | mov                 dword ptr fs:[0], ecx

        $sequence_8 = { 85c0 7543 50 6880000000 6a04 50 6a01 }
            // n = 7, score = 200
            //   85c0                 | test                eax, eax
            //   7543                 | jne                 0x45
            //   50                   | push                eax
            //   6880000000           | push                0x80
            //   6a04                 | push                4
            //   50                   | push                eax
            //   6a01                 | push                1

        $sequence_9 = { 83e4f8 83ec20 a1???????? 33c4 8944241c 6807800000 ff15???????? }
            // n = 7, score = 200
            //   83e4f8               | and                 esp, 0xfffffff8
            //   83ec20               | sub                 esp, 0x20
            //   a1????????           |                     
            //   33c4                 | xor                 eax, esp
            //   8944241c             | mov                 dword ptr [esp + 0x1c], eax
            //   6807800000           | push                0x8007
            //   ff15????????         |                     

    condition:
        7 of them and filesize < 278528
}