rule win_photoloader_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.photoloader."
        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.photoloader"
        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 = { ff15???????? 25ffffff00 0d00000005 e9???????? 8bd7 397b1c }
            // n = 6, score = 1600
            //   ff15????????         |                     
            //   25ffffff00           | and                 eax, 0xffffff
            //   0d00000005           | or                  eax, 0x5000000
            //   e9????????           |                     
            //   8bd7                 | mov                 edx, edi
            //   397b1c               | cmp                 dword ptr [ebx + 0x1c], edi

        $sequence_1 = { 0fa2 894704 33c9 b800000040 }
            // n = 4, score = 1600
            //   0fa2                 | cpuid               
            //   894704               | mov                 dword ptr [edi + 4], eax
            //   33c9                 | xor                 ecx, ecx
            //   b800000040           | mov                 eax, 0x40000000

        $sequence_2 = { f7411400000020 7407 8b41f8 3901 }
            // n = 4, score = 1600
            //   f7411400000020       | test                dword ptr [ecx + 0x14], 0x20000000
            //   7407                 | je                  9
            //   8b41f8               | mov                 eax, dword ptr [ecx - 8]
            //   3901                 | cmp                 dword ptr [ecx], eax

        $sequence_3 = { 33c9 b800000040 0fa2 895f0c }
            // n = 4, score = 1600
            //   33c9                 | xor                 ecx, ecx
            //   b800000040           | mov                 eax, 0x40000000
            //   0fa2                 | cpuid               
            //   895f0c               | mov                 dword ptr [edi + 0xc], ebx

        $sequence_4 = { c0c003 0fb6c8 8bc1 83e10f }
            // n = 4, score = 1600
            //   c0c003               | rol                 al, 3
            //   0fb6c8               | movzx               ecx, al
            //   8bc1                 | mov                 eax, ecx
            //   83e10f               | and                 ecx, 0xf

        $sequence_5 = { 8bf7 8d6f10 ff15???????? 0f31 }
            // n = 4, score = 1600
            //   8bf7                 | mov                 esi, edi
            //   8d6f10               | lea                 ebp, [edi + 0x10]
            //   ff15????????         |                     
            //   0f31                 | rdtsc               

        $sequence_6 = { b90b010000 66394a18 8d41ed 448d59fd 440f44d8 4533c9 }
            // n = 6, score = 1500
            //   b90b010000           | cpuid               
            //   66394a18             | mov                 dword ptr [edi + 0xc], ebx
            //   8d41ed               | mov                 dword ptr [edi + 4], eax
            //   448d59fd             | xor                 ecx, ecx
            //   440f44d8             | mov                 eax, 0x40000000
            //   4533c9               | cpuid               

        $sequence_7 = { 4883ec28 ff15???????? 488bc8 48b877be9f1a2fdd2406 48f7e1 482bca }
            // n = 6, score = 1500
            //   4883ec28             | dec                 eax
            //   ff15????????         |                     
            //   488bc8               | sub                 esp, 0x28
            //   48b877be9f1a2fdd2406     | dec    eax
            //   48f7e1               | mov                 ecx, eax
            //   482bca               | dec                 eax

        $sequence_8 = { 85c0 7512 ff15???????? 25ffffff00 0d00000003 }
            // n = 5, score = 1500
            //   85c0                 | cpuid               
            //   7512                 | mov                 dword ptr [edi + 4], eax
            //   ff15????????         |                     
            //   25ffffff00           | xor                 ecx, ecx
            //   0d00000003           | mov                 eax, 0x40000000

        $sequence_9 = { e8???????? 488d97c6020000 4c8bc5 4803d6 488bcb 488b5c2430 }
            // n = 6, score = 1500
            //   e8????????           |                     
            //   488d97c6020000       | mov                 eax, 0x1a9fbe77
            //   4c8bc5               | das                 
            //   4803d6               | frstor              dword ptr [esi + eax]
            //   488bcb               | dec                 eax
            //   488b5c2430           | mul                 ecx

        $sequence_10 = { 7511 ff15???????? 25ffffff00 0fbae819 }
            // n = 4, score = 1500
            //   7511                 | mov                 edx, edi
            //   ff15????????         |                     
            //   25ffffff00           | cmp                 dword ptr [ebx + 0x1c], edi
            //   0fbae819             | jbe                 0x47

        $sequence_11 = { 8bf9 33f6 33c9 0fa2 894500 }
            // n = 5, score = 200
            //   8bf9                 | mov                 dword ptr [esp + 0x14], esi
            //   33f6                 | jmp                 0x1d
            //   33c9                 | lea                 eax, [ecx + 1]
            //   0fa2                 | mov                 dword ptr [esp + 0x14], esi
            //   894500               | mov                 dword ptr [esp + 0x10], eax

        $sequence_12 = { 03f8 8d0c7b e8???????? 03f8 }
            // n = 4, score = 200
            //   03f8                 | dec                 eax
            //   8d0c7b               | shl                 edx, 0x20
            //   e8????????           |                     
            //   03f8                 | inc                 edi

        $sequence_13 = { 7461 8d4c2410 51 8d4c2424 51 53 }
            // n = 6, score = 200
            //   7461                 | inc                 ecx
            //   8d4c2410             | sub                 ecx, ecx
            //   51                   | rol                 al, 3
            //   8d4c2424             | movzx               ecx, al
            //   51                   | mov                 eax, ecx
            //   53                   | and                 ecx, 0xf

        $sequence_14 = { 89742414 eb1b 8d4101 89742414 89442410 8d4601 }
            // n = 6, score = 200
            //   89742414             | xor                 ecx, ecx
            //   eb1b                 | mov                 eax, 0x40000000
            //   8d4101               | cpuid               
            //   89742414             | mov                 dword ptr [edi + 0xc], ebx
            //   89442410             | mov                 esi, edi
            //   8d4601               | lea                 ebp, [edi + 0x10]

        $sequence_15 = { 55 33ed c744241804000000 56 }
            // n = 4, score = 200
            //   55                   | lea                 eax, [esi + 1]
            //   33ed                 | jne                 0xffffff9c
            //   c744241804000000     | push                eax
            //   56                   | push                ecx

        $sequence_16 = { 759a 50 51 53 55 }
            // n = 5, score = 200
            //   759a                 | rdtsc               
            //   50                   | dec                 eax
            //   51                   | shl                 edx, 0x20
            //   53                   | dec                 eax
            //   55                   | or                  eax, edx

        $sequence_17 = { 7504 8907 8bf0 8d6c2410 33c9 b801000080 }
            // n = 6, score = 200
            //   7504                 | mov                 ecx, dword ptr [ebx + edx*8 + 8]
            //   8907                 | dec                 eax
            //   8bf0                 | or                  eax, edx
            //   8d6c2410             | inc                 ebx
            //   33c9                 | mov                 ecx, dword ptr [ebx + edx*8 + 0x10]
            //   b801000080           | xor                 edx, edx

    condition:
        7 of them and filesize < 107520
}