rule win_cobra_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.cobra."
        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.cobra"
        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 = { 7511 e8???????? 85c0 7508 ff15???????? }
            // n = 5, score = 2900
            //   7511                 | add                 eax, 2
            //   e8????????           |                     
            //   85c0                 | cmp                 cx, bx
            //   7508                 | jne                 0xfffffffc
            //   ff15????????         |                     

        $sequence_1 = { ff25???????? 8b442408 85c0 750e 3905???????? 7e2c ff0d???????? }
            // n = 7, score = 2500
            //   ff25????????         |                     
            //   8b442408             | adc                 ecx, esi
            //   85c0                 | push                ecx
            //   750e                 | push                eax
            //   3905????????         |                     
            //   7e2c                 | mov                 ax, cs
            //   ff0d????????         |                     

        $sequence_2 = { 5b c3 85db 7405 83fb03 753b }
            // n = 6, score = 2500
            //   5b                   | push                ebx
            //   c3                   | push                esi
            //   85db                 | push                edi
            //   7405                 | mov                 ebx, ecx
            //   83fb03               | xor                 esi, esi
            //   753b                 | mov                 eax, dword ptr [esp + 8]

        $sequence_3 = { 83f801 75f1 b900010000 e8???????? }
            // n = 4, score = 2500
            //   83f801               | mov                 eax, dword ptr [esp + 8]
            //   75f1                 | test                eax, eax
            //   b900010000           | jne                 0x10
            //   e8????????           |                     

        $sequence_4 = { 757f 8b05???????? 85c0 0f8e8c000000 }
            // n = 4, score = 2500
            //   757f                 | test                eax, eax
            //   8b05????????         |                     
            //   85c0                 | jle                 0x94
            //   0f8e8c000000         | sub                 eax, 1

        $sequence_5 = { 5f 5e 5b c3 85ff 7418 }
            // n = 6, score = 2500
            //   5f                   | xor                 esi, esi
            //   5e                   | mov                 eax, dword ptr [esp + 8]
            //   5b                   | test                eax, eax
            //   c3                   | jne                 0x10
            //   85ff                 | jle                 0x30
            //   7418                 | push                ecx

        $sequence_6 = { c20c00 ff25???????? 53 56 57 8bd9 33f6 }
            // n = 7, score = 2500
            //   c20c00               | xor                 esi, esi
            //   ff25????????         |                     
            //   53                   | add                 eax, edx
            //   56                   | adc                 ecx, esi
            //   57                   | push                ecx
            //   8bd9                 | xor                 esi, esi
            //   33f6                 | add                 eax, edx

        $sequence_7 = { 7514 391d???????? 754d 33c0 }
            // n = 4, score = 2500
            //   7514                 | push                edi
            //   391d????????         |                     
            //   754d                 | mov                 ebx, ecx
            //   33c0                 | xor                 esi, esi

        $sequence_8 = { 85c0 0f8e8c000000 83e801 8905???????? }
            // n = 4, score = 2500
            //   85c0                 | je                  9
            //   0f8e8c000000         | cmp                 ebx, 3
            //   83e801               | pop                 ebx
            //   8905????????         |                     

        $sequence_9 = { e8???????? 8bf8 83fb01 751d 85ff }
            // n = 5, score = 2500
            //   e8????????           |                     
            //   8bf8                 | jle                 0x30
            //   83fb01               | push                ecx
            //   751d                 | xor                 eax, eax
            //   85ff                 | add                 esp, 0x3c

        $sequence_10 = { 5b c3 83fb01 7405 83fb02 7537 }
            // n = 6, score = 2500
            //   5b                   | jle                 0x32
            //   c3                   | ret                 0xc
            //   83fb01               | push                ebx
            //   7405                 | push                esi
            //   83fb02               | push                edi
            //   7537                 | mov                 ebx, ecx

        $sequence_11 = { 33d2 b9e8030000 f7f1 83f805 }
            // n = 4, score = 2300
            //   33d2                 | ret                 
            //   b9e8030000           | mov                 ecx, dword ptr [ebp + 8]
            //   f7f1                 | push                edi
            //   83f805               | push                ecx

        $sequence_12 = { 813c0850450000 7503 33c0 c3 }
            // n = 4, score = 2100
            //   813c0850450000       | je                  0xc
            //   7503                 | mov                 eax, 0xc0000005
            //   33c0                 | ret                 
            //   c3                   | mov                 ax, cs

        $sequence_13 = { eb22 8bd0 2bd1 81fa00040000 7c14 e8???????? }
            // n = 6, score = 1900
            //   eb22                 | push                ebx
            //   8bd0                 | push                esi
            //   2bd1                 | push                edi
            //   81fa00040000         | mov                 ebx, ecx
            //   7c14                 | xor                 esi, esi
            //   e8????????           |                     

        $sequence_14 = { 83f8ff 7407 33c0 e9???????? ff15???????? e9???????? }
            // n = 6, score = 1900
            //   83f8ff               | ret                 
            //   7407                 | push                ebx
            //   33c0                 | ret                 
            //   e9????????           |                     
            //   ff15????????         |                     
            //   e9????????           |                     

        $sequence_15 = { c9 c3 6a02 56 }
            // n = 4, score = 1900
            //   c9                   | je                  0xc
            //   c3                   | mov                 eax, 0xc0000005
            //   6a02                 | test                eax, eax
            //   56                   | je                  0xc

        $sequence_16 = { eb10 8d4608 50 e8???????? 8b4508 8930 33c0 }
            // n = 7, score = 1900
            //   eb10                 | push                edi
            //   8d4608               | push                ecx
            //   50                   | push                0
            //   e8????????           |                     
            //   8b4508               | push                0
            //   8930                 | push                esi
            //   33c0                 | push                esi

        $sequence_17 = { 85c0 7f07 e8???????? eb26 83c0ff }
            // n = 5, score = 1200
            //   85c0                 | test                eax, eax
            //   7f07                 | jg                  9
            //   e8????????           |                     
            //   eb26                 | jmp                 0x28
            //   83c0ff               | add                 eax, -1

        $sequence_18 = { e8???????? 33db 3bc3 741a }
            // n = 4, score = 1200
            //   e8????????           |                     
            //   33db                 | xor                 ebx, ebx
            //   3bc3                 | cmp                 eax, ebx
            //   741a                 | je                  0x1c

        $sequence_19 = { eb6d e8???????? 85c0 7564 }
            // n = 4, score = 1200
            //   eb6d                 | jmp                 0x6f
            //   e8????????           |                     
            //   85c0                 | test                eax, eax
            //   7564                 | jne                 0x66

        $sequence_20 = { e8???????? 4c8b1e 498b03 488bd5 488bce ff5064 488b0e }
            // n = 7, score = 1100
            //   e8????????           |                     
            //   4c8b1e               | mov                 ecx, dword ptr [esp + 0x98]
            //   498b03               | jne                 0x4a
            //   488bd5               | dec                 eax
            //   488bce               | test                eax, eax
            //   ff5064               | je                  0x3e
            //   488b0e               | dec                 eax

        $sequence_21 = { 7e4b 4c8b505c 4d85d2 7442 }
            // n = 4, score = 1100
            //   7e4b                 | jle                 0x4d
            //   4c8b505c             | dec                 esp
            //   4d85d2               | mov                 edx, dword ptr [eax + 0x5c]
            //   7442                 | dec                 ebp

        $sequence_22 = { e8???????? 4c8b1e 418bd4 498b03 488bce ff5024 488d4d08 }
            // n = 7, score = 1100
            //   e8????????           |                     
            //   4c8b1e               | mov                 edx, ebp
            //   418bd4               | dec                 eax
            //   498b03               | mov                 ecx, esi
            //   488bce               | dec                 esp
            //   ff5024               | mov                 ebx, dword ptr [esi]
            //   488d4d08             | dec                 ecx

        $sequence_23 = { 7548 488b05???????? 4885c0 743c 488b8c24a0000000 }
            // n = 5, score = 1100
            //   7548                 | test                edx, edx
            //   488b05????????       |                     
            //   4885c0               | je                  0x44
            //   743c                 | jne                 0x4a
            //   488b8c24a0000000     | dec                 eax

        $sequence_24 = { e8???????? 4c8b1e 498b03 418bd4 488bce ff501c 488d4d08 }
            // n = 7, score = 1100
            //   e8????????           |                     
            //   4c8b1e               | mov                 ecx, esi
            //   498b03               | call                dword ptr [eax + 0x64]
            //   418bd4               | dec                 eax
            //   488bce               | mov                 ecx, dword ptr [esi]
            //   ff501c               | dec                 esp
            //   488d4d08             | mov                 ebx, dword ptr [esi]

        $sequence_25 = { 7504 33c0 eb05 b865005921 }
            // n = 4, score = 900
            //   7504                 | dec                 ecx
            //   33c0                 | mov                 eax, dword ptr [ebx]
            //   eb05                 | inc                 ecx
            //   b865005921           | mov                 edx, esp

        $sequence_26 = { 83781400 750a b865005921 e9???????? }
            // n = 4, score = 900
            //   83781400             | call                dword ptr [eax + 0x1c]
            //   750a                 | dec                 esp
            //   b865005921           | mov                 ebx, dword ptr [esi]
            //   e9????????           |                     

        $sequence_27 = { ff15???????? 83f87a 740b 3d230000c0 }
            // n = 4, score = 800
            //   ff15????????         |                     
            //   83f87a               | test                ebx, ebx
            //   740b                 | jne                 0x18
            //   3d230000c0           | jne                 0x4f

        $sequence_28 = { c3 8b4d08 57 51 6a00 }
            // n = 5, score = 800
            //   c3                   | sub                 edx, ecx
            //   8b4d08               | cmp                 edx, 0x400
            //   57                   | jl                  0x20
            //   51                   | jmp                 0x24
            //   6a00                 | mov                 edx, eax

        $sequence_29 = { 6a18 8d45e8 50 6a00 6aff e8???????? 85c0 }
            // n = 7, score = 800
            //   6a18                 | dec                 eax
            //   8d45e8               | mov                 ecx, esi
            //   50                   | dec                 esp
            //   6a00                 | mov                 ebx, dword ptr [esi]
            //   6aff                 | dec                 ecx
            //   e8????????           |                     
            //   85c0                 | mov                 eax, dword ptr [ebx]

        $sequence_30 = { 83c0fe 668b4802 83c002 663bcb 75f4 8b15???????? 8b0d???????? }
            // n = 7, score = 800
            //   83c0fe               | je                  9
            //   668b4802             | xor                 eax, eax
            //   83c002               | cmp                 eax, -1
            //   663bcb               | je                  9
            //   75f4                 | xor                 eax, eax
            //   8b15????????         |                     
            //   8b0d????????         |                     

        $sequence_31 = { 8b7d0c 3bc3 7508 3bfb }
            // n = 4, score = 800
            //   8b7d0c               | push                ebx
            //   3bc3                 | push                esi
            //   7508                 | push                edi
            //   3bfb                 | mov                 ebx, ecx

        $sequence_32 = { 8908 8b0d???????? 895004 894808 33c0 }
            // n = 5, score = 800
            //   8908                 | cmp                 dword ptr [eax + ecx], 0x4550
            //   8b0d????????         |                     
            //   895004               | jne                 5
            //   894808               | xor                 eax, eax
            //   33c0                 | ret                 

        $sequence_33 = { 6689440ffc 6685c0 75ee f685c003000010 }
            // n = 4, score = 800
            //   6689440ffc           | xor                 eax, eax
            //   6685c0               | pop                 esi
            //   75ee                 | pop                 ebx
            //   f685c003000010       | ret                 

        $sequence_34 = { 8bec 56 6a00 6880000000 6a03 6a00 6a03 }
            // n = 7, score = 800
            //   8bec                 | sub                 edx, ecx
            //   56                   | cmp                 edx, 0x400
            //   6a00                 | jl                  0x1e
            //   6880000000           | cdq                 
            //   6a03                 | push                ebp
            //   6a00                 | mov                 ebx, 0x7fffffff
            //   6a03                 | ret                 0xc

        $sequence_35 = { 68???????? 51 ffd6 83c40c 6a28 }
            // n = 5, score = 800
            //   68????????           |                     
            //   51                   | mov                 ebp, esp
            //   ffd6                 | push                esi
            //   83c40c               | push                0
            //   6a28                 | push                0x80

        $sequence_36 = { 6a03 68000000c0 50 ff15???????? 8bf0 83feff 7505 }
            // n = 7, score = 800
            //   6a03                 | jne                 0xfffffffc
            //   68000000c0           | ret                 
            //   50                   | mov                 ecx, dword ptr [ebp + 8]
            //   ff15????????         |                     
            //   8bf0                 | push                edi
            //   83feff               | push                ecx
            //   7505                 | push                0

        $sequence_37 = { 83feff 7505 33c0 5e 5d c3 8b4d08 }
            // n = 7, score = 800
            //   83feff               | jne                 0x10
            //   7505                 | jle                 0x30
            //   33c0                 | mov                 eax, dword ptr [esp + 8]
            //   5e                   | test                eax, eax
            //   5d                   | jne                 0x10
            //   c3                   | jle                 0x30
            //   8b4d08               | cmp                 dword ptr [eax + ecx], 0x4550

        $sequence_38 = { 33c0 4881c4480d0000 415f 415e 415c 5e 5b }
            // n = 7, score = 700
            //   33c0                 | lea                 ecx, [esp + 0x68]
            //   4881c4480d0000       | dec                 eax
            //   415f                 | mov                 dword ptr [esp + 0x40], ecx
            //   415e                 | dec                 esp
            //   415c                 | mov                 dword ptr [esp + 0x38], esp
            //   5e                   | dec                 eax
            //   5b                   | mov                 ecx, esi

        $sequence_39 = { 488b05???????? 498bcc 488947fe 8b05???????? }
            // n = 4, score = 700
            //   488b05????????       |                     
            //   498bcc               | mov                 dword ptr [esp + 0x50], ecx
            //   488947fe             | dec                 esp
            //   8b05????????         |                     

        $sequence_40 = { 8d8588feffff 68???????? 50 ff15???????? 83c42c }
            // n = 5, score = 700
            //   8d8588feffff         | je                  0xc
            //   68????????           |                     
            //   50                   | cmp                 ebx, 3
            //   ff15????????         |                     
            //   83c42c               | pop                 edi

        $sequence_41 = { 4533e4 4c8bf1 488bda 488d8d10060000 33d2 41b808020000 }
            // n = 6, score = 700
            //   4533e4               | cmp                 eax, 0xc0000023
            //   4c8bf1               | mov                 word ptr [edi + ecx - 4], ax
            //   488bda               | test                ax, ax
            //   488d8d10060000       | jne                 0xfffffff0
            //   33d2                 | test                byte ptr [ebp + 0x3c0], 0x10
            //   41b808020000         | dec                 eax

        $sequence_42 = { b914000000 84c0 0f45f9 488bce }
            // n = 4, score = 700
            //   b914000000           | test                eax, eax
            //   84c0                 | jne                 0xc
            //   0f45f9               | ret                 0xc
            //   488bce               | push                ebx

        $sequence_43 = { 48894c2450 4c89642448 488d4c2468 48894c2440 }
            // n = 4, score = 700
            //   48894c2450           | cmp                 ebx, 1
            //   4c89642448           | je                  0xb
            //   488d4c2468           | cmp                 ebx, 2
            //   48894c2440           | mov                 ebx, dword ptr [esp + 0x58]

        $sequence_44 = { 488bce 8bd7 ff15???????? 85c0 }
            // n = 4, score = 700
            //   488bce               | lea                 ecx, [edi + 0x3e8]
            //   8bd7                 | mov                 edi, ecx
            //   ff15????????         |                     
            //   85c0                 | jne                 0x13

        $sequence_45 = { 7507 32c0 e9???????? c745b818000000 }
            // n = 4, score = 600
            //   7507                 | mov                 eax, dword ptr [ebx]
            //   32c0                 | dec                 eax
            //   e9????????           |                     
            //   c745b818000000       | mov                 ecx, esi

        $sequence_46 = { 6685c9 75f5 2bc2 d1f8 66837c43fe5c }
            // n = 5, score = 500
            //   6685c9               | pop                 esi
            //   75f5                 | pop                 ebx
            //   2bc2                 | ret                 
            //   d1f8                 | test                ebx, ebx
            //   66837c43fe5c         | je                  0xb

        $sequence_47 = { 33f6 03c2 13ce 51 }
            // n = 4, score = 500
            //   33f6                 | dec                 esp
            //   03c2                 | mov                 ebx, dword ptr [esi]
            //   13ce                 | inc                 ecx
            //   51                   | mov                 edx, esp

        $sequence_48 = { 05a1000000 50 8d84249c0d0000 68???????? }
            // n = 4, score = 300
            //   05a1000000           | pop                 ebx
            //   50                   | ret                 
            //   8d84249c0d0000       | test                ebx, ebx
            //   68????????           |                     

        $sequence_49 = { 0f8431ffffff 8b4d08 5f 8931 }
            // n = 4, score = 300
            //   0f8431ffffff         | je                  0xa
            //   8b4d08               | jne                 0x16
            //   5f                   | jne                 0x4f
            //   8931                 | xor                 eax, eax

        $sequence_50 = { 0f8456feffff 807c241301 6800080000 0f8544020000 }
            // n = 4, score = 300
            //   0f8456feffff         | add                 eax, 2
            //   807c241301           | test                cx, cx
            //   6800080000           | jne                 0xfffffff7
            //   0f8544020000         | sub                 eax, edx

        $sequence_51 = { 05a2000000 50 8d8c249c0d0000 68???????? }
            // n = 4, score = 300
            //   05a2000000           | pop                 esi
            //   50                   | pop                 ebx
            //   8d8c249c0d0000       | ret                 
            //   68????????           |                     

        $sequence_52 = { 0f84100f0000 6800080000 57 56 }
            // n = 4, score = 300
            //   0f84100f0000         | pop                 ebx
            //   6800080000           | ret                 
            //   57                   | cmp                 ebx, 1
            //   56                   | je                  0xd

        $sequence_53 = { 05a2000000 50 8d94249c0d0000 68???????? }
            // n = 4, score = 300
            //   05a2000000           | pop                 esi
            //   50                   | pop                 ebx
            //   8d94249c0d0000       | ret                 
            //   68????????           |                     

        $sequence_54 = { 668cc8 c3 53 50 }
            // n = 4, score = 200
            //   668cc8               | dec                 eax
            //   c3                   | cmp                 dword ptr [edi], 0
            //   53                   | je                  0x23
            //   50                   | dec                 eax

        $sequence_55 = { 85c0 740a b8050000c0 e9???????? }
            // n = 4, score = 200
            //   85c0                 | mov                 ebx, dword ptr [ebx]
            //   740a                 | pop                 ebx
            //   b8050000c0           | ret                 
            //   e9????????           |                     

        $sequence_56 = { c745d440000000 8b5508 83c20c 8955d0 }
            // n = 4, score = 100
            //   c745d440000000       | push                0
            //   8b5508               | push                -1
            //   83c20c               | test                eax, eax
            //   8955d0               | je                  9

    condition:
        7 of them and filesize < 1368064
}