rule win_carbanak_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.carbanak."
        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.carbanak"
        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 = { 7c0d e8???????? 84c0 7504 }
            // n = 4, score = 500
            //   7c0d                 | jl                  0xf
            //   e8????????           |                     
            //   84c0                 | test                al, al
            //   7504                 | jne                 6

        $sequence_1 = { 85c0 7509 e8???????? b001 }
            // n = 4, score = 500
            //   85c0                 | test                eax, eax
            //   7509                 | jne                 0xb
            //   e8????????           |                     
            //   b001                 | mov                 al, 1

        $sequence_2 = { 3d2c5c0700 750a e8???????? e9???????? }
            // n = 4, score = 500
            //   3d2c5c0700           | cmp                 eax, 0x75c2c
            //   750a                 | jne                 0xc
            //   e8????????           |                     
            //   e9????????           |                     

        $sequence_3 = { 7907 32c0 e9???????? 7507 b001 }
            // n = 5, score = 500
            //   7907                 | jns                 9
            //   32c0                 | xor                 al, al
            //   e9????????           |                     
            //   7507                 | jne                 9
            //   b001                 | mov                 al, 1

        $sequence_4 = { e8???????? 488bf8 4885c0 742e 488b0d???????? }
            // n = 5, score = 300
            //   e8????????           |                     
            //   488bf8               | cmp                 byte ptr [eax], 0
            //   4885c0               | jne                 0xfffffff7
            //   742e                 | dec                 eax
            //   488b0d????????       |                     

        $sequence_5 = { 488b8df0010000 e8???????? 488d4c2448 33d2 }
            // n = 4, score = 300
            //   488b8df0010000       | mov                 ecx, ebx
            //   e8????????           |                     
            //   488d4c2448           | dec                 eax
            //   33d2                 | mov                 edi, eax

        $sequence_6 = { 488bcb 488bf8 e8???????? 4533c0 4c8bcf 488d15ba140000 }
            // n = 6, score = 300
            //   488bcb               | mov                 edi, eax
            //   488bf8               | dec                 eax
            //   e8????????           |                     
            //   4533c0               | test                eax, eax
            //   4c8bcf               | je                  0x33
            //   488d15ba140000       | dec                 eax

        $sequence_7 = { 8bec 51 51 56 8d45f8 68???????? 50 }
            // n = 7, score = 200
            //   8bec                 | call                eax
            //   51                   | cmp                 eax, 0xb7
            //   51                   | je                  0xf
            //   56                   | test                eax, eax
            //   8d45f8               | je                  0xf
            //   68????????           |                     
            //   50                   | call                eax

        $sequence_8 = { be00010000 56 8d85d0fcffff 50 8d8dc0fcffff }
            // n = 5, score = 200
            //   be00010000           | cmp                 eax, 0xb7
            //   56                   | je                  0xa
            //   8d85d0fcffff         | test                eax, eax
            //   50                   | je                  0xa
            //   8d8dc0fcffff         | xor                 al, al

        $sequence_9 = { 50 57 6a1e 56 897d08 }
            // n = 5, score = 200
            //   50                   | cmp                 eax, 0xb7
            //   57                   | je                  0xf
            //   6a1e                 | test                eax, eax
            //   56                   | call                eax
            //   897d08               | cmp                 eax, 0xb7

        $sequence_10 = { 8bec 8d4524 50 ff7520 ff751c ff7518 ff7514 }
            // n = 7, score = 200
            //   8bec                 | xor                 al, al
            //   8d4524               | jne                 9
            //   50                   | mov                 al, 1
            //   ff7520               | jne                 7
            //   ff751c               | mov                 eax, dword ptr [esi + 8]
            //   ff7518               | jmp                 4
            //   ff7514               | mov                 eax, ebx

    condition:
        7 of them and filesize < 658432
}