rule win_mirrorkey_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-05-04"
        version = "1"
        description = "Detects win.mirrorkey."
        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.mirrorkey"
        malpedia_rule_date = "20260422"
        malpedia_hash = "a182e35da64e6d71cb55f125c4d4225196523f14"
        malpedia_version = "20260504"
        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 = { 5d c20800 e9???????? 3b0d???????? f27502 f2c3 f2e9ca030000 }
            // n = 7, score = 100
            //   5d                   | pop                 ebp
            //   c20800               | ret                 8
            //   e9????????           |                     
            //   3b0d????????         |                     
            //   f27502               | bnd jne             5
            //   f2c3                 | bnd ret             
            //   f2e9ca030000         | bnd jmp             0x3d0

        $sequence_1 = { 57 8b13 0f57c0 8b7d0c 83c2e0 50 }
            // n = 6, score = 100
            //   57                   | push                edi
            //   8b13                 | mov                 edx, dword ptr [ebx]
            //   0f57c0               | xorps               xmm0, xmm0
            //   8b7d0c               | mov                 edi, dword ptr [ebp + 0xc]
            //   83c2e0               | add                 edx, -0x20
            //   50                   | push                eax

        $sequence_2 = { 8b06 eb02 8bc6 c60000 c745fc00000000 8bce a1???????? }
            // n = 7, score = 100
            //   8b06                 | mov                 eax, dword ptr [esi]
            //   eb02                 | jmp                 4
            //   8bc6                 | mov                 eax, esi
            //   c60000               | mov                 byte ptr [eax], 0
            //   c745fc00000000       | mov                 dword ptr [ebp - 4], 0
            //   8bce                 | mov                 ecx, esi
            //   a1????????           |                     

        $sequence_3 = { 68???????? ff15???????? 57 8b7d18 }
            // n = 4, score = 100
            //   68????????           |                     
            //   ff15????????         |                     
            //   57                   | push                edi
            //   8b7d18               | mov                 edi, dword ptr [ebp + 0x18]

        $sequence_4 = { 6aff 6a00 56 8d4db8 c745cc0f000000 c745c800000000 c645b800 }
            // n = 7, score = 100
            //   6aff                 | push                -1
            //   6a00                 | push                0
            //   56                   | push                esi
            //   8d4db8               | lea                 ecx, [ebp - 0x48]
            //   c745cc0f000000       | mov                 dword ptr [ebp - 0x34], 0xf
            //   c745c800000000       | mov                 dword ptr [ebp - 0x38], 0
            //   c645b800             | mov                 byte ptr [ebp - 0x48], 0

        $sequence_5 = { 50 e8???????? ff75fc 8d45fc ff75f8 50 }
            // n = 6, score = 100
            //   50                   | push                eax
            //   e8????????           |                     
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   8d45fc               | lea                 eax, [ebp - 4]
            //   ff75f8               | push                dword ptr [ebp - 8]
            //   50                   | push                eax

        $sequence_6 = { 51 e8???????? ff7004 ff30 ff15???????? 83c41c }
            // n = 6, score = 100
            //   51                   | push                ecx
            //   e8????????           |                     
            //   ff7004               | push                dword ptr [eax + 4]
            //   ff30                 | push                dword ptr [eax]
            //   ff15????????         |                     
            //   83c41c               | add                 esp, 0x1c

        $sequence_7 = { 56 ff15???????? 5f 5e c7430400000000 }
            // n = 5, score = 100
            //   56                   | push                esi
            //   ff15????????         |                     
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   c7430400000000       | mov                 dword ptr [ebx + 4], 0

        $sequence_8 = { 46 3bf3 7ccf 8b4dfc }
            // n = 4, score = 100
            //   46                   | inc                 esi
            //   3bf3                 | cmp                 esi, ebx
            //   7ccf                 | jl                  0xffffffd1
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]

        $sequence_9 = { 85c0 7405 8a0c06 eb03 8a4ef4 }
            // n = 5, score = 100
            //   85c0                 | test                eax, eax
            //   7405                 | je                  7
            //   8a0c06               | mov                 cl, byte ptr [esi + eax]
            //   eb03                 | jmp                 5
            //   8a4ef4               | mov                 cl, byte ptr [esi - 0xc]

    condition:
        7 of them and filesize < 117760
}