rule win_mirage_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-05-04"
        version = "1"
        description = "Detects win.mirage."
        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.mirage"
        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 = { 6801000080 ff15???????? 85c0 7556 }
            // n = 4, score = 200
            //   6801000080           | push                0x80000001
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   7556                 | jne                 0x58

        $sequence_1 = { 85c0 7541 0fb68799010000 50 }
            // n = 4, score = 200
            //   85c0                 | test                eax, eax
            //   7541                 | jne                 0x43
            //   0fb68799010000       | movzx               eax, byte ptr [edi + 0x199]
            //   50                   | push                eax

        $sequence_2 = { 83f8ff 8945fc 0f84d0000000 be14410000 8d85d4beffff 56 }
            // n = 6, score = 200
            //   83f8ff               | cmp                 eax, -1
            //   8945fc               | mov                 dword ptr [ebp - 4], eax
            //   0f84d0000000         | je                  0xd6
            //   be14410000           | mov                 esi, 0x4114
            //   8d85d4beffff         | lea                 eax, [ebp - 0x412c]
            //   56                   | push                esi

        $sequence_3 = { 33ff 50 57 ff15???????? 85c0 0f84f4000000 8d85c0feffff }
            // n = 7, score = 200
            //   33ff                 | xor                 edi, edi
            //   50                   | push                eax
            //   57                   | push                edi
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   0f84f4000000         | je                  0xfa
            //   8d85c0feffff         | lea                 eax, [ebp - 0x140]

        $sequence_4 = { 8b8534ffffff 5e c1e814 40 }
            // n = 4, score = 200
            //   8b8534ffffff         | mov                 eax, dword ptr [ebp - 0xcc]
            //   5e                   | pop                 esi
            //   c1e814               | shr                 eax, 0x14
            //   40                   | inc                 eax

        $sequence_5 = { b8???????? e8???????? 81ec64030000 53 56 57 }
            // n = 6, score = 200
            //   b8????????           |                     
            //   e8????????           |                     
            //   81ec64030000         | sub                 esp, 0x364
            //   53                   | push                ebx
            //   56                   | push                esi
            //   57                   | push                edi

        $sequence_6 = { 50 ff35???????? e8???????? 83c424 8935???????? ff75fc }
            // n = 6, score = 200
            //   50                   | push                eax
            //   ff35????????         |                     
            //   e8????????           |                     
            //   83c424               | add                 esp, 0x24
            //   8935????????         |                     
            //   ff75fc               | push                dword ptr [ebp - 4]

        $sequence_7 = { 33c0 8d7dc9 80a41dc4f6ffff00 f3ab }
            // n = 4, score = 200
            //   33c0                 | xor                 eax, eax
            //   8d7dc9               | lea                 edi, [ebp - 0x37]
            //   80a41dc4f6ffff00     | and                 byte ptr [ebp + ebx - 0x93c], 0
            //   f3ab                 | rep stosd           dword ptr es:[edi], eax

        $sequence_8 = { c745f804010000 ff75fc ff15???????? ff75fc }
            // n = 4, score = 200
            //   c745f804010000       | mov                 dword ptr [ebp - 8], 0x104
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   ff15????????         |                     
            //   ff75fc               | push                dword ptr [ebp - 4]

        $sequence_9 = { 53 68???????? c745f804010000 ff75fc }
            // n = 4, score = 200
            //   53                   | push                ebx
            //   68????????           |                     
            //   c745f804010000       | mov                 dword ptr [ebp - 8], 0x104
            //   ff75fc               | push                dword ptr [ebp - 4]

        $sequence_10 = { 53 68???????? 6801000080 894df0 c745fc04000000 881f 899948010000 }
            // n = 7, score = 200
            //   53                   | push                ebx
            //   68????????           |                     
            //   6801000080           | push                0x80000001
            //   894df0               | mov                 dword ptr [ebp - 0x10], ecx
            //   c745fc04000000       | mov                 dword ptr [ebp - 4], 4
            //   881f                 | mov                 byte ptr [edi], bl
            //   899948010000         | mov                 dword ptr [ecx + 0x148], ebx

        $sequence_11 = { 59 3bde 0f84dd000000 8d4701 }
            // n = 4, score = 100
            //   59                   | pop                 ecx
            //   3bde                 | cmp                 ebx, esi
            //   0f84dd000000         | je                  0xe3
            //   8d4701               | lea                 eax, [edi + 1]

        $sequence_12 = { 8d45f0 50 8bce e8???????? 8bf7 }
            // n = 5, score = 100
            //   8d45f0               | lea                 eax, [ebp - 0x10]
            //   50                   | push                eax
            //   8bce                 | mov                 ecx, esi
            //   e8????????           |                     
            //   8bf7                 | mov                 esi, edi

        $sequence_13 = { 8b4df0 8d0441 69c0f4010000 50 ff15???????? ff45f0 }
            // n = 6, score = 100
            //   8b4df0               | mov                 ecx, dword ptr [ebp - 0x10]
            //   8d0441               | lea                 eax, [ecx + eax*2]
            //   69c0f4010000         | imul                eax, eax, 0x1f4
            //   50                   | push                eax
            //   ff15????????         |                     
            //   ff45f0               | inc                 dword ptr [ebp - 0x10]

        $sequence_14 = { ffd3 6683a550faffff00 b981000000 33c0 8dbd52faffff f3ab 66ab }
            // n = 7, score = 100
            //   ffd3                 | call                ebx
            //   6683a550faffff00     | and                 word ptr [ebp - 0x5b0], 0
            //   b981000000           | mov                 ecx, 0x81
            //   33c0                 | xor                 eax, eax
            //   8dbd52faffff         | lea                 edi, [ebp - 0x5ae]
            //   f3ab                 | rep stosd           dword ptr es:[edi], eax
            //   66ab                 | stosw               word ptr es:[edi], ax

        $sequence_15 = { 743e 8d8500ebffff 50 e8???????? }
            // n = 4, score = 100
            //   743e                 | je                  0x40
            //   8d8500ebffff         | lea                 eax, [ebp - 0x1500]
            //   50                   | push                eax
            //   e8????????           |                     

    condition:
        7 of them and filesize < 1695744
}