rule win_carberp_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.carberp."
        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.carberp"
        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 = { 59 59 84c0 7428 56 e8???????? 59 }
            // n = 7, score = 200
            //   59                   | pop                 ecx
            //   59                   | pop                 ecx
            //   84c0                 | test                al, al
            //   7428                 | je                  0x2a
            //   56                   | push                esi
            //   e8????????           |                     
            //   59                   | pop                 ecx

        $sequence_1 = { 8bcf 85c0 760c 3931 741b 42 83c104 }
            // n = 7, score = 200
            //   8bcf                 | mov                 ecx, edi
            //   85c0                 | test                eax, eax
            //   760c                 | jbe                 0xe
            //   3931                 | cmp                 dword ptr [ecx], esi
            //   741b                 | je                  0x1d
            //   42                   | inc                 edx
            //   83c104               | add                 ecx, 4

        $sequence_2 = { e8???????? 59 03f0 56 ff7508 e8???????? 59 }
            // n = 7, score = 200
            //   e8????????           |                     
            //   59                   | pop                 ecx
            //   03f0                 | add                 esi, eax
            //   56                   | push                esi
            //   ff7508               | push                dword ptr [ebp + 8]
            //   e8????????           |                     
            //   59                   | pop                 ecx

        $sequence_3 = { ff74241c e8???????? 8bf0 83c414 83feff 7504 32c0 }
            // n = 7, score = 200
            //   ff74241c             | push                dword ptr [esp + 0x1c]
            //   e8????????           |                     
            //   8bf0                 | mov                 esi, eax
            //   83c414               | add                 esp, 0x14
            //   83feff               | cmp                 esi, -1
            //   7504                 | jne                 6
            //   32c0                 | xor                 al, al

        $sequence_4 = { 57 53 e8???????? 894618 eb21 57 53 }
            // n = 7, score = 200
            //   57                   | push                edi
            //   53                   | push                ebx
            //   e8????????           |                     
            //   894618               | mov                 dword ptr [esi + 0x18], eax
            //   eb21                 | jmp                 0x23
            //   57                   | push                edi
            //   53                   | push                ebx

        $sequence_5 = { 83ff01 7405 83ff02 7517 6a00 53 ff35???????? }
            // n = 7, score = 200
            //   83ff01               | cmp                 edi, 1
            //   7405                 | je                  7
            //   83ff02               | cmp                 edi, 2
            //   7517                 | jne                 0x19
            //   6a00                 | push                0
            //   53                   | push                ebx
            //   ff35????????         |                     

        $sequence_6 = { 68d9e5b2cf 6a03 6a00 e8???????? 83c40c ff742408 ff742408 }
            // n = 7, score = 200
            //   68d9e5b2cf           | push                0xcfb2e5d9
            //   6a03                 | push                3
            //   6a00                 | push                0
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   ff742408             | push                dword ptr [esp + 8]
            //   ff742408             | push                dword ptr [esp + 8]

        $sequence_7 = { ff01 c3 8b0d???????? 2b4c2404 56 33f6 3935???????? }
            // n = 7, score = 200
            //   ff01                 | inc                 dword ptr [ecx]
            //   c3                   | ret                 
            //   8b0d????????         |                     
            //   2b4c2404             | sub                 ecx, dword ptr [esp + 4]
            //   56                   | push                esi
            //   33f6                 | xor                 esi, esi
            //   3935????????         |                     

        $sequence_8 = { e8???????? 8bf0 85f6 0f8494000000 ff45fc 8b45fc 89462c }
            // n = 7, score = 200
            //   e8????????           |                     
            //   8bf0                 | mov                 esi, eax
            //   85f6                 | test                esi, esi
            //   0f8494000000         | je                  0x9a
            //   ff45fc               | inc                 dword ptr [ebp - 4]
            //   8b45fc               | mov                 eax, dword ptr [ebp - 4]
            //   89462c               | mov                 dword ptr [esi + 0x2c], eax

        $sequence_9 = { 8b8704010000 3bf0 5e 7f3a 807c243400 7433 3dffffff7f }
            // n = 7, score = 200
            //   8b8704010000         | mov                 eax, dword ptr [edi + 0x104]
            //   3bf0                 | cmp                 esi, eax
            //   5e                   | pop                 esi
            //   7f3a                 | jg                  0x3c
            //   807c243400           | cmp                 byte ptr [esp + 0x34], 0
            //   7433                 | je                  0x35
            //   3dffffff7f           | cmp                 eax, 0x7fffffff

    condition:
        7 of them and filesize < 491520
}