rule win_oni_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.oni."
        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.oni"
        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 = { 53 56 57 8bd9 8d85f8f7ffff }
            // n = 5, score = 200
            //   53                   | push                ebx
            //   56                   | push                esi
            //   57                   | push                edi
            //   8bd9                 | mov                 ebx, ecx
            //   8d85f8f7ffff         | lea                 eax, [ebp - 0x808]

        $sequence_1 = { 8d8c24a0020000 c78424b40200000f000000 c78424b002000000000000 c68424a002000000 e8???????? 8d8c24b0020000 e8???????? }
            // n = 7, score = 200
            //   8d8c24a0020000       | lea                 ecx, [esp + 0x2a0]
            //   c78424b40200000f000000     | mov    dword ptr [esp + 0x2b4], 0xf
            //   c78424b002000000000000     | mov    dword ptr [esp + 0x2b0], 0
            //   c68424a002000000     | mov                 byte ptr [esp + 0x2a0], 0
            //   e8????????           |                     
            //   8d8c24b0020000       | lea                 ecx, [esp + 0x2b0]
            //   e8????????           |                     

        $sequence_2 = { 0f87cb000000 8bc8 51 e8???????? 83c404 8b451c c745f80f000000 }
            // n = 7, score = 200
            //   0f87cb000000         | ja                  0xd1
            //   8bc8                 | mov                 ecx, eax
            //   51                   | push                ecx
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   8b451c               | mov                 eax, dword ptr [ebp + 0x1c]
            //   c745f80f000000       | mov                 dword ptr [ebp - 8], 0xf

        $sequence_3 = { 8bca 57 8d7901 660f1f440000 8a01 }
            // n = 5, score = 200
            //   8bca                 | mov                 ecx, edx
            //   57                   | push                edi
            //   8d7901               | lea                 edi, [ecx + 1]
            //   660f1f440000         | nop                 word ptr [eax + eax]
            //   8a01                 | mov                 al, byte ptr [ecx]

        $sequence_4 = { 8b03 8b4004 8b441814 25c0010000 83f840 7435 85f6 }
            // n = 7, score = 200
            //   8b03                 | mov                 eax, dword ptr [ebx]
            //   8b4004               | mov                 eax, dword ptr [eax + 4]
            //   8b441814             | mov                 eax, dword ptr [eax + ebx + 0x14]
            //   25c0010000           | and                 eax, 0x1c0
            //   83f840               | cmp                 eax, 0x40
            //   7435                 | je                  0x37
            //   85f6                 | test                esi, esi

        $sequence_5 = { 8b4d80 40 3d00100000 722a f6c11f 0f8535030000 8b41fc }
            // n = 7, score = 200
            //   8b4d80               | mov                 ecx, dword ptr [ebp - 0x80]
            //   40                   | inc                 eax
            //   3d00100000           | cmp                 eax, 0x1000
            //   722a                 | jb                  0x2c
            //   f6c11f               | test                cl, 0x1f
            //   0f8535030000         | jne                 0x33b
            //   8b41fc               | mov                 eax, dword ptr [ecx - 4]

        $sequence_6 = { 83e03f c1ff06 6bd830 8b04bd90884300 f644032801 7444 837c0318ff }
            // n = 7, score = 200
            //   83e03f               | and                 eax, 0x3f
            //   c1ff06               | sar                 edi, 6
            //   6bd830               | imul                ebx, eax, 0x30
            //   8b04bd90884300       | mov                 eax, dword ptr [edi*4 + 0x438890]
            //   f644032801           | test                byte ptr [ebx + eax + 0x28], 1
            //   7444                 | je                  0x46
            //   837c0318ff           | cmp                 dword ptr [ebx + eax + 0x18], -1

        $sequence_7 = { 2bd3 b8abaaaa2a f7ea c1fa02 8bfa }
            // n = 5, score = 200
            //   2bd3                 | sub                 edx, ebx
            //   b8abaaaa2a           | mov                 eax, 0x2aaaaaab
            //   f7ea                 | imul                edx
            //   c1fa02               | sar                 edx, 2
            //   8bfa                 | mov                 edi, edx

        $sequence_8 = { f6c11f 0f85c1000000 8b41fc 3bc1 0f83bb000000 }
            // n = 5, score = 200
            //   f6c11f               | test                cl, 0x1f
            //   0f85c1000000         | jne                 0xc7
            //   8b41fc               | mov                 eax, dword ptr [ecx - 4]
            //   3bc1                 | cmp                 eax, ecx
            //   0f83bb000000         | jae                 0xc1

        $sequence_9 = { 8b048d90884300 f644382848 58 743a 668b55fc 663bd0 7505 }
            // n = 7, score = 200
            //   8b048d90884300       | mov                 eax, dword ptr [ecx*4 + 0x438890]
            //   f644382848           | test                byte ptr [eax + edi + 0x28], 0x48
            //   58                   | pop                 eax
            //   743a                 | je                  0x3c
            //   668b55fc             | mov                 dx, word ptr [ebp - 4]
            //   663bd0               | cmp                 dx, ax
            //   7505                 | jne                 7

    condition:
        7 of them and filesize < 499712
}