rule win_tinyloader_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.tinyloader."
        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.tinyloader"
        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 = { 5b 89d0 c1c010 6689c8 90 }
            // n = 5, score = 200
            //   5b                   | pop                 ebx
            //   89d0                 | mov                 eax, edx
            //   c1c010               | rol                 eax, 0x10
            //   6689c8               | mov                 ax, cx
            //   90                   | nop                 

        $sequence_1 = { 8b1d???????? 90 8998f8070000 90 }
            // n = 4, score = 200
            //   8b1d????????         |                     
            //   90                   | nop                 
            //   8998f8070000         | mov                 dword ptr [eax + 0x7f8], ebx
            //   90                   | nop                 

        $sequence_2 = { 7402 eb42 8b4500 83c00c }
            // n = 4, score = 100
            //   7402                 | je                  4
            //   eb42                 | jmp                 0x44
            //   8b4500               | mov                 eax, dword ptr [ebp]
            //   83c00c               | add                 eax, 0xc

        $sequence_3 = { 8985a0050000 0500200000 8985a8050000 0500080000 894508 }
            // n = 5, score = 100
            //   8985a0050000         | mov                 dword ptr [ebp + 0x5a0], eax
            //   0500200000           | add                 eax, 0x2000
            //   8985a8050000         | mov                 dword ptr [ebp + 0x5a8], eax
            //   0500080000           | add                 eax, 0x800
            //   894508               | mov                 dword ptr [ebp + 8], eax

        $sequence_4 = { ff15???????? 48 83c420 48 83ec20 48 8d0dea0e0000 }
            // n = 7, score = 100
            //   ff15????????         |                     
            //   48                   | dec                 eax
            //   83c420               | add                 esp, 0x20
            //   48                   | dec                 eax
            //   83ec20               | sub                 esp, 0x20
            //   48                   | dec                 eax
            //   8d0dea0e0000         | lea                 ecx, [0xeea]

        $sequence_5 = { 83c420 c705????????00010000 48 83ec20 }
            // n = 4, score = 100
            //   83c420               | add                 esp, 0x20
            //   c705????????00010000     |     
            //   48                   | dec                 eax
            //   83ec20               | sub                 esp, 0x20

        $sequence_6 = { 750a c783000400000c000000 8b8540050000 8b5d00 894308 8b85f8070000 8b5d00 }
            // n = 7, score = 100
            //   750a                 | jne                 0xc
            //   c783000400000c000000     | mov    dword ptr [ebx + 0x400], 0xc
            //   8b8540050000         | mov                 eax, dword ptr [ebp + 0x540]
            //   8b5d00               | mov                 ebx, dword ptr [ebp]
            //   894308               | mov                 dword ptr [ebx + 8], eax
            //   8b85f8070000         | mov                 eax, dword ptr [ebp + 0x7f8]
            //   8b5d00               | mov                 ebx, dword ptr [ebp]

        $sequence_7 = { 90 48 895830 90 48 8b1d???????? }
            // n = 6, score = 100
            //   90                   | nop                 
            //   48                   | dec                 eax
            //   895830               | mov                 dword ptr [eax + 0x30], ebx
            //   90                   | nop                 
            //   48                   | dec                 eax
            //   8b1d????????         |                     

        $sequence_8 = { ff15???????? 8985b8050000 6832a00000 ff15???????? }
            // n = 4, score = 100
            //   ff15????????         |                     
            //   8985b8050000         | mov                 dword ptr [ebp + 0x5b8], eax
            //   6832a00000           | push                0xa032
            //   ff15????????         |                     

        $sequence_9 = { 48 c7c200800200 49 c7c000300000 }
            // n = 4, score = 100
            //   48                   | dec                 eax
            //   c7c200800200         | mov                 edx, 0x28000
            //   49                   | dec                 ecx
            //   c7c000300000         | mov                 eax, 0x3000

        $sequence_10 = { 50 ff95b0020000 83bd4005000001 7502 }
            // n = 4, score = 100
            //   50                   | push                eax
            //   ff95b0020000         | call                dword ptr [ebp + 0x2b0]
            //   83bd4005000001       | cmp                 dword ptr [ebp + 0x540], 1
            //   7502                 | jne                 4

        $sequence_11 = { 8b4500 8b8000040000 83f80c 7702 eb28 83e80c 39c3 }
            // n = 7, score = 100
            //   8b4500               | mov                 eax, dword ptr [ebp]
            //   8b8000040000         | mov                 eax, dword ptr [eax + 0x400]
            //   83f80c               | cmp                 eax, 0xc
            //   7702                 | ja                  4
            //   eb28                 | jmp                 0x2a
            //   83e80c               | sub                 eax, 0xc
            //   39c3                 | cmp                 ebx, eax

        $sequence_12 = { 90 8b1d???????? 90 895838 90 }
            // n = 5, score = 100
            //   90                   | nop                 
            //   8b1d????????         |                     
            //   90                   | nop                 
            //   895838               | mov                 dword ptr [eax + 0x38], ebx
            //   90                   | nop                 

        $sequence_13 = { 0500080000 894508 0500200000 894518 0500200000 894510 }
            // n = 6, score = 100
            //   0500080000           | add                 eax, 0x800
            //   894508               | mov                 dword ptr [ebp + 8], eax
            //   0500200000           | add                 eax, 0x2000
            //   894518               | mov                 dword ptr [ebp + 0x18], eax
            //   0500200000           | add                 eax, 0x2000
            //   894510               | mov                 dword ptr [ebp + 0x10], eax

        $sequence_14 = { 6a00 ff15???????? 90 8b1d???????? }
            // n = 4, score = 100
            //   6a00                 | push                0
            //   ff15????????         |                     
            //   90                   | nop                 
            //   8b1d????????         |                     

        $sequence_15 = { 90 6a40 6800300000 6800800200 6a00 ff15???????? }
            // n = 6, score = 100
            //   90                   | nop                 
            //   6a40                 | push                0x40
            //   6800300000           | push                0x3000
            //   6800800200           | push                0x28000
            //   6a00                 | push                0
            //   ff15????????         |                     

        $sequence_16 = { 81fb68040000 730d 90 48 }
            // n = 4, score = 100
            //   81fb68040000         | cmp                 ebx, 0x468
            //   730d                 | jae                 0xf
            //   90                   | nop                 
            //   48                   | dec                 eax

        $sequence_17 = { 6800040000 53 ffb5b8050000 ff15???????? 83f8ff }
            // n = 5, score = 100
            //   6800040000           | push                0x400
            //   53                   | push                ebx
            //   ffb5b8050000         | push                dword ptr [ebp + 0x5b8]
            //   ff15????????         |                     
            //   83f8ff               | cmp                 eax, -1

        $sequence_18 = { 89c6 90 0500400100 90 31db 90 90 }
            // n = 7, score = 100
            //   89c6                 | mov                 esi, eax
            //   90                   | nop                 
            // 
            //   90                   | nop                 
            //   31db                 | xor                 ebx, ebx
            //   90                   | nop                 
            //   90                   | nop                 

        $sequence_19 = { ff15???????? 8d3500304000 89c7 53 }
            // n = 4, score = 100
            //   ff15????????         |                     
            //   8d3500304000         | lea                 esi, [0x403000]
            //   89c7                 | mov                 edi, eax
            //   53                   | push                ebx

        $sequence_20 = { 895838 90 48 89c6 90 48 0500400100 }
            // n = 7, score = 100
            //   895838               | mov                 dword ptr [eax + 0x38], ebx
            //   90                   | nop                 
            //   48                   | dec                 eax
            //   89c6                 | mov                 esi, eax
            //   90                   | nop                 
            //   48                   | dec                 eax
            //   0500400100           | add                 eax, 0x14000

        $sequence_21 = { 6c 00ff 15???????? e8???????? 53 68656c6c45 }
            // n = 6, score = 100
            //   6c                   | insb                byte ptr es:[edi], dx
            //   00ff                 | add                 bh, bh
            //   15????????           |                     
            //   e8????????           |                     
            //   53                   | push                ebx
            //   68656c6c45           | push                0x456c6c65

    condition:
        7 of them and filesize < 40960
}