rule win_mespinoza_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.mespinoza."
        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.mespinoza"
        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 = { ff75ec c645fc05 57 ff7518 ff75f0 53 }
            // n = 6, score = 200
            //   ff75ec               | push                dword ptr [ebp - 0x14]
            //   c645fc05             | mov                 byte ptr [ebp - 4], 5
            //   57                   | push                edi
            //   ff7518               | push                dword ptr [ebp + 0x18]
            //   ff75f0               | push                dword ptr [ebp - 0x10]
            //   53                   | push                ebx

        $sequence_1 = { c745640c000000 e8???????? 8d4d4c c745fc09000000 51 50 8d45dc }
            // n = 7, score = 200
            //   c745640c000000       | mov                 dword ptr [ebp + 0x64], 0xc
            //   e8????????           |                     
            //   8d4d4c               | lea                 ecx, [ebp + 0x4c]
            //   c745fc09000000       | mov                 dword ptr [ebp - 4], 9
            //   51                   | push                ecx
            //   50                   | push                eax
            //   8d45dc               | lea                 eax, [ebp - 0x24]

        $sequence_2 = { 3bd0 0f8c32010000 8b85bcebffff 7f08 3bc7 0f8620010000 8bbdc4ebffff }
            // n = 7, score = 200
            //   3bd0                 | cmp                 edx, eax
            //   0f8c32010000         | jl                  0x138
            //   8b85bcebffff         | mov                 eax, dword ptr [ebp - 0x1444]
            //   7f08                 | jg                  0xa
            //   3bc7                 | cmp                 eax, edi
            //   0f8620010000         | jbe                 0x126
            //   8bbdc4ebffff         | mov                 edi, dword ptr [ebp - 0x143c]

        $sequence_3 = { 0f8620010000 8bbdc4ebffff 85c9 0f88f5000000 8bc1 99 8985c4ebffff }
            // n = 7, score = 200
            //   0f8620010000         | jbe                 0x126
            //   8bbdc4ebffff         | mov                 edi, dword ptr [ebp - 0x143c]
            //   85c9                 | test                ecx, ecx
            //   0f88f5000000         | js                  0xfb
            //   8bc1                 | mov                 eax, ecx
            //   99                   | cdq                 
            //   8985c4ebffff         | mov                 dword ptr [ebp - 0x143c], eax

        $sequence_4 = { e8???????? c6451700 eb47 85d2 741f 8b07 8d4d9c }
            // n = 7, score = 200
            //   e8????????           |                     
            //   c6451700             | mov                 byte ptr [ebp + 0x17], 0
            //   eb47                 | jmp                 0x49
            //   85d2                 | test                edx, edx
            //   741f                 | je                  0x21
            //   8b07                 | mov                 eax, dword ptr [edi]
            //   8d4d9c               | lea                 ecx, [ebp - 0x64]

        $sequence_5 = { 85f6 7438 81feffffff3f 7738 57 56 e8???????? }
            // n = 7, score = 200
            //   85f6                 | test                esi, esi
            //   7438                 | je                  0x3a
            //   81feffffff3f         | cmp                 esi, 0x3fffffff
            //   7738                 | ja                  0x3a
            //   57                   | push                edi
            //   56                   | push                esi
            //   e8????????           |                     

        $sequence_6 = { 0f45c8 894dd4 3bcf 740a 807df300 7504 32d2 }
            // n = 7, score = 200
            //   0f45c8               | cmovne              ecx, eax
            //   894dd4               | mov                 dword ptr [ebp - 0x2c], ecx
            //   3bcf                 | cmp                 ecx, edi
            //   740a                 | je                  0xc
            //   807df300             | cmp                 byte ptr [ebp - 0xd], 0
            //   7504                 | jne                 6
            //   32d2                 | xor                 dl, dl

        $sequence_7 = { 8d45f4 64a300000000 8bf1 8b4d08 8d45c4 50 e8???????? }
            // n = 7, score = 200
            //   8d45f4               | lea                 eax, [ebp - 0xc]
            //   64a300000000         | mov                 dword ptr fs:[0], eax
            //   8bf1                 | mov                 esi, ecx
            //   8b4d08               | mov                 ecx, dword ptr [ebp + 8]
            //   8d45c4               | lea                 eax, [ebp - 0x3c]
            //   50                   | push                eax
            //   e8????????           |                     

        $sequence_8 = { c21400 55 8bec 51 56 ff7508 8bf1 }
            // n = 7, score = 200
            //   c21400               | ret                 0x14
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   51                   | push                ecx
            //   56                   | push                esi
            //   ff7508               | push                dword ptr [ebp + 8]
            //   8bf1                 | mov                 esi, ecx

        $sequence_9 = { c745fc06000000 0f43ca 8b55f0 8bfa }
            // n = 4, score = 200
            //   c745fc06000000       | mov                 dword ptr [ebp - 4], 6
            //   0f43ca               | cmovae              ecx, edx
            //   8b55f0               | mov                 edx, dword ptr [ebp - 0x10]
            //   8bfa                 | mov                 edi, edx

    condition:
        7 of them and filesize < 1091584
}