rule win_upas_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.upas."
        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.upas"
        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 = { 57 e8???????? f7d8 1bf6 53 57 }
            // n = 6, score = 400
            //   57                   | push                edi
            //   e8????????           |                     
            //   f7d8                 | neg                 eax
            //   1bf6                 | sbb                 esi, esi
            //   53                   | push                ebx
            //   57                   | push                edi

        $sequence_1 = { 7508 83c8ff e9???????? 56 e8???????? 59 8945f8 }
            // n = 7, score = 400
            //   7508                 | jne                 0xa
            //   83c8ff               | or                  eax, 0xffffffff
            //   e9????????           |                     
            //   56                   | push                esi
            //   e8????????           |                     
            //   59                   | pop                 ecx
            //   8945f8               | mov                 dword ptr [ebp - 8], eax

        $sequence_2 = { 8b4508 83c040 5d c3 55 8bec 8b4d0c }
            // n = 7, score = 400
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   83c040               | add                 eax, 0x40
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   8b4d0c               | mov                 ecx, dword ptr [ebp + 0xc]

        $sequence_3 = { 50 8d8548feffff 50 8d4520 50 53 e8???????? }
            // n = 7, score = 400
            //   50                   | push                eax
            //   8d8548feffff         | lea                 eax, [ebp - 0x1b8]
            //   50                   | push                eax
            //   8d4520               | lea                 eax, [ebp + 0x20]
            //   50                   | push                eax
            //   53                   | push                ebx
            //   e8????????           |                     

        $sequence_4 = { 85c0 0f84d9000000 33c0 8945e8 85ff 0f8ecc000000 }
            // n = 6, score = 400
            //   85c0                 | test                eax, eax
            //   0f84d9000000         | je                  0xdf
            //   33c0                 | xor                 eax, eax
            //   8945e8               | mov                 dword ptr [ebp - 0x18], eax
            //   85ff                 | test                edi, edi
            //   0f8ecc000000         | jle                 0xd2

        $sequence_5 = { ff750c 8d45b8 50 e8???????? 8b45b8 }
            // n = 5, score = 400
            //   ff750c               | push                dword ptr [ebp + 0xc]
            //   8d45b8               | lea                 eax, [ebp - 0x48]
            //   50                   | push                eax
            //   e8????????           |                     
            //   8b45b8               | mov                 eax, dword ptr [ebp - 0x48]

        $sequence_6 = { 8d45cc 50 ff75f8 ff75ec ff15???????? }
            // n = 5, score = 400
            //   8d45cc               | lea                 eax, [ebp - 0x34]
            //   50                   | push                eax
            //   ff75f8               | push                dword ptr [ebp - 8]
            //   ff75ec               | push                dword ptr [ebp - 0x14]
            //   ff15????????         |                     

        $sequence_7 = { 50 ff15???????? 33c0 5f 5e 5b 83c568 }
            // n = 7, score = 400
            //   50                   | push                eax
            //   ff15????????         |                     
            //   33c0                 | xor                 eax, eax
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   5b                   | pop                 ebx
            //   83c568               | add                 ebp, 0x68

        $sequence_8 = { 57 53 e9???????? 8b4514 8b1d???????? 57 6a08 }
            // n = 7, score = 400
            //   57                   | push                edi
            //   53                   | push                ebx
            //   e9????????           |                     
            //   8b4514               | mov                 eax, dword ptr [ebp + 0x14]
            //   8b1d????????         |                     
            //   57                   | push                edi
            //   6a08                 | push                8

        $sequence_9 = { ff75e0 8d45ec 50 8d45f8 }
            // n = 4, score = 400
            //   ff75e0               | push                dword ptr [ebp - 0x20]
            //   8d45ec               | lea                 eax, [ebp - 0x14]
            //   50                   | push                eax
            //   8d45f8               | lea                 eax, [ebp - 8]

    condition:
        7 of them and filesize < 114688
}