rule win_bernhardpos_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.bernhardpos."
        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.bernhardpos"
        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 = { c1e806 83e03f 8b4d0c 034df4 8a9020544100 }
            // n = 5, score = 200
            //   c1e806               | shr                 eax, 6
            //   83e03f               | and                 eax, 0x3f
            //   8b4d0c               | mov                 ecx, dword ptr [ebp + 0xc]
            //   034df4               | add                 ecx, dword ptr [ebp - 0xc]
            //   8a9020544100         | mov                 dl, byte ptr [eax + 0x415420]

        $sequence_1 = { c645fd64 c645fe65 c645ff00 b801000000 }
            // n = 4, score = 200
            //   c645fd64             | mov                 byte ptr [ebp - 3], 0x64
            //   c645fe65             | mov                 byte ptr [ebp - 2], 0x65
            //   c645ff00             | mov                 byte ptr [ebp - 1], 0
            //   b801000000           | mov                 eax, 1

        $sequence_2 = { 817dfcffffff6f 7407 33c0 e9???????? }
            // n = 4, score = 200
            //   817dfcffffff6f       | cmp                 dword ptr [ebp - 4], 0x6fffffff
            //   7407                 | je                  9
            //   33c0                 | xor                 eax, eax
            //   e9????????           |                     

        $sequence_3 = { 83bd4cfeffff00 7e0c c78508feffff01000000 eb0a }
            // n = 4, score = 200
            //   83bd4cfeffff00       | cmp                 dword ptr [ebp - 0x1b4], 0
            //   7e0c                 | jle                 0xe
            //   c78508feffff01000000     | mov    dword ptr [ebp - 0x1f8], 1
            //   eb0a                 | jmp                 0xc

        $sequence_4 = { ff15???????? 81bdccfdffffd8010000 0f85d2000000 6a40 8d45a8 }
            // n = 5, score = 200
            //   ff15????????         |                     
            //   81bdccfdffffd8010000     | cmp    dword ptr [ebp - 0x234], 0x1d8
            //   0f85d2000000         | jne                 0xd8
            //   6a40                 | push                0x40
            //   8d45a8               | lea                 eax, [ebp - 0x58]

        $sequence_5 = { 83c408 8b4508 50 e8???????? 83c404 b801000000 }
            // n = 6, score = 200
            //   83c408               | add                 esp, 8
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   50                   | push                eax
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   b801000000           | mov                 eax, 1

        $sequence_6 = { 83e863 5f 5e 5b }
            // n = 4, score = 200
            //   83e863               | sub                 eax, 0x63
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   5b                   | pop                 ebx

        $sequence_7 = { e8???????? 83c408 c785e8fbffff00000000 c785e4fbffff00000000 c785c0fbffff24000000 }
            // n = 5, score = 200
            //   e8????????           |                     
            //   83c408               | add                 esp, 8
            //   c785e8fbffff00000000     | mov    dword ptr [ebp - 0x418], 0
            //   c785e4fbffff00000000     | mov    dword ptr [ebp - 0x41c], 0
            //   c785c0fbffff24000000     | mov    dword ptr [ebp - 0x440], 0x24

        $sequence_8 = { e8???????? a3???????? 68a86b4aa0 a1???????? 50 e8???????? }
            // n = 6, score = 200
            //   e8????????           |                     
            //   a3????????           |                     
            //   68a86b4aa0           | push                0xa04a6ba8
            //   a1????????           |                     
            //   50                   | push                eax
            //   e8????????           |                     

        $sequence_9 = { b801000000 6bc800 81c1???????? 898d58feffff 6a65 ff15???????? 8b8d58feffff }
            // n = 7, score = 200
            //   b801000000           | mov                 eax, 1
            //   6bc800               | imul                ecx, eax, 0
            //   81c1????????         |                     
            //   898d58feffff         | mov                 dword ptr [ebp - 0x1a8], ecx
            //   6a65                 | push                0x65
            //   ff15????????         |                     
            //   8b8d58feffff         | mov                 ecx, dword ptr [ebp - 0x1a8]

    condition:
        7 of them and filesize < 368640
}