rule win_cuba_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.cuba."
        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.cuba"
        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 = { 0019 43 41 00444341 }
            // n = 4, score = 100
            //   0019                 | add                 byte ptr [ecx], bl
            //   43                   | inc                 ebx
            //   41                   | inc                 ecx
            //   00444341             | add                 byte ptr [ebx + eax*2 + 0x41], al

        $sequence_1 = { 84c0 0f8414010000 8b06 813846494445 750d 8178044c2e4341 0f84fd000000 }
            // n = 7, score = 100
            //   84c0                 | test                al, al
            //   0f8414010000         | je                  0x11a
            //   8b06                 | mov                 eax, dword ptr [esi]
            //   813846494445         | cmp                 dword ptr [eax], 0x45444946
            //   750d                 | jne                 0xf
            //   8178044c2e4341       | cmp                 dword ptr [eax + 4], 0x41432e4c
            //   0f84fd000000         | je                  0x103

        $sequence_2 = { 3985c8f9ffff 7414 8d85c0f9ffff 50 56 ff15???????? }
            // n = 6, score = 100
            //   3985c8f9ffff         | cmp                 dword ptr [ebp - 0x638], eax
            //   7414                 | je                  0x16
            //   8d85c0f9ffff         | lea                 eax, [ebp - 0x640]
            //   50                   | push                eax
            //   56                   | push                esi
            //   ff15????????         |                     

        $sequence_3 = { 0026 45 41 003a }
            // n = 4, score = 100
            //   0026                 | add                 byte ptr [esi], ah
            //   45                   | inc                 ebp
            //   41                   | inc                 ecx
            //   003a                 | add                 byte ptr [edx], bh

        $sequence_4 = { 000d???????? 384100 b538 41 }
            // n = 4, score = 100
            //   000d????????         |                     
            //   384100               | cmp                 byte ptr [ecx], al
            //   b538                 | mov                 ch, 0x38
            //   41                   | inc                 ecx

        $sequence_5 = { 5e 7426 6683bdf4fdffff00 741c 8d85f4fdffff }
            // n = 5, score = 100
            //   5e                   | pop                 esi
            //   7426                 | je                  0x28
            //   6683bdf4fdffff00     | cmp                 word ptr [ebp - 0x20c], 0
            //   741c                 | je                  0x1e
            //   8d85f4fdffff         | lea                 eax, [ebp - 0x20c]

        $sequence_6 = { ff15???????? eb16 39bdc8f9ffff 7414 8d85c0f9ffff }
            // n = 5, score = 100
            //   ff15????????         |                     
            //   eb16                 | jmp                 0x18
            //   39bdc8f9ffff         | cmp                 dword ptr [ebp - 0x638], edi
            //   7414                 | je                  0x16
            //   8d85c0f9ffff         | lea                 eax, [ebp - 0x640]

        $sequence_7 = { 0012 45 41 0026 }
            // n = 4, score = 100
            //   0012                 | add                 byte ptr [edx], dl
            //   45                   | inc                 ebp
            //   41                   | inc                 ecx
            //   0026                 | add                 byte ptr [esi], ah

        $sequence_8 = { 8945f0 8b450c 8945f4 8b4514 40 c745ecac9c4000 894df8 }
            // n = 7, score = 100
            //   8945f0               | mov                 dword ptr [ebp - 0x10], eax
            //   8b450c               | mov                 eax, dword ptr [ebp + 0xc]
            //   8945f4               | mov                 dword ptr [ebp - 0xc], eax
            //   8b4514               | mov                 eax, dword ptr [ebp + 0x14]
            //   40                   | inc                 eax
            //   c745ecac9c4000       | mov                 dword ptr [ebp - 0x14], 0x409cac
            //   894df8               | mov                 dword ptr [ebp - 8], ecx

        $sequence_9 = { 0026 43 41 00b043410062 }
            // n = 4, score = 100
            //   0026                 | add                 byte ptr [esi], ah
            //   43                   | inc                 ebx
            //   41                   | inc                 ecx
            //   00b043410062         | add                 byte ptr [eax + 0x62004143], dh

        $sequence_10 = { 8bce e8???????? e8???????? 8b4dfc 33c0 33cd 5e }
            // n = 7, score = 100
            //   8bce                 | mov                 ecx, esi
            //   e8????????           |                     
            //   e8????????           |                     
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   33c0                 | xor                 eax, eax
            //   33cd                 | xor                 ecx, ebp
            //   5e                   | pop                 esi

        $sequence_11 = { 8b85e0feffff 03b40518ffffff 03b0fcb14100 03b5f8feffff }
            // n = 4, score = 100
            //   8b85e0feffff         | mov                 eax, dword ptr [ebp - 0x120]
            //   03b40518ffffff       | add                 esi, dword ptr [ebp + eax - 0xe8]
            //   03b0fcb14100         | add                 esi, dword ptr [eax + 0x41b1fc]
            //   03b5f8feffff         | add                 esi, dword ptr [ebp - 0x108]

        $sequence_12 = { 000c43 41 0035???????? 43 }
            // n = 4, score = 100
            //   000c43               | add                 byte ptr [ebx + eax*2], cl
            //   41                   | inc                 ecx
            //   0035????????         |                     
            //   43                   | inc                 ebx

        $sequence_13 = { 003a 45 41 004245 }
            // n = 4, score = 100
            //   003a                 | add                 byte ptr [edx], bh
            //   45                   | inc                 ebp
            //   41                   | inc                 ecx
            //   004245               | add                 byte ptr [edx + 0x45], al

        $sequence_14 = { 03f0 8b85e0feffff 03b40514ffffff 03b0f8b14100 03b5e4feffff 8d0433 }
            // n = 6, score = 100
            //   03f0                 | add                 esi, eax
            //   8b85e0feffff         | mov                 eax, dword ptr [ebp - 0x120]
            //   03b40514ffffff       | add                 esi, dword ptr [ebp + eax - 0xec]
            //   03b0f8b14100         | add                 esi, dword ptr [eax + 0x41b1f8]
            //   03b5e4feffff         | add                 esi, dword ptr [ebp - 0x11c]
            //   8d0433               | lea                 eax, [ebx + esi]

        $sequence_15 = { 000446 41 00d1 45 }
            // n = 4, score = 100
            //   000446               | add                 byte ptr [esi + eax*2], al
            //   41                   | inc                 ecx
            //   00d1                 | add                 cl, dl
            //   45                   | inc                 ebp

    condition:
        7 of them and filesize < 1094656
}