rule win_gspy_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.gspy."
        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.gspy"
        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 = { 895030 83c204 895034 8b5028 5f 8d541201 41 }
            // n = 7, score = 100
            //   895030               | mov                 dword ptr [eax + 0x30], edx
            //   83c204               | add                 edx, 4
            //   895034               | mov                 dword ptr [eax + 0x34], edx
            //   8b5028               | mov                 edx, dword ptr [eax + 0x28]
            //   5f                   | pop                 edi
            //   8d541201             | lea                 edx, [edx + edx + 1]
            //   41                   | inc                 ecx

        $sequence_1 = { 68782f0000 ff15???????? 8bc6 c744241000000000 e8???????? 8b442410 5e }
            // n = 7, score = 100
            //   68782f0000           | push                0x2f78
            //   ff15????????         |                     
            //   8bc6                 | mov                 eax, esi
            //   c744241000000000     | mov                 dword ptr [esp + 0x10], 0
            //   e8????????           |                     
            //   8b442410             | mov                 eax, dword ptr [esp + 0x10]
            //   5e                   | pop                 esi

        $sequence_2 = { 3bc8 72f1 33c9 66894c4410 8d542410 52 8d84241c020000 }
            // n = 7, score = 100
            //   3bc8                 | cmp                 ecx, eax
            //   72f1                 | jb                  0xfffffff3
            //   33c9                 | xor                 ecx, ecx
            //   66894c4410           | mov                 word ptr [esp + eax*2 + 0x10], cx
            //   8d542410             | lea                 edx, [esp + 0x10]
            //   52                   | push                edx
            //   8d84241c020000       | lea                 eax, [esp + 0x21c]

        $sequence_3 = { 8d942420020000 52 6a00 6a00 50 6a00 ffd7 }
            // n = 7, score = 100
            //   8d942420020000       | lea                 edx, [esp + 0x220]
            //   52                   | push                edx
            //   6a00                 | push                0
            //   6a00                 | push                0
            //   50                   | push                eax
            //   6a00                 | push                0
            //   ffd7                 | call                edi

        $sequence_4 = { 85c0 750f be05000000 8bc6 5e 81c41c010000 c3 }
            // n = 7, score = 100
            //   85c0                 | test                eax, eax
            //   750f                 | jne                 0x11
            //   be05000000           | mov                 esi, 5
            //   8bc6                 | mov                 eax, esi
            //   5e                   | pop                 esi
            //   81c41c010000         | add                 esp, 0x11c
            //   c3                   | ret                 

        $sequence_5 = { 756d f60720 7415 8b442410 50 ff15???????? }
            // n = 6, score = 100
            //   756d                 | jne                 0x6f
            //   f60720               | test                byte ptr [edi], 0x20
            //   7415                 | je                  0x17
            //   8b442410             | mov                 eax, dword ptr [esp + 0x10]
            //   50                   | push                eax
            //   ff15????????         |                     

        $sequence_6 = { 56 33c0 6a44 50 8d4c2434 51 668944241c }
            // n = 7, score = 100
            //   56                   | push                esi
            //   33c0                 | xor                 eax, eax
            //   6a44                 | push                0x44
            //   50                   | push                eax
            //   8d4c2434             | lea                 ecx, [esp + 0x34]
            //   51                   | push                ecx
            //   668944241c           | mov                 word ptr [esp + 0x1c], ax

        $sequence_7 = { 8d4c2420 51 ffd7 85c0 75d8 8b542430 68ff040000 }
            // n = 7, score = 100
            //   8d4c2420             | lea                 ecx, [esp + 0x20]
            //   51                   | push                ecx
            //   ffd7                 | call                edi
            //   85c0                 | test                eax, eax
            //   75d8                 | jne                 0xffffffda
            //   8b542430             | mov                 edx, dword ptr [esp + 0x30]
            //   68ff040000           | push                0x4ff

        $sequence_8 = { 6a20 6a00 6a08 6a00 46 56 e8???????? }
            // n = 7, score = 100
            //   6a20                 | push                0x20
            //   6a00                 | push                0
            //   6a08                 | push                8
            //   6a00                 | push                0
            //   46                   | inc                 esi
            //   56                   | push                esi
            //   e8????????           |                     

        $sequence_9 = { e8???????? 89442418 8b4714 8d5004 395710 7216 8b4f18 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   89442418             | mov                 dword ptr [esp + 0x18], eax
            //   8b4714               | mov                 eax, dword ptr [edi + 0x14]
            //   8d5004               | lea                 edx, [eax + 4]
            //   395710               | cmp                 dword ptr [edi + 0x10], edx
            //   7216                 | jb                  0x18
            //   8b4f18               | mov                 ecx, dword ptr [edi + 0x18]

    condition:
        7 of them and filesize < 421888
}