rule win_kk_rat_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.kk_rat."
        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.kk_rat"
        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 = { 8b4e34 e8???????? 0fb7f8 6685ff 7504 32c0 eb3a }
            // n = 7, score = 100
            //   8b4e34               | mov                 ecx, dword ptr [esi + 0x34]
            //   e8????????           |                     
            //   0fb7f8               | movzx               edi, ax
            //   6685ff               | test                di, di
            //   7504                 | jne                 6
            //   32c0                 | xor                 al, al
            //   eb3a                 | jmp                 0x3c

        $sequence_1 = { c785d0fbffff78db1210 8d85ecfbffff 8985ccfbffff 85db 7508 219dc4fbffff }
            // n = 6, score = 100
            //   c785d0fbffff78db1210     | mov    dword ptr [ebp - 0x430], 0x1012db78
            //   8d85ecfbffff         | lea                 eax, [ebp - 0x414]
            //   8985ccfbffff         | mov                 dword ptr [ebp - 0x434], eax
            //   85db                 | test                ebx, ebx
            //   7508                 | jne                 0xa
            //   219dc4fbffff         | and                 dword ptr [ebp - 0x43c], ebx

        $sequence_2 = { 89465c 8b471c 8b5814 8b4f10 83c408 3bd9 7602 }
            // n = 7, score = 100
            //   89465c               | mov                 dword ptr [esi + 0x5c], eax
            //   8b471c               | mov                 eax, dword ptr [edi + 0x1c]
            //   8b5814               | mov                 ebx, dword ptr [eax + 0x14]
            //   8b4f10               | mov                 ecx, dword ptr [edi + 0x10]
            //   83c408               | add                 esp, 8
            //   3bd9                 | cmp                 ebx, ecx
            //   7602                 | jbe                 4

        $sequence_3 = { 8b08 50 ff5128 8b45d8 8b08 50 }
            // n = 6, score = 100
            //   8b08                 | mov                 ecx, dword ptr [eax]
            //   50                   | push                eax
            //   ff5128               | call                dword ptr [ecx + 0x28]
            //   8b45d8               | mov                 eax, dword ptr [ebp - 0x28]
            //   8b08                 | mov                 ecx, dword ptr [eax]
            //   50                   | push                eax

        $sequence_4 = { 7404 b001 eb02 32c0 8b4e08 83e101 5f }
            // n = 7, score = 100
            //   7404                 | je                  6
            //   b001                 | mov                 al, 1
            //   eb02                 | jmp                 4
            //   32c0                 | xor                 al, al
            //   8b4e08               | mov                 ecx, dword ptr [esi + 8]
            //   83e101               | and                 ecx, 1
            //   5f                   | pop                 edi

        $sequence_5 = { 751c e8???????? eb15 8b550c 4a 52 }
            // n = 6, score = 100
            //   751c                 | jne                 0x1e
            //   e8????????           |                     
            //   eb15                 | jmp                 0x17
            //   8b550c               | mov                 edx, dword ptr [ebp + 0xc]
            //   4a                   | dec                 edx
            //   52                   | push                edx

        $sequence_6 = { 8d45bc c745cc34ae1310 8945d0 ff7528 8b45d4 ff7524 8945a4 }
            // n = 7, score = 100
            //   8d45bc               | lea                 eax, [ebp - 0x44]
            //   c745cc34ae1310       | mov                 dword ptr [ebp - 0x34], 0x1013ae34
            //   8945d0               | mov                 dword ptr [ebp - 0x30], eax
            //   ff7528               | push                dword ptr [ebp + 0x28]
            //   8b45d4               | mov                 eax, dword ptr [ebp - 0x2c]
            //   ff7524               | push                dword ptr [ebp + 0x24]
            //   8945a4               | mov                 dword ptr [ebp - 0x5c], eax

        $sequence_7 = { 83c43c 5f 5e 33c0 5d c3 55 }
            // n = 7, score = 100
            //   83c43c               | add                 esp, 0x3c
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   33c0                 | xor                 eax, eax
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   55                   | push                ebp

        $sequence_8 = { 57 bb03010000 53 8d85f5fdffff 6a00 50 c685f4fdffff00 }
            // n = 7, score = 100
            //   57                   | push                edi
            //   bb03010000           | mov                 ebx, 0x103
            //   53                   | push                ebx
            //   8d85f5fdffff         | lea                 eax, [ebp - 0x20b]
            //   6a00                 | push                0
            //   50                   | push                eax
            //   c685f4fdffff00       | mov                 byte ptr [ebp - 0x20c], 0

        $sequence_9 = { 8bec 83ec20 33c0 8b0cc5d09b1710 3b4d0c 7464 }
            // n = 6, score = 100
            //   8bec                 | mov                 ebp, esp
            //   83ec20               | sub                 esp, 0x20
            //   33c0                 | xor                 eax, eax
            //   8b0cc5d09b1710       | mov                 ecx, dword ptr [eax*8 + 0x10179bd0]
            //   3b4d0c               | cmp                 ecx, dword ptr [ebp + 0xc]
            //   7464                 | je                  0x66

    condition:
        7 of them and filesize < 3516416
}