rule win_nightshade_c2_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.nightshade_c2."
        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.nightshade_c2"
        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 = { 8bc1 89442438 eba1 837c243000 7f08 c744244401000000 488b4c2468 }
            // n = 7, score = 100
            //   8bc1                 | dec                 eax
            //   89442438             | mov                 dword ptr [esp + 0x30], eax
            //   eba1                 | dec                 eax
            //   837c243000           | arpl                word ptr [esp + 0x60], ax
            //   7f08                 | dec                 esp
            //   c744244401000000     | mov                 eax, eax
            //   488b4c2468           | dec                 eax

        $sequence_1 = { ba02000000 488b8c24c0000000 e8???????? 4889442450 48837c245000 7505 e9???????? }
            // n = 7, score = 100
            //   ba02000000           | je                  0x1da1
            //   488b8c24c0000000     | mov                 edx, 2
            //   e8????????           |                     
            //   4889442450           | dec                 eax
            //   48837c245000         | mov                 ecx, dword ptr [esp + 0x20]
            //   7505                 | jmp                 0x1dc3
            //   e9????????           |                     

        $sequence_2 = { 488bf8 33c0 b910000000 f3aa 48c744246000000000 48c744243000000000 }
            // n = 6, score = 100
            //   488bf8               | cwde                
            //   33c0                 | mov                 dword ptr [esp + 0x20], eax
            //   b910000000           | dec                 eax
            //   f3aa                 | mov                 eax, dword ptr [esp + 0x88]
            //   48c744246000000000     | dec    eax
            //   48c744243000000000     | shr    eax, 0x10

        $sequence_3 = { 5f c3 48894c2408 4883ec28 488b442430 48833800 7422 }
            // n = 7, score = 100
            //   5f                   | mov                 ecx, dword ptr [esp + 0xde0]
            //   c3                   | dec                 eax
            //   48894c2408           | mov                 eax, dword ptr [ecx + eax]
            //   4883ec28             | mov                 eax, dword ptr [esp]
            //   488b442430           | dec                 eax
            //   48833800             | cmp                 eax, 0x200
            //   7422                 | jae                 0x89b

        $sequence_4 = { e8???????? 837b1000 75dd 488d05c35f0100 483bd8 74d1 488bcb }
            // n = 7, score = 100
            //   e8????????           |                     
            //   837b1000             | dec                 eax
            //   75dd                 | mov                 dword ptr [esp + 0x38], eax
            //   488d05c35f0100       | dec                 esp
            //   483bd8               | lea                 eax, [esp + 0x48]
            //   74d1                 | dec                 eax
            //   488bcb               | lea                 edx, [0x21217]

        $sequence_5 = { 85c0 740a b801000000 e9???????? 488d0d5ceb0100 ff15???????? 85c0 }
            // n = 7, score = 100
            //   85c0                 | mov                 ecx, 1
            //   740a                 | dec                 eax
            //   b801000000           | imul                ecx, ecx, 4
            //   e9????????           |                     
            //   488d0d5ceb0100       | mov                 eax, dword ptr [eax]
            //   ff15????????         |                     
            //   85c0                 | mov                 dword ptr [esp + ecx + 0x50], eax

        $sequence_6 = { 488b4c2450 0fb6542424 881401 ebd8 }
            // n = 4, score = 100
            //   488b4c2450           | mov                 ecx, dword ptr [esp + 0x80]
            //   0fb6542424           | dec                 esp
            //   881401               | lea                 eax, [0x30a]
            //   ebd8                 | dec                 eax

        $sequence_7 = { 4c8d0d46c40000 c5f35cca c4c173590cc1 4c8d0d15b40000 c5f359c1 c5fb101d???????? c5fb102d???????? }
            // n = 7, score = 100
            //   4c8d0d46c40000       | cmp                 dword ptr [esp + 0x30], 0
            //   c5f35cca             | jle                 0x17f0
            //   c4c173590cc1         | dec                 eax
            //   4c8d0d15b40000       | arpl                word ptr [esp + 0x30], ax
            //   c5f359c1             | dec                 eax
            //   c5fb101d????????     |                     
            //   c5fb102d????????     |                     

        $sequence_8 = { 488d8c24b0000000 e8???????? 4533c9 41b804010000 488d9424b0000000 488b4c2448 ff15???????? }
            // n = 7, score = 100
            //   488d8c24b0000000     | mov                 ecx, dword ptr [esp + 0x30]
            //   e8????????           |                     
            //   4533c9               | cmp                 dword ptr [esp + 0x20], 0xff
            //   41b804010000         | jle                 0xa86
            //   488d9424b0000000     | mov                 dword ptr [esp], 0xff
            //   488b4c2448           | jmp                 0xa8d
            //   ff15????????         |                     

        $sequence_9 = { 0f2e05???????? 7a06 0f84b4000000 f30f10442404 0f2e05???????? 7a06 0f849f000000 }
            // n = 7, score = 100
            //   0f2e05????????       |                     
            //   7a06                 | dec                 eax
            //   0f84b4000000         | mov                 dword ptr [esp + eax + 0x98], ecx
            //   f30f10442404         | inc                 ecx
            //   0f2e05????????       |                     
            //   7a06                 | mov                 eax, 0x10
            //   0f849f000000         | dec                 eax

    condition:
        7 of them and filesize < 458752
}