rule win_wannacryptor_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.wannacryptor."
        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.wannacryptor"
        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 = { 8d4c247c c78424d8000000ffffffff e8???????? 8b8c24d0000000 5e 5d 5b }
            // n = 7, score = 700
            //   8d4c247c             | lea                 ecx, [esp + 0x7c]
            //   c78424d8000000ffffffff     | mov    dword ptr [esp + 0xd8], 0xffffffff
            //   e8????????           |                     
            //   8b8c24d0000000       | mov                 ecx, dword ptr [esp + 0xd0]
            //   5e                   | pop                 esi
            //   5d                   | pop                 ebp
            //   5b                   | pop                 ebx

        $sequence_1 = { 81fa00010000 7515 8b5008 83fa0d 7405 83fa1b }
            // n = 6, score = 700
            //   81fa00010000         | cmp                 edx, 0x100
            //   7515                 | jne                 0x17
            //   8b5008               | mov                 edx, dword ptr [eax + 8]
            //   83fa0d               | cmp                 edx, 0xd
            //   7405                 | je                  7
            //   83fa1b               | cmp                 edx, 0x1b

        $sequence_2 = { ff15???????? 50 8d4c2424 e8???????? 57 e8???????? 85c0 }
            // n = 7, score = 700
            //   ff15????????         |                     
            //   50                   | push                eax
            //   8d4c2424             | lea                 ecx, [esp + 0x24]
            //   e8????????           |                     
            //   57                   | push                edi
            //   e8????????           |                     
            //   85c0                 | test                eax, eax

        $sequence_3 = { e8???????? 8b8c2484000000 8d842480000000 f7d8 1bc0 c68424dc00000001 }
            // n = 6, score = 700
            //   e8????????           |                     
            //   8b8c2484000000       | mov                 ecx, dword ptr [esp + 0x84]
            //   8d842480000000       | lea                 eax, [esp + 0x80]
            //   f7d8                 | neg                 eax
            //   1bc0                 | sbb                 eax, eax
            //   c68424dc00000001     | mov                 byte ptr [esp + 0xdc], 1

        $sequence_4 = { 7405 83fa1b 751e b801000000 c20400 }
            // n = 5, score = 700
            //   7405                 | je                  7
            //   83fa1b               | cmp                 edx, 0x1b
            //   751e                 | jne                 0x20
            //   b801000000           | mov                 eax, 1
            //   c20400               | ret                 4

        $sequence_5 = { 51 8bcf e8???????? 4b 75f2 8b4678 8d7e44 }
            // n = 7, score = 700
            //   51                   | push                ecx
            //   8bcf                 | mov                 ecx, edi
            //   e8????????           |                     
            //   4b                   | dec                 ebx
            //   75f2                 | jne                 0xfffffff4
            //   8b4678               | mov                 eax, dword ptr [esi + 0x78]
            //   8d7e44               | lea                 edi, [esi + 0x44]

        $sequence_6 = { e8???????? 8d4648 8d4c2410 50 c744243000000000 }
            // n = 5, score = 700
            //   e8????????           |                     
            //   8d4648               | lea                 eax, [esi + 0x48]
            //   8d4c2410             | lea                 ecx, [esp + 0x10]
            //   50                   | push                eax
            //   c744243000000000     | mov                 dword ptr [esp + 0x30], 0

        $sequence_7 = { e9???????? 0f8ee3010000 807e4b01 7529 8b4644 8d7e44 8b48f8 }
            // n = 7, score = 700
            //   e9????????           |                     
            //   0f8ee3010000         | jle                 0x1e9
            //   807e4b01             | cmp                 byte ptr [esi + 0x4b], 1
            //   7529                 | jne                 0x2b
            //   8b4644               | mov                 eax, dword ptr [esi + 0x44]
            //   8d7e44               | lea                 edi, [esi + 0x44]
            //   8b48f8               | mov                 ecx, dword ptr [eax - 8]

        $sequence_8 = { 8a4659 84c0 753e 85f6 }
            // n = 4, score = 700
            //   8a4659               | mov                 al, byte ptr [esi + 0x59]
            //   84c0                 | test                al, al
            //   753e                 | jne                 0x40
            //   85f6                 | test                esi, esi

        $sequence_9 = { 52 ffd6 8d4c241c c68424d800000000 e8???????? }
            // n = 5, score = 700
            //   52                   | push                edx
            //   ffd6                 | call                esi
            //   8d4c241c             | lea                 ecx, [esp + 0x1c]
            //   c68424d800000000     | mov                 byte ptr [esp + 0xd8], 0
            //   e8????????           |                     

    condition:
        7 of them and filesize < 540672
}