rule win_grimplant_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.grimplant."
        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.grimplant"
        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 = { e8???????? e8???????? 48898424c0000000 48899c24c8000000 c644246700 488b942418010000 488b0a }
            // n = 7, score = 100
            //   e8????????           |                     
            //   e8????????           |                     
            //   48898424c0000000     | mov                 dword ptr [esp + 0x340], 0
            //   48899c24c8000000     | dec                 eax
            //   c644246700           | lea                 edx, [esp + 0x348]
            //   488b942418010000     | dec                 eax
            //   488b0a               | mov                 ebx, dword ptr [esi + 8]

        $sequence_1 = { e8???????? 488d15f4481700 4889542468 4889442470 488d057b532300 bb2c000000 488d4c2468 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   488d15f4481700       | dec                 eax
            //   4889542468           | mov                 eax, edx
            //   4889442470           | nop                 
            //   488d057b532300       | dec                 eax
            //   bb2c000000           | mov                 ebx, dword ptr [eax + 8]
            //   488d4c2468           | dec                 eax

        $sequence_2 = { e8???????? c70010000000 833d????????00 750e 488b442420 488905???????? eb11 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   c70010000000         | dec                 eax
            //   833d????????00       |                     
            //   750e                 | mov                 ecx, dword ptr [eax + 0x30]
            //   488b442420           | dec                 eax
            //   488905????????       |                     
            //   eb11                 | mov                 eax, ebx

        $sequence_3 = { eb0f 488d3d73aa7f00 0f1f00 e8???????? 31c0 31db 4889d9 }
            // n = 7, score = 100
            //   eb0f                 | jae                 0x15c
            //   488d3d73aa7f00       | dec                 eax
            //   0f1f00               | mov                 dword ptr [esp + 0x88], eax
            //   e8????????           |                     
            //   31c0                 | dec                 eax
            //   31db                 | lea                 eax, [0xf2e01]
            //   4889d9               | nop                 

        $sequence_4 = { e8???????? 48c740080c000000 833d????????00 750c 488d1504491300 488910 eb0f }
            // n = 7, score = 100
            //   e8????????           |                     
            //   48c740080c000000     | dec                 eax
            //   833d????????00       |                     
            //   750c                 | lea                 eax, [0x31aa91]
            //   488d1504491300       | dec                 eax
            //   488910               | lea                 ecx, [esp + 0xf8]
            //   eb0f                 | test                byte ptr [eax], al

        $sequence_5 = { eb0d 4889c7 488b542458 e8???????? 488d05da5d2500 488b5c2420 488b4c2448 }
            // n = 7, score = 100
            //   eb0d                 | xor                 eax, eax
            //   4889c7               | jmp                 0x988
            //   488b542458           | dec                 eax
            //   e8????????           |                     
            //   488d05da5d2500       | mov                 ebp, dword ptr [esp + 0x58]
            //   488b5c2420           | dec                 eax
            //   488b4c2448           | add                 esp, 0x60

        $sequence_6 = { c3 440f11bc24e8010000 c644244700 488b942400030000 488b02 ffd0 488b8c24f8010000 }
            // n = 7, score = 100
            //   c3                   | mov                 dword ptr [esp + 0x18], ebx
            //   440f11bc24e8010000     | dec    eax
            //   c644244700           | lea                 eax, [0x24d8f4]
            //   488b942400030000     | dec                 eax
            //   488b02               | lea                 ebx, [esp + 0x10]
            //   ffd0                 | dec                 eax
            //   488b8c24f8010000     | mov                 eax, dword ptr [eax + 8]

        $sequence_7 = { e8???????? 488b8c2410010000 488b5148 488b842418010000 ffd2 4889442470 48895c2438 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   488b8c2410010000     | dec                 eax
            //   488b5148             | lea                 eax, [0x4522b0]
            //   488b842418010000     | jmp                 0x1672
            //   ffd2                 | xor                 eax, eax
            //   4889442470           | xor                 edx, edx
            //   48895c2438           | dec                 eax

        $sequence_8 = { e8???????? 488d057ef94e00 bb14000000 e8???????? 90 4889442408 48895c2410 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   488d057ef94e00       | dec                 eax
            //   bb14000000           | mov                 dword ptr [edx + 0x30], eax
            //   e8????????           |                     
            //   90                   | dec                 eax
            //   4889442408           | mov                 eax, edx
            //   48895c2410           | dec                 eax

        $sequence_9 = { e9???????? 488bac2400010000 4881c408010000 c3 4889442408 48895c2410 884c2418 }
            // n = 7, score = 100
            //   e9????????           |                     
            //   488bac2400010000     | mov                 ebp, dword ptr [esp + 0x30]
            //   4881c408010000       | dec                 eax
            //   c3                   | add                 esp, 0x38
            //   4889442408           | dec                 eax
            //   48895c2410           | mov                 ebp, dword ptr [esp + 0x30]
            //   884c2418             | dec                 eax

    condition:
        7 of them and filesize < 19940352
}