rule win_metastealer_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.metastealer."
        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.metastealer"
        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 = { ff75ec 56 e8???????? 83c40c 85c0 755c ffb64c020000 }
            // n = 7, score = 300
            //   ff75ec               | push                dword ptr [ebp - 0x14]
            //   56                   | push                esi
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   85c0                 | test                eax, eax
            //   755c                 | jne                 0x5e
            //   ffb64c020000         | push                dword ptr [esi + 0x24c]

        $sequence_1 = { e9???????? 8b450c c70000000000 5e 5b 5f 8be5 }
            // n = 7, score = 300
            //   e9????????           |                     
            //   8b450c               | mov                 eax, dword ptr [ebp + 0xc]
            //   c70000000000         | mov                 dword ptr [eax], 0
            //   5e                   | pop                 esi
            //   5b                   | pop                 ebx
            //   5f                   | pop                 edi
            //   8be5                 | mov                 esp, ebp

        $sequence_2 = { ff33 e8???????? 8bf8 83c40c 85ff 7412 c64710a5 }
            // n = 7, score = 300
            //   ff33                 | push                dword ptr [ebx]
            //   e8????????           |                     
            //   8bf8                 | mov                 edi, eax
            //   83c40c               | add                 esp, 0xc
            //   85ff                 | test                edi, edi
            //   7412                 | je                  0x14
            //   c64710a5             | mov                 byte ptr [edi + 0x10], 0xa5

        $sequence_3 = { f7c300800000 0f8578000000 3b5de4 7317 c745e800000000 85c9 8b4de8 }
            // n = 7, score = 300
            //   f7c300800000         | test                ebx, 0x8000
            //   0f8578000000         | jne                 0x7e
            //   3b5de4               | cmp                 ebx, dword ptr [ebp - 0x1c]
            //   7317                 | jae                 0x19
            //   c745e800000000       | mov                 dword ptr [ebp - 0x18], 0
            //   85c9                 | test                ecx, ecx
            //   8b4de8               | mov                 ecx, dword ptr [ebp - 0x18]

        $sequence_4 = { e9???????? 3d00009942 0f8588010000 8b4318 8bca 8b731c 81e1ff0f0000 }
            // n = 7, score = 300
            //   e9????????           |                     
            //   3d00009942           | cmp                 eax, 0x42990000
            //   0f8588010000         | jne                 0x18e
            //   8b4318               | mov                 eax, dword ptr [ebx + 0x18]
            //   8bca                 | mov                 ecx, edx
            //   8b731c               | mov                 esi, dword ptr [ebx + 0x1c]
            //   81e1ff0f0000         | and                 ecx, 0xfff

        $sequence_5 = { ff730c 68???????? 8d45bc 50 e8???????? 83c428 c645fc10 }
            // n = 7, score = 300
            //   ff730c               | push                dword ptr [ebx + 0xc]
            //   68????????           |                     
            //   8d45bc               | lea                 eax, [ebp - 0x44]
            //   50                   | push                eax
            //   e8????????           |                     
            //   83c428               | add                 esp, 0x28
            //   c645fc10             | mov                 byte ptr [ebp - 4], 0x10

        $sequence_6 = { ff7320 ff731c 50 e8???????? 83c40c 5f 5e }
            // n = 7, score = 300
            //   ff7320               | push                dword ptr [ebx + 0x20]
            //   ff731c               | push                dword ptr [ebx + 0x1c]
            //   50                   | push                eax
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi

        $sequence_7 = { ff15???????? 83c404 8d7e1c eb14 8b461c 8d7e1c 85c0 }
            // n = 7, score = 300
            //   ff15????????         |                     
            //   83c404               | add                 esp, 4
            //   8d7e1c               | lea                 edi, [esi + 0x1c]
            //   eb14                 | jmp                 0x16
            //   8b461c               | mov                 eax, dword ptr [esi + 0x1c]
            //   8d7e1c               | lea                 edi, [esi + 0x1c]
            //   85c0                 | test                eax, eax

        $sequence_8 = { f7d0 23f3 23d0 eb25 85ff 7f0d 7c04 }
            // n = 7, score = 300
            //   f7d0                 | not                 eax
            //   23f3                 | and                 esi, ebx
            //   23d0                 | and                 edx, eax
            //   eb25                 | jmp                 0x27
            //   85ff                 | test                edi, edi
            //   7f0d                 | jg                  0xf
            //   7c04                 | jl                  6

        $sequence_9 = { ff5108 8b472c 50 8b08 ff511c 8bc8 898d70ffffff }
            // n = 7, score = 300
            //   ff5108               | call                dword ptr [ecx + 8]
            //   8b472c               | mov                 eax, dword ptr [edi + 0x2c]
            //   50                   | push                eax
            //   8b08                 | mov                 ecx, dword ptr [eax]
            //   ff511c               | call                dword ptr [ecx + 0x1c]
            //   8bc8                 | mov                 ecx, eax
            //   898d70ffffff         | mov                 dword ptr [ebp - 0x90], ecx

    condition:
        7 of them and filesize < 26230784
}