rule win_disk_knight_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.disk_knight."
        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.disk_knight"
        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 = { 7407 b901000000 eb02 33c9 d903 d89d54ffffff dfe0 }
            // n = 7, score = 100
            //   7407                 | je                  9
            //   b901000000           | mov                 ecx, 1
            //   eb02                 | jmp                 4
            //   33c9                 | xor                 ecx, ecx
            //   d903                 | fld                 dword ptr [ebx]
            //   d89d54ffffff         | fcomp               dword ptr [ebp - 0xac]
            //   dfe0                 | fnstsw              ax

        $sequence_1 = { 8b55d0 894808 8b4d84 89500c 8b45ac 50 }
            // n = 6, score = 100
            //   8b55d0               | mov                 edx, dword ptr [ebp - 0x30]
            //   894808               | mov                 dword ptr [eax + 8], ecx
            //   8b4d84               | mov                 ecx, dword ptr [ebp - 0x7c]
            //   89500c               | mov                 dword ptr [eax + 0xc], edx
            //   8b45ac               | mov                 eax, dword ptr [ebp - 0x54]
            //   50                   | push                eax

        $sequence_2 = { c785c0fdffff00000000 8b4da8 898dc8feffff 8d55d8 52 }
            // n = 5, score = 100
            //   c785c0fdffff00000000     | mov    dword ptr [ebp - 0x240], 0
            //   8b4da8               | mov                 ecx, dword ptr [ebp - 0x58]
            //   898dc8feffff         | mov                 dword ptr [ebp - 0x138], ecx
            //   8d55d8               | lea                 edx, [ebp - 0x28]
            //   52                   | push                edx

        $sequence_3 = { 50 8d559c 52 ff15???????? 83ec10 8bc4 8930 }
            // n = 7, score = 100
            //   50                   | push                eax
            //   8d559c               | lea                 edx, [ebp - 0x64]
            //   52                   | push                edx
            //   ff15????????         |                     
            //   83ec10               | sub                 esp, 0x10
            //   8bc4                 | mov                 eax, esp
            //   8930                 | mov                 dword ptr [eax], esi

        $sequence_4 = { 6685ff 0f84cd010000 833b00 750c 53 68???????? ff15???????? }
            // n = 7, score = 100
            //   6685ff               | test                di, di
            //   0f84cd010000         | je                  0x1d3
            //   833b00               | cmp                 dword ptr [ebx], 0
            //   750c                 | jne                 0xe
            //   53                   | push                ebx
            //   68????????           |                     
            //   ff15????????         |                     

        $sequence_5 = { 8b45c0 6aff 50 8bf0 8b08 ff516c 3bc3 }
            // n = 7, score = 100
            //   8b45c0               | mov                 eax, dword ptr [ebp - 0x40]
            //   6aff                 | push                -1
            //   50                   | push                eax
            //   8bf0                 | mov                 esi, eax
            //   8b08                 | mov                 ecx, dword ptr [eax]
            //   ff516c               | call                dword ptr [ecx + 0x6c]
            //   3bc3                 | cmp                 eax, ebx

        $sequence_6 = { 52 57 702d 56 894c2424 e8???????? }
            // n = 6, score = 100
            //   52                   | push                edx
            //   57                   | push                edi
            //   702d                 | jo                  0x2f
            //   56                   | push                esi
            //   894c2424             | mov                 dword ptr [esp + 0x24], ecx
            //   e8????????           |                     

        $sequence_7 = { b925000000 8d7c240c f3ab 8d8424a0000000 8d4c240c 50 51 }
            // n = 7, score = 100
            //   b925000000           | mov                 ecx, 0x25
            //   8d7c240c             | lea                 edi, [esp + 0xc]
            //   f3ab                 | rep stosd           dword ptr es:[edi], eax
            //   8d8424a0000000       | lea                 eax, [esp + 0xa0]
            //   8d4c240c             | lea                 ecx, [esp + 0xc]
            //   50                   | push                eax
            //   51                   | push                ecx

        $sequence_8 = { 8b95c4feffff 33c9 83fa02 8d55a0 0f94c1 f7d9 668bf1 }
            // n = 7, score = 100
            //   8b95c4feffff         | mov                 edx, dword ptr [ebp - 0x13c]
            //   33c9                 | xor                 ecx, ecx
            //   83fa02               | cmp                 edx, 2
            //   8d55a0               | lea                 edx, [ebp - 0x60]
            //   0f94c1               | sete                cl
            //   f7d9                 | neg                 ecx
            //   668bf1               | mov                 si, cx

        $sequence_9 = { 8b45b4 50 57 ff15???????? 8d4db4 ff15???????? 8b4d14 }
            // n = 7, score = 100
            //   8b45b4               | mov                 eax, dword ptr [ebp - 0x4c]
            //   50                   | push                eax
            //   57                   | push                edi
            //   ff15????????         |                     
            //   8d4db4               | lea                 ecx, [ebp - 0x4c]
            //   ff15????????         |                     
            //   8b4d14               | mov                 ecx, dword ptr [ebp + 0x14]

    condition:
        7 of them and filesize < 868352
}