rule win_ghole_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.ghole."
        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.ghole"
        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 = { 0f8487000000 83f808 740a 83f801 7464 e9???????? 837dfc00 }
            // n = 7, score = 100
            //   0f8487000000         | je                  0x8d
            //   83f808               | cmp                 eax, 8
            //   740a                 | je                  0xc
            //   83f801               | cmp                 eax, 1
            //   7464                 | je                  0x66
            //   e9????????           |                     
            //   837dfc00             | cmp                 dword ptr [ebp - 4], 0

        $sequence_1 = { 41 5c c3 48 8b0d???????? e8???????? 4c }
            // n = 7, score = 100
            //   41                   | inc                 ecx
            //   5c                   | pop                 esp
            //   c3                   | ret                 
            //   48                   | dec                 eax
            //   8b0d????????         |                     
            //   e8????????           |                     
            //   4c                   | dec                 esp

        $sequence_2 = { 48 8b8d08f7ffff 48 8b45d8 48 89ce 48 }
            // n = 7, score = 100
            //   48                   | dec                 eax
            //   8b8d08f7ffff         | mov                 ecx, dword ptr [ebp - 0x8f8]
            //   48                   | dec                 eax
            //   8b45d8               | mov                 eax, dword ptr [ebp - 0x28]
            //   48                   | dec                 eax
            //   89ce                 | mov                 esi, ecx
            //   48                   | dec                 eax

        $sequence_3 = { e9???????? 48 8b45e8 48 8b4038 48 85c0 }
            // n = 7, score = 100
            //   e9????????           |                     
            //   48                   | dec                 eax
            //   8b45e8               | mov                 eax, dword ptr [ebp - 0x18]
            //   48                   | dec                 eax
            //   8b4038               | mov                 eax, dword ptr [eax + 0x38]
            //   48                   | dec                 eax
            //   85c0                 | test                eax, eax

        $sequence_4 = { 8d45c8 48 89c7 e8???????? 48 }
            // n = 5, score = 100
            //   8d45c8               | lea                 eax, [ebp - 0x38]
            //   48                   | dec                 eax
            //   89c7                 | mov                 edi, eax
            //   e8????????           |                     
            //   48                   | dec                 eax

        $sequence_5 = { 89c7 e8???????? 85c0 7407 b8ffffffff eb6b 48 }
            // n = 7, score = 100
            //   89c7                 | mov                 edi, eax
            //   e8????????           |                     
            //   85c0                 | test                eax, eax
            //   7407                 | je                  9
            //   b8ffffffff           | mov                 eax, 0xffffffff
            //   eb6b                 | jmp                 0x6d
            //   48                   | dec                 eax

        $sequence_6 = { 48 89c7 e8???????? 48 8945f8 48 8b4df0 }
            // n = 7, score = 100
            //   48                   | dec                 eax
            //   89c7                 | mov                 edi, eax
            //   e8????????           |                     
            //   48                   | dec                 eax
            //   8945f8               | mov                 dword ptr [ebp - 8], eax
            //   48                   | dec                 eax
            //   8b4df0               | mov                 ecx, dword ptr [ebp - 0x10]

        $sequence_7 = { 98 48 c1e006 48 89c7 e8???????? 48 }
            // n = 7, score = 100
            //   98                   | cwde                
            //   48                   | dec                 eax
            //   c1e006               | shl                 eax, 6
            //   48                   | dec                 eax
            //   89c7                 | mov                 edi, eax
            //   e8????????           |                     
            //   48                   | dec                 eax

        $sequence_8 = { 663d2000 7406 663d0900 75b3 4d 85c0 740b }
            // n = 7, score = 100
            //   663d2000             | cmp                 ax, 0x20
            //   7406                 | je                  8
            //   663d0900             | cmp                 ax, 9
            //   75b3                 | jne                 0xffffffb5
            //   4d                   | dec                 ebp
            //   85c0                 | test                eax, eax
            //   740b                 | je                  0xd

        $sequence_9 = { e8???????? 48 8905???????? 48 8d355e700000 48 }
            // n = 6, score = 100
            //   e8????????           |                     
            //   48                   | dec                 eax
            //   8905????????         |                     
            //   48                   | dec                 eax
            //   8d355e700000         | lea                 esi, [0x705e]
            //   48                   | dec                 eax

    condition:
        7 of them and filesize < 622592
}