rule win_dnspionage_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.dnspionage."
        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.dnspionage"
        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 = { 894f0c 894704 8d45f4 894708 eb02 33ff 6a10 }
            // n = 7, score = 300
            //   894f0c               | mov                 dword ptr [edi + 0xc], ecx
            //   894704               | mov                 dword ptr [edi + 4], eax
            //   8d45f4               | lea                 eax, [ebp - 0xc]
            //   894708               | mov                 dword ptr [edi + 8], eax
            //   eb02                 | jmp                 4
            //   33ff                 | xor                 edi, edi
            //   6a10                 | push                0x10

        $sequence_1 = { 46 84c0 75f9 2bf1 83ff10 5f }
            // n = 6, score = 300
            //   46                   | inc                 esi
            //   84c0                 | test                al, al
            //   75f9                 | jne                 0xfffffffb
            //   2bf1                 | sub                 esi, ecx
            //   83ff10               | cmp                 edi, 0x10
            //   5f                   | pop                 edi

        $sequence_2 = { 660f1f440000 8b85f8efffff 85c0 7451 3d00100000 }
            // n = 5, score = 300
            //   660f1f440000         | nop                 word ptr [eax + eax]
            //   8b85f8efffff         | mov                 eax, dword ptr [ebp - 0x1008]
            //   85c0                 | test                eax, eax
            //   7451                 | je                  0x53
            //   3d00100000           | cmp                 eax, 0x1000

        $sequence_3 = { c7470c20000000 53 ff7508 e8???????? 8bf0 }
            // n = 5, score = 300
            //   c7470c20000000       | mov                 dword ptr [edi + 0xc], 0x20
            //   53                   | push                ebx
            //   ff7508               | push                dword ptr [ebp + 8]
            //   e8????????           |                     
            //   8bf0                 | mov                 esi, eax

        $sequence_4 = { ff33 e8???????? 8bce 8903 83c408 c1e902 897c88fc }
            // n = 7, score = 300
            //   ff33                 | push                dword ptr [ebx]
            //   e8????????           |                     
            //   8bce                 | mov                 ecx, esi
            //   8903                 | mov                 dword ptr [ebx], eax
            //   83c408               | add                 esp, 8
            //   c1e902               | shr                 ecx, 2
            //   897c88fc             | mov                 dword ptr [eax + ecx*4 - 4], edi

        $sequence_5 = { 8b01 ff5010 33c0 5b }
            // n = 4, score = 300
            //   8b01                 | mov                 eax, dword ptr [ecx]
            //   ff5010               | call                dword ptr [eax + 0x10]
            //   33c0                 | xor                 eax, eax
            //   5b                   | pop                 ebx

        $sequence_6 = { 8bd7 894f20 8bcb 89470c e8???????? 85f6 7448 }
            // n = 7, score = 300
            //   8bd7                 | mov                 edx, edi
            //   894f20               | mov                 dword ptr [edi + 0x20], ecx
            //   8bcb                 | mov                 ecx, ebx
            //   89470c               | mov                 dword ptr [edi + 0xc], eax
            //   e8????????           |                     
            //   85f6                 | test                esi, esi
            //   7448                 | je                  0x4a

        $sequence_7 = { 83fe03 7d13 ba03000000 2bd6 8a4340 880439 41 }
            // n = 7, score = 300
            //   83fe03               | cmp                 esi, 3
            //   7d13                 | jge                 0x15
            //   ba03000000           | mov                 edx, 3
            //   2bd6                 | sub                 edx, esi
            //   8a4340               | mov                 al, byte ptr [ebx + 0x40]
            //   880439               | mov                 byte ptr [ecx + edi], al
            //   41                   | inc                 ecx

        $sequence_8 = { 7905 48 83c8fc 40 7417 }
            // n = 5, score = 300
            //   7905                 | jns                 7
            //   48                   | dec                 eax
            //   83c8fc               | or                  eax, 0xfffffffc
            //   40                   | inc                 eax
            //   7417                 | je                  0x19

        $sequence_9 = { 84c9 75f9 6a00 8d4df8 2bc2 }
            // n = 5, score = 300
            //   84c9                 | test                cl, cl
            //   75f9                 | jne                 0xfffffffb
            //   6a00                 | push                0
            //   8d4df8               | lea                 ecx, [ebp - 8]
            //   2bc2                 | sub                 eax, edx

    condition:
        7 of them and filesize < 786432
}