rule win_pykspa_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.pykspa."
        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.pykspa"
        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 = { 59 85f6 744b 85db 7517 8b0d???????? 69c9e8030000 }
            // n = 7, score = 100
            //   59                   | pop                 ecx
            //   85f6                 | test                esi, esi
            //   744b                 | je                  0x4d
            //   85db                 | test                ebx, ebx
            //   7517                 | jne                 0x19
            //   8b0d????????         |                     
            //   69c9e8030000         | imul                ecx, ecx, 0x3e8

        $sequence_1 = { 6a00 6a00 89b5e4feffff 899de0feffff ff15???????? 56 8bd8 }
            // n = 7, score = 100
            //   6a00                 | push                0
            //   6a00                 | push                0
            //   89b5e4feffff         | mov                 dword ptr [ebp - 0x11c], esi
            //   899de0feffff         | mov                 dword ptr [ebp - 0x120], ebx
            //   ff15????????         |                     
            //   56                   | push                esi
            //   8bd8                 | mov                 ebx, eax

        $sequence_2 = { 741e 56 8bc7 53 8bf9 e8???????? 59 }
            // n = 7, score = 100
            //   741e                 | je                  0x20
            //   56                   | push                esi
            //   8bc7                 | mov                 eax, edi
            //   53                   | push                ebx
            //   8bf9                 | mov                 edi, ecx
            //   e8????????           |                     
            //   59                   | pop                 ecx

        $sequence_3 = { 53 ffd6 807d1400 740c 68???????? 53 ff15???????? }
            // n = 7, score = 100
            //   53                   | push                ebx
            //   ffd6                 | call                esi
            //   807d1400             | cmp                 byte ptr [ebp + 0x14], 0
            //   740c                 | je                  0xe
            //   68????????           |                     
            //   53                   | push                ebx
            //   ff15????????         |                     

        $sequence_4 = { 80f95c 7405 80f92f 7505 8bf0 c60600 8b3d???????? }
            // n = 7, score = 100
            //   80f95c               | cmp                 cl, 0x5c
            //   7405                 | je                  7
            //   80f92f               | cmp                 cl, 0x2f
            //   7505                 | jne                 7
            //   8bf0                 | mov                 esi, eax
            //   c60600               | mov                 byte ptr [esi], 0
            //   8b3d????????         |                     

        $sequence_5 = { c9 c3 8b44240c 56 8b742408 ff74240c 03c6 }
            // n = 7, score = 100
            //   c9                   | leave               
            //   c3                   | ret                 
            //   8b44240c             | mov                 eax, dword ptr [esp + 0xc]
            //   56                   | push                esi
            //   8b742408             | mov                 esi, dword ptr [esp + 8]
            //   ff74240c             | push                dword ptr [esp + 0xc]
            //   03c6                 | add                 eax, esi

        $sequence_6 = { c78594faffff24000000 c78598faffff21000000 89959cfaffff c785a0faffff23000000 c785a4faffff22000000 }
            // n = 5, score = 100
            //   c78594faffff24000000     | mov    dword ptr [ebp - 0x56c], 0x24
            //   c78598faffff21000000     | mov    dword ptr [ebp - 0x568], 0x21
            //   89959cfaffff         | mov                 dword ptr [ebp - 0x564], edx
            //   c785a0faffff23000000     | mov    dword ptr [ebp - 0x560], 0x23
            //   c785a4faffff22000000     | mov    dword ptr [ebp - 0x55c], 0x22

        $sequence_7 = { 3bd7 8910 8b7104 1bd2 f7da 03f2 3bf2 }
            // n = 7, score = 100
            //   3bd7                 | cmp                 edx, edi
            //   8910                 | mov                 dword ptr [eax], edx
            //   8b7104               | mov                 esi, dword ptr [ecx + 4]
            //   1bd2                 | sbb                 edx, edx
            //   f7da                 | neg                 edx
            //   03f2                 | add                 esi, edx
            //   3bf2                 | cmp                 esi, edx

        $sequence_8 = { 68???????? 57 ffd6 85c0 750d ff75fa ff7510 }
            // n = 7, score = 100
            //   68????????           |                     
            //   57                   | push                edi
            //   ffd6                 | call                esi
            //   85c0                 | test                eax, eax
            //   750d                 | jne                 0xf
            //   ff75fa               | push                dword ptr [ebp - 6]
            //   ff7510               | push                dword ptr [ebp + 0x10]

        $sequence_9 = { 8b750c 83c410 ff7508 56 ff15???????? }
            // n = 5, score = 100
            //   8b750c               | mov                 esi, dword ptr [ebp + 0xc]
            //   83c410               | add                 esp, 0x10
            //   ff7508               | push                dword ptr [ebp + 8]
            //   56                   | push                esi
            //   ff15????????         |                     

    condition:
        7 of them and filesize < 835584
}