rule win_shatteredglass_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.shatteredglass."
        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.shatteredglass"
        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 = { 8bec 8b4508 8d4d10 51 ff750c 6a19 }
            // n = 6, score = 100
            //   8bec                 | mov                 ebp, esp
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   8d4d10               | lea                 ecx, [ebp + 0x10]
            //   51                   | push                ecx
            //   ff750c               | push                dword ptr [ebp + 0xc]
            //   6a19                 | push                0x19

        $sequence_1 = { 3de4000000 7309 8b04c5385e4100 5d c3 33c0 }
            // n = 6, score = 100
            //   3de4000000           | cmp                 eax, 0xe4
            //   7309                 | jae                 0xb
            //   8b04c5385e4100       | mov                 eax, dword ptr [eax*8 + 0x415e38]
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   33c0                 | xor                 eax, eax

        $sequence_2 = { 33c0 eb05 1bc0 83c801 6a00 6a00 53 }
            // n = 7, score = 100
            //   33c0                 | xor                 eax, eax
            //   eb05                 | jmp                 7
            //   1bc0                 | sbb                 eax, eax
            //   83c801               | or                  eax, 1
            //   6a00                 | push                0
            //   6a00                 | push                0
            //   53                   | push                ebx

        $sequence_3 = { 0fbec2 0fbe80e0424100 83e00f eb02 33c0 8bbdbcfdffff 0fbebcc700434100 }
            // n = 7, score = 100
            //   0fbec2               | movsx               eax, dl
            //   0fbe80e0424100       | movsx               eax, byte ptr [eax + 0x4142e0]
            //   83e00f               | and                 eax, 0xf
            //   eb02                 | jmp                 4
            //   33c0                 | xor                 eax, eax
            //   8bbdbcfdffff         | mov                 edi, dword ptr [ebp - 0x244]
            //   0fbebcc700434100     | movsx               edi, byte ptr [edi + eax*8 + 0x414300]

        $sequence_4 = { c1f805 c1e106 8b0485d0d14100 0fbe440804 83e040 5d c3 }
            // n = 7, score = 100
            //   c1f805               | sar                 eax, 5
            //   c1e106               | shl                 ecx, 6
            //   8b0485d0d14100       | mov                 eax, dword ptr [eax*4 + 0x41d1d0]
            //   0fbe440804           | movsx               eax, byte ptr [eax + ecx + 4]
            //   83e040               | and                 eax, 0x40
            //   5d                   | pop                 ebp
            //   c3                   | ret                 

        $sequence_5 = { 8d4900 0fb70c77 8d41d0 6683f809 7705 }
            // n = 5, score = 100
            //   8d4900               | lea                 ecx, [ecx]
            //   0fb70c77             | movzx               ecx, word ptr [edi + esi*2]
            //   8d41d0               | lea                 eax, [ecx - 0x30]
            //   6683f809             | cmp                 ax, 9
            //   7705                 | ja                  7

        $sequence_6 = { 6810040000 53 e8???????? 83c414 f685a4fdffff10 0f8487000000 6820080000 }
            // n = 7, score = 100
            //   6810040000           | push                0x410
            //   53                   | push                ebx
            //   e8????????           |                     
            //   83c414               | add                 esp, 0x14
            //   f685a4fdffff10       | test                byte ptr [ebp - 0x25c], 0x10
            //   0f8487000000         | je                  0x8d
            //   6820080000           | push                0x820

        $sequence_7 = { 6689044da4d14100 41 ebe8 8bce 894de4 81f901010000 }
            // n = 6, score = 100
            //   6689044da4d14100     | mov                 word ptr [ecx*2 + 0x41d1a4], ax
            //   41                   | inc                 ecx
            //   ebe8                 | jmp                 0xffffffea
            //   8bce                 | mov                 ecx, esi
            //   894de4               | mov                 dword ptr [ebp - 0x1c], ecx
            //   81f901010000         | cmp                 ecx, 0x101

        $sequence_8 = { c1e706 8b049dd0d14100 0fbe443804 83e001 750a e8???????? 832000 }
            // n = 7, score = 100
            //   c1e706               | shl                 edi, 6
            //   8b049dd0d14100       | mov                 eax, dword ptr [ebx*4 + 0x41d1d0]
            //   0fbe443804           | movsx               eax, byte ptr [eax + edi + 4]
            //   83e001               | and                 eax, 1
            //   750a                 | jne                 0xc
            //   e8????????           |                     
            //   832000               | and                 dword ptr [eax], 0

        $sequence_9 = { 57 6a2e 51 e8???????? 8bf8 83c408 }
            // n = 6, score = 100
            //   57                   | push                edi
            //   6a2e                 | push                0x2e
            //   51                   | push                ecx
            //   e8????????           |                     
            //   8bf8                 | mov                 edi, eax
            //   83c408               | add                 esp, 8

    condition:
        7 of them and filesize < 273408
}