rule win_ragnarlocker_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.ragnarlocker."
        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.ragnarlocker"
        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 = { 8bbed0000000 c6041f80 47 83ff70 7628 b980000000 }
            // n = 6, score = 300
            //   8bbed0000000         | mov                 edi, dword ptr [esi + 0xd0]
            //   c6041f80             | mov                 byte ptr [edi + ebx], 0x80
            //   47                   | inc                 edi
            //   83ff70               | cmp                 edi, 0x70
            //   7628                 | jbe                 0x2a
            //   b980000000           | mov                 ecx, 0x80

        $sequence_1 = { 0facd11c c1e604 0bf9 c1ea1c 8b4de4 0bf2 }
            // n = 6, score = 300
            //   0facd11c             | shrd                ecx, edx, 0x1c
            //   c1e604               | shl                 esi, 4
            //   0bf9                 | or                  edi, ecx
            //   c1ea1c               | shr                 edx, 0x1c
            //   8b4de4               | mov                 ecx, dword ptr [ebp - 0x1c]
            //   0bf2                 | or                  esi, edx

        $sequence_2 = { 0fb6c5 6a04 0bd0 0fb6c1 6800300000 c1e208 53 }
            // n = 7, score = 300
            //   0fb6c5               | movzx               eax, ch
            //   6a04                 | push                4
            //   0bd0                 | or                  edx, eax
            //   0fb6c1               | movzx               eax, cl
            //   6800300000           | push                0x3000
            //   c1e208               | shl                 edx, 8
            //   53                   | push                ebx

        $sequence_3 = { 8bf9 0facd112 c1e70e 33f6 0bf1 c1ea12 }
            // n = 6, score = 300
            //   8bf9                 | mov                 edi, ecx
            //   0facd112             | shrd                ecx, edx, 0x12
            //   c1e70e               | shl                 edi, 0xe
            //   33f6                 | xor                 esi, esi
            //   0bf1                 | or                  esi, ecx
            //   c1ea12               | shr                 edx, 0x12

        $sequence_4 = { 7510 ff75fc ff15???????? 8bc6 5e 8be5 5d }
            // n = 7, score = 300
            //   7510                 | jne                 0x12
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   ff15????????         |                     
            //   8bc6                 | mov                 eax, esi
            //   5e                   | pop                 esi
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp

        $sequence_5 = { 8b4d0c 13c7 8945f4 0fb64160 }
            // n = 4, score = 300
            //   8b4d0c               | mov                 ecx, dword ptr [ebp + 0xc]
            //   13c7                 | adc                 eax, edi
            //   8945f4               | mov                 dword ptr [ebp - 0xc], eax
            //   0fb64160             | movzx               eax, byte ptr [ecx + 0x60]

        $sequence_6 = { 8bf2 0fa4ca17 c1ee09 0bda c1e117 8b55d4 0bf1 }
            // n = 7, score = 300
            //   8bf2                 | mov                 esi, edx
            //   0fa4ca17             | shld                edx, ecx, 0x17
            //   c1ee09               | shr                 esi, 9
            //   0bda                 | or                  ebx, edx
            //   c1e117               | shl                 ecx, 0x17
            //   8b55d4               | mov                 edx, dword ptr [ebp - 0x2c]
            //   0bf1                 | or                  esi, ecx

        $sequence_7 = { 2375cc 234dd8 8b45f4 33f1 8b4de4 8bd0 2345ec }
            // n = 7, score = 300
            //   2375cc               | and                 esi, dword ptr [ebp - 0x34]
            //   234dd8               | and                 ecx, dword ptr [ebp - 0x28]
            //   8b45f4               | mov                 eax, dword ptr [ebp - 0xc]
            //   33f1                 | xor                 esi, ecx
            //   8b4de4               | mov                 ecx, dword ptr [ebp - 0x1c]
            //   8bd0                 | mov                 edx, eax
            //   2345ec               | and                 eax, dword ptr [ebp - 0x14]

        $sequence_8 = { 0fa4de08 99 c1e308 0bd8 899d40ffffff 8b4738 }
            // n = 6, score = 300
            //   0fa4de08             | shld                esi, ebx, 8
            //   99                   | cdq                 
            //   c1e308               | shl                 ebx, 8
            //   0bd8                 | or                  ebx, eax
            //   899d40ffffff         | mov                 dword ptr [ebp - 0xc0], ebx
            //   8b4738               | mov                 eax, dword ptr [edi + 0x38]

        $sequence_9 = { 8955e8 0fb64110 13f7 99 8975ec 8bd8 0fb64111 }
            // n = 7, score = 300
            //   8955e8               | mov                 dword ptr [ebp - 0x18], edx
            //   0fb64110             | movzx               eax, byte ptr [ecx + 0x10]
            //   13f7                 | adc                 esi, edi
            //   99                   | cdq                 
            //   8975ec               | mov                 dword ptr [ebp - 0x14], esi
            //   8bd8                 | mov                 ebx, eax
            //   0fb64111             | movzx               eax, byte ptr [ecx + 0x11]

    condition:
        7 of them and filesize < 147456
}