rule win_htprat_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.htprat."
        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.htprat"
        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 = { 837de810 8b5dd4 898578ffffff 7303 8d5dd4 33d2 8bc7 }
            // n = 7, score = 200
            //   837de810             | cmp                 dword ptr [ebp - 0x18], 0x10
            //   8b5dd4               | mov                 ebx, dword ptr [ebp - 0x2c]
            //   898578ffffff         | mov                 dword ptr [ebp - 0x88], eax
            //   7303                 | jae                 5
            //   8d5dd4               | lea                 ebx, [ebp - 0x2c]
            //   33d2                 | xor                 edx, edx
            //   8bc7                 | mov                 eax, edi

        $sequence_1 = { 8b5d08 8b13 66833a22 7561 8365e400 33c0 c745e807000000 }
            // n = 7, score = 200
            //   8b5d08               | mov                 ebx, dword ptr [ebp + 8]
            //   8b13                 | mov                 edx, dword ptr [ebx]
            //   66833a22             | cmp                 word ptr [edx], 0x22
            //   7561                 | jne                 0x63
            //   8365e400             | and                 dword ptr [ebp - 0x1c], 0
            //   33c0                 | xor                 eax, eax
            //   c745e807000000       | mov                 dword ptr [ebp - 0x18], 7

        $sequence_2 = { 3b08 751a 8d410c 8bcb e8???????? 84c0 0f84d2000000 }
            // n = 7, score = 200
            //   3b08                 | cmp                 ecx, dword ptr [eax]
            //   751a                 | jne                 0x1c
            //   8d410c               | lea                 eax, [ecx + 0xc]
            //   8bcb                 | mov                 ecx, ebx
            //   e8????????           |                     
            //   84c0                 | test                al, al
            //   0f84d2000000         | je                  0xd8

        $sequence_3 = { 33c9 66890c78 b001 ebc5 55 8bec }
            // n = 6, score = 200
            //   33c9                 | xor                 ecx, ecx
            //   66890c78             | mov                 word ptr [eax + edi*2], cx
            //   b001                 | mov                 al, 1
            //   ebc5                 | jmp                 0xffffffc7
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp

        $sequence_4 = { c9 c3 55 8bec 8b4d08 e8???????? ff7508 }
            // n = 7, score = 200
            //   c9                   | leave               
            //   c3                   | ret                 
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   8b4d08               | mov                 ecx, dword ptr [ebp + 8]
            //   e8????????           |                     
            //   ff7508               | push                dword ptr [ebp + 8]

        $sequence_5 = { ff15???????? 85c0 750c ff15???????? 89831c010000 39bbd0000000 766c }
            // n = 7, score = 200
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   750c                 | jne                 0xe
            //   ff15????????         |                     
            //   89831c010000         | mov                 dword ptr [ebx + 0x11c], eax
            //   39bbd0000000         | cmp                 dword ptr [ebx + 0xd0], edi
            //   766c                 | jbe                 0x6e

        $sequence_6 = { eb85 8365fc00 b8???????? c3 33db e9???????? 55 }
            // n = 7, score = 200
            //   eb85                 | jmp                 0xffffff87
            //   8365fc00             | and                 dword ptr [ebp - 4], 0
            //   b8????????           |                     
            //   c3                   | ret                 
            //   33db                 | xor                 ebx, ebx
            //   e9????????           |                     
            //   55                   | push                ebp

        $sequence_7 = { 8365fc00 8bce 8bd7 e8???????? 8b75cc 50 }
            // n = 6, score = 200
            //   8365fc00             | and                 dword ptr [ebp - 4], 0
            //   8bce                 | mov                 ecx, esi
            //   8bd7                 | mov                 edx, edi
            //   e8????????           |                     
            //   8b75cc               | mov                 esi, dword ptr [ebp - 0x34]
            //   50                   | push                eax

        $sequence_8 = { 83f966 7f3d 7434 83f922 7428 }
            // n = 5, score = 200
            //   83f966               | cmp                 ecx, 0x66
            //   7f3d                 | jg                  0x3f
            //   7434                 | je                  0x36
            //   83f922               | cmp                 ecx, 0x22
            //   7428                 | je                  0x2a

        $sequence_9 = { 8d7dcc e8???????? 8b5dcc 6a01 33ff 8d75d0 e8???????? }
            // n = 7, score = 200
            //   8d7dcc               | lea                 edi, [ebp - 0x34]
            //   e8????????           |                     
            //   8b5dcc               | mov                 ebx, dword ptr [ebp - 0x34]
            //   6a01                 | push                1
            //   33ff                 | xor                 edi, edi
            //   8d75d0               | lea                 esi, [ebp - 0x30]
            //   e8????????           |                     

    condition:
        7 of them and filesize < 278528
}