rule win_medusalocker_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.medusalocker."
        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.medusalocker"
        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 = { 8b45ec 83e001 740c 8365ecfe 8d4d9c e8???????? }
            // n = 6, score = 400
            //   8b45ec               | mov                 eax, dword ptr [ebp - 0x14]
            //   83e001               | and                 eax, 1
            //   740c                 | je                  0xe
            //   8365ecfe             | and                 dword ptr [ebp - 0x14], 0xfffffffe
            //   8d4d9c               | lea                 ecx, [ebp - 0x64]
            //   e8????????           |                     

        $sequence_1 = { 894df4 8b4510 8945f8 6a00 8d4df8 }
            // n = 5, score = 400
            //   894df4               | mov                 dword ptr [ebp - 0xc], ecx
            //   8b4510               | mov                 eax, dword ptr [ebp + 0x10]
            //   8945f8               | mov                 dword ptr [ebp - 8], eax
            //   6a00                 | push                0
            //   8d4df8               | lea                 ecx, [ebp - 8]

        $sequence_2 = { e8???????? c645fc00 8d4dd8 e8???????? 8b4d0c 51 e8???????? }
            // n = 7, score = 400
            //   e8????????           |                     
            //   c645fc00             | mov                 byte ptr [ebp - 4], 0
            //   8d4dd8               | lea                 ecx, [ebp - 0x28]
            //   e8????????           |                     
            //   8b4d0c               | mov                 ecx, dword ptr [ebp + 0xc]
            //   51                   | push                ecx
            //   e8????????           |                     

        $sequence_3 = { ba01000000 85d2 742d 8b4d0c e8???????? 6a00 6840420f00 }
            // n = 7, score = 400
            //   ba01000000           | mov                 edx, 1
            //   85d2                 | test                edx, edx
            //   742d                 | je                  0x2f
            //   8b4d0c               | mov                 ecx, dword ptr [ebp + 0xc]
            //   e8????????           |                     
            //   6a00                 | push                0
            //   6840420f00           | push                0xf4240

        $sequence_4 = { 8d8d58ffffff e8???????? 8945c4 8b4dc4 894dc0 }
            // n = 5, score = 400
            //   8d8d58ffffff         | lea                 ecx, [ebp - 0xa8]
            //   e8????????           |                     
            //   8945c4               | mov                 dword ptr [ebp - 0x3c], eax
            //   8b4dc4               | mov                 ecx, dword ptr [ebp - 0x3c]
            //   894dc0               | mov                 dword ptr [ebp - 0x40], ecx

        $sequence_5 = { 52 e8???????? 83c40c 8b4510 2b45f4 50 }
            // n = 6, score = 400
            //   52                   | push                edx
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   8b4510               | mov                 eax, dword ptr [ebp + 0x10]
            //   2b45f4               | sub                 eax, dword ptr [ebp - 0xc]
            //   50                   | push                eax

        $sequence_6 = { 894db8 8b4db8 e8???????? c745fc00000000 8d4dd8 }
            // n = 5, score = 400
            //   894db8               | mov                 dword ptr [ebp - 0x48], ecx
            //   8b4db8               | mov                 ecx, dword ptr [ebp - 0x48]
            //   e8????????           |                     
            //   c745fc00000000       | mov                 dword ptr [ebp - 4], 0
            //   8d4dd8               | lea                 ecx, [ebp - 0x28]

        $sequence_7 = { e8???????? 83c404 8945d0 837dd000 7464 8b4d0c 51 }
            // n = 7, score = 400
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   8945d0               | mov                 dword ptr [ebp - 0x30], eax
            //   837dd000             | cmp                 dword ptr [ebp - 0x30], 0
            //   7464                 | je                  0x66
            //   8b4d0c               | mov                 ecx, dword ptr [ebp + 0xc]
            //   51                   | push                ecx

        $sequence_8 = { 8b5514 52 e8???????? 83c404 50 8b4510 }
            // n = 6, score = 400
            //   8b5514               | mov                 edx, dword ptr [ebp + 0x14]
            //   52                   | push                edx
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   50                   | push                eax
            //   8b4510               | mov                 eax, dword ptr [ebp + 0x10]

        $sequence_9 = { c785d0fdffff00000000 68???????? 8b95d0fdffff 52 8b8ddcfdffff e8???????? }
            // n = 6, score = 400
            //   c785d0fdffff00000000     | mov    dword ptr [ebp - 0x230], 0
            //   68????????           |                     
            //   8b95d0fdffff         | mov                 edx, dword ptr [ebp - 0x230]
            //   52                   | push                edx
            //   8b8ddcfdffff         | mov                 ecx, dword ptr [ebp - 0x224]
            //   e8????????           |                     

    condition:
        7 of them and filesize < 1433600
}