rule win_onhat_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.onhat."
        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.onhat"
        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 = { c3 8a4001 41 3bcd 890d???????? 7d4b 8b148e }
            // n = 7, score = 200
            //   c3                   | ret                 
            //   8a4001               | mov                 al, byte ptr [eax + 1]
            //   41                   | inc                 ecx
            //   3bcd                 | cmp                 ecx, ebp
            //   890d????????         |                     
            //   7d4b                 | jge                 0x4d
            //   8b148e               | mov                 edx, dword ptr [esi + ecx*4]

        $sequence_1 = { e8???????? 83c404 b807000080 5f }
            // n = 4, score = 200
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   b807000080           | mov                 eax, 0x80000007
            //   5f                   | pop                 edi

        $sequence_2 = { 56 e8???????? 40 f7d8 1bc0 23c6 5e }
            // n = 7, score = 200
            //   56                   | push                esi
            //   e8????????           |                     
            //   40                   | inc                 eax
            //   f7d8                 | neg                 eax
            //   1bc0                 | sbb                 eax, eax
            //   23c6                 | and                 eax, esi
            //   5e                   | pop                 esi

        $sequence_3 = { 55 89442418 e8???????? 8be8 83c408 }
            // n = 5, score = 200
            //   55                   | push                ebp
            //   89442418             | mov                 dword ptr [esp + 0x18], eax
            //   e8????????           |                     
            //   8be8                 | mov                 ebp, eax
            //   83c408               | add                 esp, 8

        $sequence_4 = { 884c2438 663bf0 7508 8b74243c }
            // n = 4, score = 200
            //   884c2438             | mov                 byte ptr [esp + 0x38], cl
            //   663bf0               | cmp                 si, ax
            //   7508                 | jne                 0xa
            //   8b74243c             | mov                 esi, dword ptr [esp + 0x3c]

        $sequence_5 = { c644242f00 aa ffd6 8b2d???????? 8d842494000000 50 ffd5 }
            // n = 7, score = 200
            //   c644242f00           | mov                 byte ptr [esp + 0x2f], 0
            //   aa                   | stosb               byte ptr es:[edi], al
            //   ffd6                 | call                esi
            //   8b2d????????         |                     
            //   8d842494000000       | lea                 eax, [esp + 0x94]
            //   50                   | push                eax
            //   ffd5                 | call                ebp

        $sequence_6 = { 81e6ffff0000 56 55 53 e8???????? 8bf8 85ff }
            // n = 7, score = 200
            //   81e6ffff0000         | and                 esi, 0xffff
            //   56                   | push                esi
            //   55                   | push                ebp
            //   53                   | push                ebx
            //   e8????????           |                     
            //   8bf8                 | mov                 edi, eax
            //   85ff                 | test                edi, edi

        $sequence_7 = { c684249001000052 c684249101000054 888c2492010000 889c2493010000 c684249401000020 8884249d010000 888424a7010000 }
            // n = 7, score = 200
            //   c684249001000052     | mov                 byte ptr [esp + 0x190], 0x52
            //   c684249101000054     | mov                 byte ptr [esp + 0x191], 0x54
            //   888c2492010000       | mov                 byte ptr [esp + 0x192], cl
            //   889c2493010000       | mov                 byte ptr [esp + 0x193], bl
            //   c684249401000020     | mov                 byte ptr [esp + 0x194], 0x20
            //   8884249d010000       | mov                 byte ptr [esp + 0x19d], al
            //   888424a7010000       | mov                 byte ptr [esp + 0x1a7], al

        $sequence_8 = { 83c408 e9???????? ff15???????? e9???????? 68???????? eb05 68???????? }
            // n = 7, score = 200
            //   83c408               | add                 esp, 8
            //   e9????????           |                     
            //   ff15????????         |                     
            //   e9????????           |                     
            //   68????????           |                     
            //   eb05                 | jmp                 7
            //   68????????           |                     

        $sequence_9 = { 8d8c2440020000 8d9424cc000000 51 e9???????? a1???????? 50 ff15???????? }
            // n = 7, score = 200
            //   8d8c2440020000       | lea                 ecx, [esp + 0x240]
            //   8d9424cc000000       | lea                 edx, [esp + 0xcc]
            //   51                   | push                ecx
            //   e9????????           |                     
            //   a1????????           |                     
            //   50                   | push                eax
            //   ff15????????         |                     

    condition:
        7 of them and filesize < 57344
}