rule win_regin_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.regin."
        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.regin"
        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 = { 48 8be9 41 bf80000000 48 895010 895808 }
            // n = 7, score = 100
            //   48                   | dec                 eax
            //   8be9                 | mov                 ebp, ecx
            //   41                   | inc                 ecx
            //   bf80000000           | mov                 edi, 0x80
            //   48                   | dec                 eax
            //   895010               | mov                 dword ptr [eax + 0x10], edx
            //   895808               | mov                 dword ptr [eax + 8], ebx

        $sequence_1 = { 3905???????? 0f8538010000 833d????????00 0f842b010000 8b05???????? }
            // n = 5, score = 100
            //   3905????????         |                     
            //   0f8538010000         | jne                 0x13e
            //   833d????????00       |                     
            //   0f842b010000         | je                  0x131
            //   8b05????????         |                     

        $sequence_2 = { 0f44fe 48 8b742458 8bc7 48 83c440 }
            // n = 6, score = 100
            //   0f44fe               | cmove               edi, esi
            //   48                   | dec                 eax
            //   8b742458             | mov                 esi, dword ptr [esp + 0x58]
            //   8bc7                 | mov                 eax, edi
            //   48                   | dec                 eax
            //   83c440               | add                 esp, 0x40

        $sequence_3 = { 48 8d4c2420 4c 8bc3 e8???????? 48 8b4c2470 }
            // n = 7, score = 100
            //   48                   | dec                 eax
            //   8d4c2420             | lea                 ecx, [esp + 0x20]
            //   4c                   | dec                 esp
            //   8bc3                 | mov                 eax, ebx
            //   e8????????           |                     
            //   48                   | dec                 eax
            //   8b4c2470             | mov                 ecx, dword ptr [esp + 0x70]

        $sequence_4 = { 83ec28 83c8ff 48 85c9 7412 }
            // n = 5, score = 100
            //   83ec28               | sub                 esp, 0x28
            //   83c8ff               | or                  eax, 0xffffffff
            //   48                   | dec                 eax
            //   85c9                 | test                ecx, ecx
            //   7412                 | je                  0x14

        $sequence_5 = { ff15???????? 85c0 740c 8b05???????? 39442460 7405 }
            // n = 6, score = 100
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   740c                 | je                  0xe
            //   8b05????????         |                     
            //   39442460             | cmp                 dword ptr [esp + 0x60], eax
            //   7405                 | je                  7

        $sequence_6 = { 7708 33db 895c2460 eb2e 33db }
            // n = 5, score = 100
            //   7708                 | ja                  0xa
            //   33db                 | xor                 ebx, ebx
            //   895c2460             | mov                 dword ptr [esp + 0x60], ebx
            //   eb2e                 | jmp                 0x30
            //   33db                 | xor                 ebx, ebx

        $sequence_7 = { 3bf0 7727 48 8b0f 4c 8d4c2448 44 }
            // n = 7, score = 100
            //   3bf0                 | cmp                 esi, eax
            //   7727                 | ja                  0x29
            //   48                   | dec                 eax
            //   8b0f                 | mov                 ecx, dword ptr [edi]
            //   4c                   | dec                 esp
            //   8d4c2448             | lea                 ecx, [esp + 0x48]
            //   44                   | inc                 esp

        $sequence_8 = { 3df5000000 722c 66833b5c 7515 }
            // n = 4, score = 100
            //   3df5000000           | cmp                 eax, 0xf5
            //   722c                 | jb                  0x2e
            //   66833b5c             | cmp                 word ptr [ebx], 0x5c
            //   7515                 | jne                 0x17

        $sequence_9 = { 41 83e508 7408 41 }
            // n = 4, score = 100
            //   41                   | inc                 ecx
            //   83e508               | and                 ebp, 8
            //   7408                 | je                  0xa
            //   41                   | inc                 ecx

    condition:
        7 of them and filesize < 49152
}