rule win_blackmatter_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.blackmatter."
        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.blackmatter"
        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 = { 50 8d851cffffff 50 8d45f8 50 6a00 8d45dc }
            // n = 7, score = 400
            //   50                   | push                eax
            //   8d851cffffff         | lea                 eax, [ebp - 0xe4]
            //   50                   | push                eax
            //   8d45f8               | lea                 eax, [ebp - 8]
            //   50                   | push                eax
            //   6a00                 | push                0
            //   8d45dc               | lea                 eax, [ebp - 0x24]

        $sequence_1 = { ebe7 837de400 7408 ff75e4 }
            // n = 4, score = 400
            //   ebe7                 | jmp                 0xffffffe9
            //   837de400             | cmp                 dword ptr [ebp - 0x1c], 0
            //   7408                 | je                  0xa
            //   ff75e4               | push                dword ptr [ebp - 0x1c]

        $sequence_2 = { ff75e8 ff75ec e8???????? 803d????????00 }
            // n = 4, score = 400
            //   ff75e8               | push                dword ptr [ebp - 0x18]
            //   ff75ec               | push                dword ptr [ebp - 0x14]
            //   e8????????           |                     
            //   803d????????00       |                     

        $sequence_3 = { 50 ff15???????? 83c404 8bf8 8d047d02000000 50 8d85fcfeffff }
            // n = 7, score = 400
            //   50                   | push                eax
            //   ff15????????         |                     
            //   83c404               | add                 esp, 4
            //   8bf8                 | mov                 edi, eax
            //   8d047d02000000       | lea                 eax, [edi*2 + 2]
            //   50                   | push                eax
            //   8d85fcfeffff         | lea                 eax, [ebp - 0x104]

        $sequence_4 = { 8d3c3e 57 ff15???????? eb05 }
            // n = 4, score = 400
            //   8d3c3e               | lea                 edi, [esi + edi]
            //   57                   | push                edi
            //   ff15????????         |                     
            //   eb05                 | jmp                 7

        $sequence_5 = { e8???????? 8945fc eb0c 83c702 ff4df8 837df800 }
            // n = 6, score = 400
            //   e8????????           |                     
            //   8945fc               | mov                 dword ptr [ebp - 4], eax
            //   eb0c                 | jmp                 0xe
            //   83c702               | add                 edi, 2
            //   ff4df8               | dec                 dword ptr [ebp - 8]
            //   837df800             | cmp                 dword ptr [ebp - 8], 0

        $sequence_6 = { 817e043f005c00 0f85c2010000 c745f400000000 8d45f4 50 6a40 57 }
            // n = 7, score = 400
            //   817e043f005c00       | cmp                 dword ptr [esi + 4], 0x5c003f
            //   0f85c2010000         | jne                 0x1c8
            //   c745f400000000       | mov                 dword ptr [ebp - 0xc], 0
            //   8d45f4               | lea                 eax, [ebp - 0xc]
            //   50                   | push                eax
            //   6a40                 | push                0x40
            //   57                   | push                edi

        $sequence_7 = { 7409 83f802 0f857c010000 e8???????? }
            // n = 4, score = 400
            //   7409                 | je                  0xb
            //   83f802               | cmp                 eax, 2
            //   0f857c010000         | jne                 0x182
            //   e8????????           |                     

        $sequence_8 = { 7502 eb65 53 ff15???????? 83c404 8d3443 }
            // n = 6, score = 400
            //   7502                 | jne                 4
            //   eb65                 | jmp                 0x67
            //   53                   | push                ebx
            //   ff15????????         |                     
            //   83c404               | add                 esp, 4
            //   8d3443               | lea                 esi, [ebx + eax*2]

        $sequence_9 = { ff7508 ff35???????? e8???????? 85c0 0f8545020000 e8???????? }
            // n = 6, score = 400
            //   ff7508               | push                dword ptr [ebp + 8]
            //   ff35????????         |                     
            //   e8????????           |                     
            //   85c0                 | test                eax, eax
            //   0f8545020000         | jne                 0x24b
            //   e8????????           |                     

    condition:
        7 of them and filesize < 194560
}