rule win_diavol_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.diavol."
        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.diavol"
        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 = { 898d88f3ffff ff15???????? 83f8ff 0f84ca000000 }
            // n = 4, score = 100
            //   898d88f3ffff         | mov                 dword ptr [ebp - 0xc78], ecx
            //   ff15????????         |                     
            //   83f8ff               | cmp                 eax, -1
            //   0f84ca000000         | je                  0xd0

        $sequence_1 = { 68???????? 8d95a0f9ffff e8???????? 8d85a0f9ffff 83c424 }
            // n = 5, score = 100
            //   68????????           |                     
            //   8d95a0f9ffff         | lea                 edx, [ebp - 0x660]
            //   e8????????           |                     
            //   8d85a0f9ffff         | lea                 eax, [ebp - 0x660]
            //   83c424               | add                 esp, 0x24

        $sequence_2 = { 7412 66837dfc2a 7431 663bca 7535 83c002 }
            // n = 6, score = 100
            //   7412                 | je                  0x14
            //   66837dfc2a           | cmp                 word ptr [ebp - 4], 0x2a
            //   7431                 | je                  0x33
            //   663bca               | cmp                 cx, dx
            //   7535                 | jne                 0x37
            //   83c002               | add                 eax, 2

        $sequence_3 = { d1f8 66394c4302 8d5c4302 0f8552ffffff 5f 5e 33c0 }
            // n = 7, score = 100
            //   d1f8                 | sar                 eax, 1
            //   66394c4302           | cmp                 word ptr [ebx + eax*2 + 2], cx
            //   8d5c4302             | lea                 ebx, [ebx + eax*2 + 2]
            //   0f8552ffffff         | jne                 0xffffff58
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   33c0                 | xor                 eax, eax

        $sequence_4 = { 50 56 ff15???????? 85c0 0f8450010000 8b8d30c2ffff }
            // n = 6, score = 100
            //   50                   | push                eax
            //   56                   | push                esi
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   0f8450010000         | je                  0x156
            //   8b8d30c2ffff         | mov                 ecx, dword ptr [ebp - 0x3dd0]

        $sequence_5 = { 83d8ff 85c0 7532 8b85d0fbffff 50 6a00 }
            // n = 6, score = 100
            //   83d8ff               | sbb                 eax, -1
            //   85c0                 | test                eax, eax
            //   7532                 | jne                 0x34
            //   8b85d0fbffff         | mov                 eax, dword ptr [ebp - 0x430]
            //   50                   | push                eax
            //   6a00                 | push                0

        $sequence_6 = { 85f6 752a 6a02 53 ff15???????? }
            // n = 5, score = 100
            //   85f6                 | test                esi, esi
            //   752a                 | jne                 0x2c
            //   6a02                 | push                2
            //   53                   | push                ebx
            //   ff15????????         |                     

        $sequence_7 = { ffd0 56 ff15???????? e8???????? e8???????? }
            // n = 5, score = 100
            //   ffd0                 | call                eax
            //   56                   | push                esi
            //   ff15????????         |                     
            //   e8????????           |                     
            //   e8????????           |                     

        $sequence_8 = { c785fcefffff00000000 e8???????? 6800020000 8d85a0fdffff 6a00 }
            // n = 5, score = 100
            //   c785fcefffff00000000     | mov    dword ptr [ebp - 0x1004], 0
            //   e8????????           |                     
            //   6800020000           | push                0x200
            //   8d85a0fdffff         | lea                 eax, [ebp - 0x260]
            //   6a00                 | push                0

        $sequence_9 = { 81ec20010000 a1???????? 33c5 8945fc 6880000000 8d8578ffffff }
            // n = 6, score = 100
            //   81ec20010000         | sub                 esp, 0x120
            //   a1????????           |                     
            //   33c5                 | xor                 eax, ebp
            //   8945fc               | mov                 dword ptr [ebp - 4], eax
            //   6880000000           | push                0x80
            //   8d8578ffffff         | lea                 eax, [ebp - 0x88]

    condition:
        7 of them and filesize < 191488
}