rule win_rgdoor_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.rgdoor."
        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.rgdoor"
        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 = { 488d0d1aa30100 e8???????? 48ffc0 4803d8 488bd7 488bcb e8???????? }
            // n = 7, score = 100
            //   488d0d1aa30100       | mov                 dword ptr [esp + 0x30], ebx
            //   e8????????           |                     
            //   48ffc0               | dec                 esp
            //   4803d8               | mov                 edi, eax
            //   488bd7               | dec                 eax
            //   488bcb               | mov                 dword ptr [esp + 0x38], eax
            //   e8????????           |                     

        $sequence_1 = { 750a 8bde 448be6 448bef eb08 8bdf }
            // n = 6, score = 100
            //   750a                 | lea                 eax, [0x1b3e7]
            //   8bde                 | mov                 ebx, edx
            //   448be6               | dec                 eax
            //   448bef               | mov                 edi, ecx
            //   eb08                 | dec                 eax
            //   8bdf                 | mov                 dword ptr [ecx], eax

        $sequence_2 = { 4885c0 750d e8???????? c70009000000 eb4e 488bce e8???????? }
            // n = 7, score = 100
            //   4885c0               | dec                 eax
            //   750d                 | mov                 ecx, ebx
            //   e8????????           |                     
            //   c70009000000         | dec                 eax
            //   eb4e                 | lea                 edx, [0x1587a]
            //   488bce               | dec                 eax
            //   e8????????           |                     

        $sequence_3 = { 443032 41ffc0 488d5201 4963c0 483b45a8 76ed 448b45a8 }
            // n = 7, score = 100
            //   443032               | je                  0x555
            //   41ffc0               | xor                 eax, eax
            //   488d5201             | jmp                 0x582
            //   4963c0               | mov                 eax, dword ptr [ecx + 0x18]
            //   483b45a8             | and                 eax, 0x10
            //   76ed                 | dec                 eax
            //   448b45a8             | add                 esp, 0x28

        $sequence_4 = { 7559 6690 4c8bc3 ba80000000 488d8d10020000 e8???????? }
            // n = 6, score = 100
            //   7559                 | dec                 eax
            //   6690                 | lea                 ecx, [0x27f3f]
            //   4c8bc3               | dec                 eax
            //   ba80000000           | mov                 eax, ecx
            //   488d8d10020000       | test                byte ptr [eax + 0x38], 0x7f
            //   e8????????           |                     

        $sequence_5 = { 4885c0 0f84a1020000 498d5509 48c74424780f000000 4c897c2470 }
            // n = 5, score = 100
            //   4885c0               | dec                 eax
            //   0f84a1020000         | arpl                cx, cx
            //   498d5509             | dec                 eax
            //   48c74424780f000000     | lea    edx, [0x1cd58]
            //   4c897c2470           | dec                 eax

        $sequence_6 = { 49ffc0 3bcb 0f8c42ffffff 4c8bb42450010000 }
            // n = 4, score = 100
            //   49ffc0               | dec                 eax
            //   3bcb                 | mov                 ecx, ebx
            //   0f8c42ffffff         | call                dword ptr [eax + 0x90]
            //   4c8bb42450010000     | test                eax, eax

        $sequence_7 = { 66660f1f840000000000 4863c2 f30f6f0418 660fefc6 f30f7f0418 8d4210 4863c8 }
            // n = 7, score = 100
            //   66660f1f840000000000     | lea    eax, [0xa4c1]
            //   4863c2               | dec                 eax
            //   f30f6f0418           | lea                 ecx, [0x9a06]
            //   660fefc6             | dec                 eax
            //   f30f7f0418           | lea                 eax, [0xa54c]
            //   8d4210               | dec                 eax
            //   4863c8               | lea                 eax, [0xa57f]

        $sequence_8 = { 8b7c2458 488b4c2478 e8???????? 488bce e8???????? 8b9c2460010000 }
            // n = 6, score = 100
            //   8b7c2458             | lea                 ecx, [ebp - 0x20]
            //   488b4c2478           | nop                 
            //   e8????????           |                     
            //   488bce               | dec                 esp
            //   e8????????           |                     
            //   8b9c2460010000       | lea                 edi, [ebp - 0x48]

        $sequence_9 = { 4c8d45d8 488b4dd8 4883ff10 4c0f43c1 }
            // n = 4, score = 100
            //   4c8d45d8             | mov                 dword ptr [ecx + 0xd4], esi
            //   488b4dd8             | dec                 eax
            //   4883ff10             | mov                 dword ptr [ecx + 0x118], eax
            //   4c0f43c1             | xor                 eax, eax

    condition:
        7 of them and filesize < 475136
}