rule win_findpos_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.findpos."
        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.findpos"
        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 = { 8b7008 8b4610 3b02 0f8385000000 53 }
            // n = 5, score = 100
            //   8b7008               | mov                 esi, dword ptr [eax + 8]
            //   8b4610               | mov                 eax, dword ptr [esi + 0x10]
            //   3b02                 | cmp                 eax, dword ptr [edx]
            //   0f8385000000         | jae                 0x8b
            //   53                   | push                ebx

        $sequence_1 = { 03c3 8945f4 2bfb 740b 8b35???????? 8b4df0 ebc3 }
            // n = 7, score = 100
            //   03c3                 | add                 eax, ebx
            //   8945f4               | mov                 dword ptr [ebp - 0xc], eax
            //   2bfb                 | sub                 edi, ebx
            //   740b                 | je                  0xd
            //   8b35????????         |                     
            //   8b4df0               | mov                 ecx, dword ptr [ebp - 0x10]
            //   ebc3                 | jmp                 0xffffffc5

        $sequence_2 = { 895dfc e8???????? 837dec10 8d55d8 0f4355d8 33c9 e8???????? }
            // n = 7, score = 100
            //   895dfc               | mov                 dword ptr [ebp - 4], ebx
            //   e8????????           |                     
            //   837dec10             | cmp                 dword ptr [ebp - 0x14], 0x10
            //   8d55d8               | lea                 edx, [ebp - 0x28]
            //   0f4355d8             | cmovae              edx, dword ptr [ebp - 0x28]
            //   33c9                 | xor                 ecx, ecx
            //   e8????????           |                     

        $sequence_3 = { 7405 e8???????? a900000080 751f d9fa 833d????????00 0f8543470000 }
            // n = 7, score = 100
            //   7405                 | je                  7
            //   e8????????           |                     
            //   a900000080           | test                eax, 0x80000000
            //   751f                 | jne                 0x21
            //   d9fa                 | fsqrt               
            //   833d????????00       |                     
            //   0f8543470000         | jne                 0x4749

        $sequence_4 = { 8d4c2410 c784244803000003000000 e8???????? 6a00 6a01 8d4c2418 e9???????? }
            // n = 7, score = 100
            //   8d4c2410             | lea                 ecx, [esp + 0x10]
            //   c784244803000003000000     | mov    dword ptr [esp + 0x348], 3
            //   e8????????           |                     
            //   6a00                 | push                0
            //   6a01                 | push                1
            //   8d4c2418             | lea                 ecx, [esp + 0x18]
            //   e9????????           |                     

        $sequence_5 = { 33f6 21b5e4e7ffff 85c0 747c 8b3d???????? }
            // n = 5, score = 100
            //   33f6                 | xor                 esi, esi
            //   21b5e4e7ffff         | and                 dword ptr [ebp - 0x181c], esi
            //   85c0                 | test                eax, eax
            //   747c                 | je                  0x7e
            //   8b3d????????         |                     

        $sequence_6 = { e8???????? 3975f8 75f2 56 57 }
            // n = 5, score = 100
            //   e8????????           |                     
            //   3975f8               | cmp                 dword ptr [ebp - 8], esi
            //   75f2                 | jne                 0xfffffff4
            //   56                   | push                esi
            //   57                   | push                edi

        $sequence_7 = { 0f43ca c6041900 5b 5f b8???????? 5e 5d }
            // n = 7, score = 100
            //   0f43ca               | cmovae              ecx, edx
            //   c6041900             | mov                 byte ptr [ecx + ebx], 0
            //   5b                   | pop                 ebx
            //   5f                   | pop                 edi
            //   b8????????           |                     
            //   5e                   | pop                 esi
            //   5d                   | pop                 ebp

        $sequence_8 = { 75f2 56 57 8d45f8 50 }
            // n = 5, score = 100
            //   75f2                 | jne                 0xfffffff4
            //   56                   | push                esi
            //   57                   | push                edi
            //   8d45f8               | lea                 eax, [ebp - 8]
            //   50                   | push                eax

        $sequence_9 = { 8b450c 8945f4 8b4514 40 c745ec325a4000 894df8 }
            // n = 6, score = 100
            //   8b450c               | mov                 eax, dword ptr [ebp + 0xc]
            //   8945f4               | mov                 dword ptr [ebp - 0xc], eax
            //   8b4514               | mov                 eax, dword ptr [ebp + 0x14]
            //   40                   | inc                 eax
            //   c745ec325a4000       | mov                 dword ptr [ebp - 0x14], 0x405a32
            //   894df8               | mov                 dword ptr [ebp - 8], ecx

    condition:
        7 of them and filesize < 286720
}