rule win_pwnpos_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.pwnpos."
        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.pwnpos"
        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 = { e8???????? 8b10 8b4508 5f 5e c6400401 8910 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   8b10                 | mov                 edx, dword ptr [eax]
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   c6400401             | mov                 byte ptr [eax + 4], 1
            //   8910                 | mov                 dword ptr [eax], edx

        $sequence_1 = { 83bd7cffffff10 720f 8b8568ffffff 50 e8???????? 83c404 8b4df4 }
            // n = 7, score = 100
            //   83bd7cffffff10       | cmp                 dword ptr [ebp - 0x84], 0x10
            //   720f                 | jb                  0x11
            //   8b8568ffffff         | mov                 eax, dword ptr [ebp - 0x98]
            //   50                   | push                eax
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   8b4df4               | mov                 ecx, dword ptr [ebp - 0xc]

        $sequence_2 = { 8bff 55 8bec ff7510 8b450c ff34857cb44300 }
            // n = 6, score = 100
            //   8bff                 | mov                 edi, edi
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   ff7510               | push                dword ptr [ebp + 0x10]
            //   8b450c               | mov                 eax, dword ptr [ebp + 0xc]
            //   ff34857cb44300       | push                dword ptr [eax*4 + 0x43b47c]

        $sequence_3 = { 64a300000000 8965f0 8b7d08 6a20 e8???????? 8bf0 }
            // n = 6, score = 100
            //   64a300000000         | mov                 dword ptr fs:[0], eax
            //   8965f0               | mov                 dword ptr [ebp - 0x10], esp
            //   8b7d08               | mov                 edi, dword ptr [ebp + 8]
            //   6a20                 | push                0x20
            //   e8????????           |                     
            //   8bf0                 | mov                 esi, eax

        $sequence_4 = { 83c404 33c9 c70607000000 c746fc00000000 66894eec 83c620 8d56e8 }
            // n = 7, score = 100
            //   83c404               | add                 esp, 4
            //   33c9                 | xor                 ecx, ecx
            //   c70607000000         | mov                 dword ptr [esi], 7
            //   c746fc00000000       | mov                 dword ptr [esi - 4], 0
            //   66894eec             | mov                 word ptr [esi - 0x14], cx
            //   83c620               | add                 esi, 0x20
            //   8d56e8               | lea                 edx, [esi - 0x18]

        $sequence_5 = { ff34c5f84e4400 ff15???????? 5d c3 6a0c 68???????? e8???????? }
            // n = 7, score = 100
            //   ff34c5f84e4400       | push                dword ptr [eax*8 + 0x444ef8]
            //   ff15????????         |                     
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   6a0c                 | push                0xc
            //   68????????           |                     
            //   e8????????           |                     

        $sequence_6 = { 80792100 7405 8b7b08 eb1b 8b4308 }
            // n = 5, score = 100
            //   80792100             | cmp                 byte ptr [ecx + 0x21], 0
            //   7405                 | je                  7
            //   8b7b08               | mov                 edi, dword ptr [ebx + 8]
            //   eb1b                 | jmp                 0x1d
            //   8b4308               | mov                 eax, dword ptr [ebx + 8]

        $sequence_7 = { e8???????? 50 c744246c00000000 e8???????? c744246cffffffff 8b7c243c 83c404 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   50                   | push                eax
            //   c744246c00000000     | mov                 dword ptr [esp + 0x6c], 0
            //   e8????????           |                     
            //   c744246cffffffff     | mov                 dword ptr [esp + 0x6c], 0xffffffff
            //   8b7c243c             | mov                 edi, dword ptr [esp + 0x3c]
            //   83c404               | add                 esp, 4

        $sequence_8 = { 3bcf 736b 8b1d???????? 8db1404b4c00 3bf7 7602 8bf7 }
            // n = 7, score = 100
            //   3bcf                 | cmp                 ecx, edi
            //   736b                 | jae                 0x6d
            //   8b1d????????         |                     
            //   8db1404b4c00         | lea                 esi, [ecx + 0x4c4b40]
            //   3bf7                 | cmp                 esi, edi
            //   7602                 | jbe                 4
            //   8bf7                 | mov                 esi, edi

        $sequence_9 = { 8bd1 8b09 eb03 8b4908 80792100 74e6 5f }
            // n = 7, score = 100
            //   8bd1                 | mov                 edx, ecx
            //   8b09                 | mov                 ecx, dword ptr [ecx]
            //   eb03                 | jmp                 5
            //   8b4908               | mov                 ecx, dword ptr [ecx + 8]
            //   80792100             | cmp                 byte ptr [ecx + 0x21], 0
            //   74e6                 | je                  0xffffffe8
            //   5f                   | pop                 edi

    condition:
        7 of them and filesize < 638976
}