rule win_graphite_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.graphite."
        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.graphite"
        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 = { 81e2ff030000 81e1bf030000 83c940 c1e10a 0bca }
            // n = 5, score = 500
            //   81e2ff030000         | dec                 eax
            //   81e1bf030000         | mov                 ecx, ebx
            //   83c940               | dec                 esp
            //   c1e10a               | arpl                ax, ax
            //   0bca                 | dec                 eax

        $sequence_1 = { ff15???????? 33c0 eb05 b801010000 }
            // n = 4, score = 500
            //   ff15????????         |                     
            //   33c0                 | mov                 dword ptr [ebp - 0x50], 0xd7b8d794
            //   eb05                 | mov                 dword ptr [ebp - 0x4c], 0xd7a3d7b9
            //   b801010000           | mov                 dword ptr [ebp - 0x48], 0xd7b8d7a5

        $sequence_2 = { 81e1bf030000 83c940 c1e10a 0bca }
            // n = 4, score = 500
            //   81e1bf030000         | push                esi
            //   83c940               | push                dword ptr [esp + 0x1c]
            //   c1e10a               | push                edi
            //   0bca                 | push                esi

        $sequence_3 = { 85db 7513 33d2 e8???????? 84c0 }
            // n = 5, score = 500
            //   85db                 | mov                 edx, esp
            //   7513                 | dec                 esp
            //   33d2                 | arpl                ax, ax
            //   e8????????           |                     
            //   84c0                 | dec                 edx

        $sequence_4 = { 85db 7513 33d2 e8???????? }
            // n = 4, score = 500
            //   85db                 | mov                 word ptr [ebp - 1], 0x3821
            //   7513                 | mov                 edx, 0x74
            //   33d2                 | mov                 dword ptr [ebp - 0x29], 0x8cde8cd0
            //   e8????????           |                     

        $sequence_5 = { 7513 33d2 e8???????? 84c0 74e4 }
            // n = 5, score = 500
            //   7513                 | inc                 ecx
            //   33d2                 | mov                 dword ptr [esp], eax
            //   e8????????           |                     
            //   84c0                 | dec                 eax
            //   74e4                 | mov                 ecx, edi

        $sequence_6 = { 33d2 e8???????? 84c0 74e4 }
            // n = 4, score = 500
            //   33d2                 | inc                 esp
            //   e8????????           |                     
            //   84c0                 | mov                 eax, ebx
            //   74e4                 | dec                 ecx

        $sequence_7 = { 81e2ff030000 81e1bf030000 83c940 c1e10a }
            // n = 4, score = 500
            //   81e2ff030000         | push                dword ptr [esp + 0x1c]
            //   81e1bf030000         | mov                 esi, edi
            //   83c940               | push                esi
            //   c1e10a               | push                dword ptr [esp + 0x20]

        $sequence_8 = { 85db 7513 33d2 e8???????? 84c0 74e4 }
            // n = 6, score = 500
            //   85db                 | inc                 ecx
            //   7513                 | mov                 ecx, 0x26
            //   33d2                 | dec                 eax
            //   e8????????           |                     
            //   84c0                 | mov                 dword ptr [esp + 0x30], edi
            //   74e4                 | dec                 eax

        $sequence_9 = { 7513 33d2 e8???????? 84c0 }
            // n = 4, score = 500
            //   7513                 | dec                 ebp
            //   33d2                 | mov                 edx, ebp
            //   e8????????           |                     
            //   84c0                 | mov                 byte ptr [ebx], cl

    condition:
        7 of them and filesize < 98304
}