rule win_mirage_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        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 = "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 = { 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_1 = { 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_2 = { 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_3 = { 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_4 = { 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_5 = { 50 53 68???????? c745f804010000 ff75fc ff15???????? }
            // n = 6, score = 200
            //   50                   | push                eax
            //   53                   | push                ebx
            //   68????????           |                     
            //   c745f804010000       | mov                 dword ptr [ebp - 8], 0x104
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   ff15????????         |                     

        $sequence_6 = { 68???????? e8???????? 59 8945e4 8025????????00 }
            // n = 5, score = 200
            //   68????????           |                     
            //   e8????????           |                     
            //   59                   | pop                 ecx
            //   8945e4               | mov                 dword ptr [ebp - 0x1c], eax
            //   8025????????00       |                     

        $sequence_7 = { 6801000080 ff15???????? 85c0 7556 }
            // n = 4, score = 200
            //   6801000080           | push                0x80000001
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   7556                 | jne                 0x58

        $sequence_8 = { 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_9 = { 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_10 = { 8b4304 8bfc 83c304 a5 }
            // n = 4, score = 100
            //   8b4304               | mov                 eax, dword ptr [ebx + 4]
            //   8bfc                 | mov                 edi, esp
            //   83c304               | add                 ebx, 4
            //   a5                   | movsd               dword ptr es:[edi], dword ptr [esi]

        $sequence_11 = { 8bca 8dbdf2e6ffff 66899df0e6ffff 66899dd0deffff f3ab 66ab }
            // n = 6, score = 100
            //   8bca                 | mov                 ecx, edx
            //   8dbdf2e6ffff         | lea                 edi, [ebp - 0x190e]
            //   66899df0e6ffff       | mov                 word ptr [ebp - 0x1910], bx
            //   66899dd0deffff       | mov                 word ptr [ebp - 0x2130], bx
            //   f3ab                 | rep stosd           dword ptr es:[edi], eax
            //   66ab                 | stosw               word ptr es:[edi], ax

        $sequence_12 = { 89480c c20c00 56 8bf1 e8???????? f644240801 7407 }
            // n = 7, score = 100
            //   89480c               | mov                 dword ptr [eax + 0xc], ecx
            //   c20c00               | ret                 0xc
            //   56                   | push                esi
            //   8bf1                 | mov                 esi, ecx
            //   e8????????           |                     
            //   f644240801           | test                byte ptr [esp + 8], 1
            //   7407                 | je                  9

        $sequence_13 = { ff15???????? ff7508 ff15???????? ff750c 8b35???????? }
            // n = 5, score = 100
            //   ff15????????         |                     
            //   ff7508               | push                dword ptr [ebp + 8]
            //   ff15????????         |                     
            //   ff750c               | push                dword ptr [ebp + 0xc]
            //   8b35????????         |                     

        $sequence_14 = { 4b 75ea 6683673e00 5f 5e 5b }
            // n = 6, score = 100
            //   4b                   | dec                 ebx
            //   75ea                 | jne                 0xffffffec
            //   6683673e00           | and                 word ptr [edi + 0x3e], 0
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   5b                   | pop                 ebx

        $sequence_15 = { ff15???????? 57 ffd3 50 ff15???????? 33c0 397508 }
            // n = 7, score = 100
            //   ff15????????         |                     
            //   57                   | push                edi
            //   ffd3                 | call                ebx
            //   50                   | push                eax
            //   ff15????????         |                     
            //   33c0                 | xor                 eax, eax
            //   397508               | cmp                 dword ptr [ebp + 8], esi

    condition:
        7 of them and filesize < 1695744
}