rule elf_gobrat_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects elf.gobrat."
        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/elf.gobrat"
        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???????? 4889842498000000 48895c2450 488b842440010000 488b9c2448010000 e8???????? 48898424c0000000 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   4889842498000000     | dec                 eax
            //   48895c2450           | mov                 edx, dword ptr [esp + 0x58]
            //   488b842440010000     | dec                 eax
            //   488b9c2448010000     | lea                 ecx, [0x1b9588]
            //   e8????????           |                     
            //   48898424c0000000     | dec                 eax

        $sequence_1 = { 4d3b6610 0f8605070000 4881ecf0010000 4889ac24e8010000 488dac24e8010000 48899c2400020000 4889b42418020000 }
            // n = 7, score = 100
            //   4d3b6610             | dec                 eax
            //   0f8605070000         | mov                 dword ptr [esp + 0x108], edx
            //   4881ecf0010000       | dec                 eax
            //   4889ac24e8010000     | mov                 dword ptr [esp + 0x110], 1
            //   488dac24e8010000     | dec                 eax
            //   48899c2400020000     | mov                 edx, dword ptr [esp + 0x78]
            //   4889b42418020000     | dec                 eax

        $sequence_2 = { 4d39c8 740e bb03000000 488d0584862d00 eb2a 4889542428 48897c2458 }
            // n = 7, score = 100
            //   4d39c8               | mov                 edx, dword ptr [esp + 0x68]
            //   740e                 | dec                 eax
            //   bb03000000           | mov                 dword ptr [esp + 0x1a8], edx
            //   488d0584862d00       | dec                 eax
            //   eb2a                 | mov                 ecx, dword ptr [esp + 0xd8]
            //   4889542428           | dec                 eax
            //   48897c2458           | mov                 edi, dword ptr [esp + 0x168]

        $sequence_3 = { 94 e4b8 89e3 809549e38094e4 ba8ce38095 49e380 94 }
            // n = 7, score = 100
            //   94                   | mov                 eax, dword ptr [esp + 0x18]
            //   e4b8                 | dec                 eax
            //   89e3                 | mov                 ebp, dword ptr [esp + 0x28]
            //   809549e38094e4       | dec                 eax
            //   ba8ce38095           | add                 esp, 0x30
            //   49e380               | ret                 
            //   94                   | dec                 eax

        $sequence_4 = { 84c0 0f8508010000 488b842498000000 488b8c24a8000000 488b542478 488b9c2480000000 488bb424b8000000 }
            // n = 7, score = 100
            //   84c0                 | dec                 eax
            //   0f8508010000         | mov                 ebx, dword ptr [edi + 0x168]
            //   488b842498000000     | dec                 eax
            //   488b8c24a8000000     | mov                 ebp, dword ptr [esp + 0x378]
            //   488b542478           | dec                 eax
            //   488b9c2480000000     | add                 esp, 0x380
            //   488bb424b8000000     | ret                 

        $sequence_5 = { ebac 90 41bb00020000 f04c0fc19880010100 4d89dc 49c1eb0d 4c39d9 }
            // n = 7, score = 100
            //   ebac                 | mov                 dword ptr [esp + 0xb0], 0x28
            //   90                   | dec                 eax
            //   41bb00020000         | mov                 dword ptr [esp + 0xb8], 0x28
            //   f04c0fc19880010100     | dec    eax
            //   4d89dc               | mov                 dword ptr [esp + 0xc0], 0x28
            //   49c1eb0d             | dec                 eax
            //   4c39d9               | mov                 dword ptr [esp + 0xc8], 0x28

        $sequence_6 = { 7506 48895010 eb09 488d7810 e8???????? 488b5318 488b7320 }
            // n = 7, score = 100
            //   7506                 | cmp                 ecx, eax
            //   48895010             | jb                  0x53c
            //   eb09                 | dec                 eax
            //   488d7810             | mov                 dword ptr [esp + 0x58], esi
            //   e8????????           |                     
            //   488b5318             | dec                 esp
            //   488b7320             | mov                 dword ptr [esp + 0xa0], ebx

        $sequence_7 = { f0081a 90 90 488b442430 e8???????? 90 488b542428 }
            // n = 7, score = 100
            //   f0081a               | mov                 dword ptr [esp + 0xe0], 0x2f
            //   90                   | dec                 eax
            //   90                   | mov                 dword ptr [esp + 0xe8], 0x2f
            //   488b442430           | dec                 eax
            //   e8????????           |                     
            //   90                   | mov                 dword ptr [esp + 0x1b8], 2
            //   488b542428           | dec                 eax

        $sequence_8 = { 488d3db8101900 be32000000 0f1f00 e8???????? 488d4c2460 bf02000000 4889fe }
            // n = 7, score = 100
            //   488d3db8101900       | movzx               edx, word ptr [ecx + 0x20]
            //   be32000000           | dec                 eax
            //   0f1f00               | mov                 eax, edx
            //   e8????????           |                     
            //   488d4c2460           | mov                 ebx, 0xa
            //   bf02000000           | dec                 eax
            //   4889fe               | mov                 dword ptr [esp + 0x40], eax

        $sequence_9 = { e8???????? 488d057aca0900 488d1dd3661900 e8???????? 90 4889442408 48895c2410 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   488d057aca0900       | dec                 eax
            //   488d1dd3661900       | mov                 dword ptr [esp + 0x90], ecx
            //   e8????????           |                     
            //   90                   | dec                 eax
            //   4889442408           | lea                 edi, [0x275c6e]
            //   48895c2410           | dec                 eax

    condition:
        7 of them and filesize < 12853248
}