rule win_karsto_rat_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.karsto_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.karsto_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 = { 8bca 83e207 48c1e903 420fb60401 0fabd0 42880401 488bcb }
            // n = 7, score = 100
            //   8bca                 | inc                 edx
            //   83e207               | cmp                 byte ptr [ecx + eax + 0x1e3d0], al
            //   48c1e903             | mov                 dword ptr [esp + 0x40], eax
            //   420fb60401           | inc                 ecx
            //   0fabd0               | mov                 eax, dword ptr [esp + 0xbc]
            //   42880401             | bt                  eax, 8
            //   488bcb               | jb                  0x1ce

        $sequence_1 = { 7603 488b36 4d8d442401 488bd6 4b8d0c3e e8???????? 488b5c2478 }
            // n = 7, score = 100
            //   7603                 | dec                 eax
            //   488b36               | lea                 edi, [ebp + 0x298]
            //   4d8d442401           | dec                 eax
            //   488bd6               | cmp                 edx, 0xf
            //   4b8d0c3e             | dec                 eax
            //   e8????????           |                     
            //   488b5c2478           | cmova               edi, ecx

        $sequence_2 = { 7407 4188442409 eb04 4d892c24 41c644240801 498b0424 4885db }
            // n = 7, score = 100
            //   7407                 | lea                 eax, [esi + edi]
            //   4188442409           | dec                 eax
            //   eb04                 | and                 eax, 0xffffffe0
            //   4d892c24             | dec                 eax
            //   41c644240801         | cmp                 eax, 0x40
            //   498b0424             | jl                  0x711
            //   4885db               | movups              xmm0, xmmword ptr [edi]

        $sequence_3 = { 483bce 741c ff15???????? 488b06 48634804 4803ce ff15???????? }
            // n = 7, score = 100
            //   483bce               | mov                 ecx, eax
            //   741c                 | dec                 eax
            //   ff15????????         |                     
            //   488b06               | mov                 ebp, dword ptr [esp + 0x40]
            //   48634804             | dec                 eax
            //   4803ce               | sub                 ecx, eax
            //   ff15????????         |                     

        $sequence_4 = { 458801 448bc2 85d2 75d6 4c8d85cd040000 498bd1 488d4dc0 }
            // n = 7, score = 100
            //   458801               | xor                 edx, edx
            //   448bc2               | dec                 eax
            //   85d2                 | mov                 ecx, esi
            //   75d6                 | dec                 ebp
            //   4c8d85cd040000       | test                ecx, ecx
            //   498bd1               | je                  0x6bd
            //   488d4dc0             | inc                 ebp

        $sequence_5 = { 488d4c2460 e8???????? 0f1000 0f11442440 0f104810 0f114c2450 4c896810 }
            // n = 7, score = 100
            //   488d4c2460           | dec                 eax
            //   e8????????           |                     
            //   0f1000               | cmp                 eax, ebx
            //   0f11442440           | je                  0x84
            //   0f104810             | dec                 eax
            //   0f114c2450           | mov                 edx, dword ptr [ebx]
            //   4c896810             | dec                 esp

        $sequence_6 = { 760b 4c8bf7 4d2bf7 eb03 4d8bf4 49ffc0 488d4f1c }
            // n = 7, score = 100
            //   760b                 | mov                 eax, 0x104
            //   4c8bf7               | dec                 eax
            //   4d2bf7               | lea                 edx, [esp + 0x40]
            //   eb03                 | xor                 ecx, ecx
            //   4d8bf4               | jne                 0x6d4
            //   49ffc0               | jne                 0x6d6
            //   488d4f1c             | dec                 esp

        $sequence_7 = { 4c8d442440 48837c24580f 4c0f47442440 448b4c2450 498bd4 }
            // n = 5, score = 100
            //   4c8d442440           | lea                 eax, [ebp + 0x660]
            //   48837c24580f         | dec                 ecx
            //   4c0f47442440         | mov                 eax, 0xffffffff
            //   448b4c2450           | nop                 dword ptr [eax]
            //   498bd4               | dec                 esp

        $sequence_8 = { 488b550f 4c2bc2 49c1f804 e8???????? b301 488d4d0f e8???????? }
            // n = 7, score = 100
            //   488b550f             | mov                 eax, dword ptr [esi + 0x18]
            //   4c2bc2               | dec                 ecx
            //   49c1f804             | mov                 dword ptr [esp + 0x18], eax
            //   e8????????           |                     
            //   b301                 | dec                 esp
            //   488d4d0f             | mov                 dword ptr [esi + 0x18], esp
            //   e8????????           |                     

        $sequence_9 = { 7409 80f97d 0f8577010000 884378 0fbec0 89437c }
            // n = 6, score = 100
            //   7409                 | dec                 eax
            //   80f97d               | mov                 ecx, dword ptr [ebx + 0x58]
            //   0f8577010000         | jae                 0xe8
            //   884378               | cmp                 byte ptr [ebx + 0x78], 0x5c
            //   0fbec0               | jne                 0xe8
            //   89437c               | dec                 esp

    condition:
        7 of them and filesize < 336896
}