rule win_nimgrabber_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.nimgrabber."
        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.nimgrabber"
        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 = { 0f8425120000 897c2428 8b7c2478 c744242000000000 897c2424 8bbc24fc000000 896c2418 }
            // n = 7, score = 200
            //   0f8425120000         | je                  0x122b
            //   897c2428             | mov                 dword ptr [esp + 0x28], edi
            //   8b7c2478             | mov                 edi, dword ptr [esp + 0x78]
            //   c744242000000000     | mov                 dword ptr [esp + 0x20], 0
            //   897c2424             | mov                 dword ptr [esp + 0x24], edi
            //   8bbc24fc000000       | mov                 edi, dword ptr [esp + 0xfc]
            //   896c2418             | mov                 dword ptr [esp + 0x18], ebp

        $sequence_1 = { ba1e000000 89442418 e8???????? 8944241c e9???????? 894c2404 c70424???????? }
            // n = 7, score = 200
            //   ba1e000000           | mov                 edx, 0x1e
            //   89442418             | mov                 dword ptr [esp + 0x18], eax
            //   e8????????           |                     
            //   8944241c             | mov                 dword ptr [esp + 0x1c], eax
            //   e9????????           |                     
            //   894c2404             | mov                 dword ptr [esp + 4], ecx
            //   c70424????????       |                     

        $sequence_2 = { 8b4c2448 897004 8bb42484000000 668910 897008 8b742454 89580c }
            // n = 7, score = 200
            //   8b4c2448             | mov                 ecx, dword ptr [esp + 0x48]
            //   897004               | mov                 dword ptr [eax + 4], esi
            //   8bb42484000000       | mov                 esi, dword ptr [esp + 0x84]
            //   668910               | mov                 word ptr [eax], dx
            //   897008               | mov                 dword ptr [eax + 8], esi
            //   8b742454             | mov                 esi, dword ptr [esp + 0x54]
            //   89580c               | mov                 dword ptr [eax + 0xc], ebx

        $sequence_3 = { c744240800000000 c744240c00000000 89442404 e8???????? e9???????? 83e801 890c24 }
            // n = 7, score = 200
            //   c744240800000000     | mov                 dword ptr [esp + 8], 0
            //   c744240c00000000     | mov                 dword ptr [esp + 0xc], 0
            //   89442404             | mov                 dword ptr [esp + 4], eax
            //   e8????????           |                     
            //   e9????????           |                     
            //   83e801               | sub                 eax, 1
            //   890c24               | mov                 dword ptr [esp], ecx

        $sequence_4 = { 09d0 3dffff0000 0f8ee3000000 3dffff1000 0f8fee000000 2d00000100 89c2 }
            // n = 7, score = 200
            //   09d0                 | or                  eax, edx
            //   3dffff0000           | cmp                 eax, 0xffff
            //   0f8ee3000000         | jle                 0xe9
            //   3dffff1000           | cmp                 eax, 0x10ffff
            //   0f8fee000000         | jg                  0xf4
            //   2d00000100           | sub                 eax, 0x10000
            //   89c2                 | mov                 edx, eax

        $sequence_5 = { e8???????? 8b842484000000 8b542468 8b480c e8???????? 84c0 0f85bcd1ffff }
            // n = 7, score = 200
            //   e8????????           |                     
            //   8b842484000000       | mov                 eax, dword ptr [esp + 0x84]
            //   8b542468             | mov                 edx, dword ptr [esp + 0x68]
            //   8b480c               | mov                 ecx, dword ptr [eax + 0xc]
            //   e8????????           |                     
            //   84c0                 | test                al, al
            //   0f85bcd1ffff         | jne                 0xffffd1c2

        $sequence_6 = { 5f 5d c3 c7442404c3040000 891c24 e8???????? e9???????? }
            // n = 7, score = 200
            //   5f                   | pop                 edi
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   c7442404c3040000     | mov                 dword ptr [esp + 4], 0x4c3
            //   891c24               | mov                 dword ptr [esp], ebx
            //   e8????????           |                     
            //   e9????????           |                     

        $sequence_7 = { 0f85defcffff b8ffffffff e9???????? 837c24447f 0f8eff140000 8b4c2444 ba0a000000 }
            // n = 7, score = 200
            //   0f85defcffff         | jne                 0xfffffce4
            //   b8ffffffff           | mov                 eax, 0xffffffff
            //   e9????????           |                     
            //   837c24447f           | cmp                 dword ptr [esp + 0x44], 0x7f
            //   0f8eff140000         | jle                 0x1505
            //   8b4c2444             | mov                 ecx, dword ptr [esp + 0x44]
            //   ba0a000000           | mov                 edx, 0xa

        $sequence_8 = { ebea 83e841 83f819 0f96c3 e9???????? }
            // n = 5, score = 200
            //   ebea                 | jmp                 0xffffffec
            //   83e841               | sub                 eax, 0x41
            //   83f819               | cmp                 eax, 0x19
            //   0f96c3               | setbe               bl
            //   e9????????           |                     

        $sequence_9 = { e9???????? 83e901 893c24 894c2404 e8???????? e9???????? 83eb05 }
            // n = 7, score = 200
            //   e9????????           |                     
            //   83e901               | sub                 ecx, 1
            //   893c24               | mov                 dword ptr [esp], edi
            //   894c2404             | mov                 dword ptr [esp + 4], ecx
            //   e8????????           |                     
            //   e9????????           |                     
            //   83eb05               | sub                 ebx, 5

    condition:
        7 of them and filesize < 1238016
}