rule win_appleseed_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.appleseed."
        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.appleseed"
        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???????? 90 4c8d4dc0 4c8bc0 }
            // n = 4, score = 100
            //   e8????????           |                     
            //   90                   | mov                 byte ptr [ebx], 0
            //   4c8d4dc0             | inc                 ecx
            //   4c8bc0               | mov                 eax, esi

        $sequence_1 = { b91e000000 e8???????? b9ff000000 e8???????? 4803db 4c8d35a0f10100 49833cde00 }
            // n = 7, score = 100
            //   b91e000000           | test                ebx, ebx
            //   e8????????           |                     
            //   b9ff000000           | je                  0xd45
            //   e8????????           |                     
            //   4803db               | inc                 ecx
            //   4c8d35a0f10100       | mov                 byte ptr [esp], cl
            //   49833cde00           | dec                 ebx

        $sequence_2 = { 488bcb 440fb744a802 0fb714a8 e8???????? 488d05c741ffff 448b84a830c30200 4585c0 }
            // n = 7, score = 100
            //   488bcb               | lea                 edi, [0xfffe290f]
            //   440fb744a802         | dec                 ecx
            //   0fb714a8             | arpl                cx, bp
            //   e8????????           |                     
            //   488d05c741ffff       | inc                 esp
            //   448b84a830c30200     | mov                 edx, dword ptr [edi + ebp*4 + 0x34714]
            //   4585c0               | dec                 ecx

        $sequence_3 = { 48c74424780f000000 48895c2470 c644246000 48c74424580f000000 48895c2450 c644244000 }
            // n = 6, score = 100
            //   48c74424780f000000     | lea    edx, [ebp - 0x28]
            //   48895c2470           | je                  0x2297
            //   c644246000           | dec                 eax
            //   48c74424580f000000     | mov    dword ptr [ebp - 0x30], 0xf
            //   48895c2450           | dec                 eax
            //   c644244000           | mov                 dword ptr [ebp - 0x38], ebx

        $sequence_4 = { 488bd7 488d4c2450 e8???????? 90 488d4c2450 e8???????? 90 }
            // n = 7, score = 100
            //   488bd7               | inc                 ecx
            //   488d4c2450           | mov                 byte ptr [esp], 0
            //   e8????????           |                     
            //   90                   | dec                 ecx
            //   488d4c2450           | cmp                 dword ptr [edi + 0x18], 0x10
            //   e8????????           |                     
            //   90                   | dec                 ecx

        $sequence_5 = { 48833d????????00 0f84f50b0000 488d1533190200 488d4db8 e8???????? 90 488d55d8 }
            // n = 7, score = 100
            //   48833d????????00     |                     
            //   0f84f50b0000         | nop                 
            //   488d1533190200       | dec                 eax
            //   488d4db8             | mov                 dword ptr [ebp - 0x40], 0xf
            //   e8????????           |                     
            //   90                   | dec                 esp
            //   488d55d8             | mov                 dword ptr [ebp - 0x48], esi

        $sequence_6 = { 4533c0 488bd0 488d8da8000000 e8???????? 90 48837b1810 7208 }
            // n = 7, score = 100
            //   4533c0               | dec                 eax
            //   488bd0               | lea                 ecx, [ebp - 0x48]
            //   488d8da8000000       | nop                 
            //   e8????????           |                     
            //   90                   | dec                 eax
            //   48837b1810           | lea                 edx, [ebp - 0x28]
            //   7208                 | dec                 eax

        $sequence_7 = { 33c0 488945a0 488945a8 488945b0 c745a018000000 48895da8 }
            // n = 6, score = 100
            //   33c0                 | je                  0xfff
            //   488945a0             | dec                 eax
            //   488945a8             | lea                 edx, [0x1b8ab]
            //   488945b0             | dec                 eax
            //   c745a018000000       | lea                 ecx, [ebp + 0xf0]
            //   48895da8             | test                ebx, ebx

        $sequence_8 = { 48c1f805 83e11f 488d15e7cc0100 488b04c2 486bc958 c644080800 85db }
            // n = 7, score = 100
            //   48c1f805             | test                esi, esi
            //   83e11f               | je                  0x1421
            //   488d15e7cc0100       | inc                 ecx
            //   488b04c2             | mov                 edx, esi
            //   486bc958             | dec                 eax
            //   c644080800           | mov                 ecx, dword ptr [ebp - 0x78]
            //   85db                 | test                eax, eax

        $sequence_9 = { 498bcd ff15???????? 4c8be0 4885c0 0f84b2000000 }
            // n = 5, score = 100
            //   498bcd               | je                  0x917
            //   ff15????????         |                     
            //   4c8be0               | dec                 eax
            //   4885c0               | lea                 eax, [0x2bfb7]
            //   0f84b2000000         | jmp                 0x920

    condition:
        7 of them and filesize < 497664
}