rule win_sendsafe_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-05-04"
        version = "1"
        description = "Detects win.sendsafe."
        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.sendsafe"
        malpedia_rule_date = "20260422"
        malpedia_hash = "a182e35da64e6d71cb55f125c4d4225196523f14"
        malpedia_version = "20260504"
        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 = { 8d8dfcfdffff 51 e8???????? 83c40c 8d95fcfdffff 52 e8???????? }
            // n = 7, score = 200
            //   8d8dfcfdffff         | lea                 ecx, [ebp - 0x204]
            //   51                   | push                ecx
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc
            //   8d95fcfdffff         | lea                 edx, [ebp - 0x204]
            //   52                   | push                edx
            //   e8????????           |                     

        $sequence_1 = { ff15???????? 85c0 7409 c745cc01000000 eb07 c745cc00000000 8a4dcc }
            // n = 7, score = 200
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   7409                 | je                  0xb
            //   c745cc01000000       | mov                 dword ptr [ebp - 0x34], 1
            //   eb07                 | jmp                 9
            //   c745cc00000000       | mov                 dword ptr [ebp - 0x34], 0
            //   8a4dcc               | mov                 cl, byte ptr [ebp - 0x34]

        $sequence_2 = { eb5c 8b55cc 8b4230 8b4dc8 8b1488 837a2c00 744a }
            // n = 7, score = 200
            //   eb5c                 | jmp                 0x5e
            //   8b55cc               | mov                 edx, dword ptr [ebp - 0x34]
            //   8b4230               | mov                 eax, dword ptr [edx + 0x30]
            //   8b4dc8               | mov                 ecx, dword ptr [ebp - 0x38]
            //   8b1488               | mov                 edx, dword ptr [eax + ecx*4]
            //   837a2c00             | cmp                 dword ptr [edx + 0x2c], 0
            //   744a                 | je                  0x4c

        $sequence_3 = { eb1a b816020000 25ffff0000 0d00000700 0d00000080 898578f6ffff 8b8d78f6ffff }
            // n = 7, score = 200
            //   eb1a                 | jmp                 0x1c
            //   b816020000           | mov                 eax, 0x216
            //   25ffff0000           | and                 eax, 0xffff
            //   0d00000700           | or                  eax, 0x70000
            //   0d00000080           | or                  eax, 0x80000000
            //   898578f6ffff         | mov                 dword ptr [ebp - 0x988], eax
            //   8b8d78f6ffff         | mov                 ecx, dword ptr [ebp - 0x988]

        $sequence_4 = { eb0f 8b4df4 51 e8???????? 83c404 8945e8 8b55e8 }
            // n = 7, score = 200
            //   eb0f                 | jmp                 0x11
            //   8b4df4               | mov                 ecx, dword ptr [ebp - 0xc]
            //   51                   | push                ecx
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   8945e8               | mov                 dword ptr [ebp - 0x18], eax
            //   8b55e8               | mov                 edx, dword ptr [ebp - 0x18]

        $sequence_5 = { 8b8894000000 51 8d55dc 52 e8???????? 83c408 8d45dc }
            // n = 7, score = 200
            //   8b8894000000         | mov                 ecx, dword ptr [eax + 0x94]
            //   51                   | push                ecx
            //   8d55dc               | lea                 edx, [ebp - 0x24]
            //   52                   | push                edx
            //   e8????????           |                     
            //   83c408               | add                 esp, 8
            //   8d45dc               | lea                 eax, [ebp - 0x24]

        $sequence_6 = { e8???????? 8b45e8 898574ffffff 8b4d10 8b9574ffffff 8b01 3b4210 }
            // n = 7, score = 200
            //   e8????????           |                     
            //   8b45e8               | mov                 eax, dword ptr [ebp - 0x18]
            //   898574ffffff         | mov                 dword ptr [ebp - 0x8c], eax
            //   8b4d10               | mov                 ecx, dword ptr [ebp + 0x10]
            //   8b9574ffffff         | mov                 edx, dword ptr [ebp - 0x8c]
            //   8b01                 | mov                 eax, dword ptr [ecx]
            //   3b4210               | cmp                 eax, dword ptr [edx + 0x10]

        $sequence_7 = { c741144d000000 8b5508 8b02 b904000000 6bd100 8b4dfc 894c1018 }
            // n = 7, score = 200
            //   c741144d000000       | mov                 dword ptr [ecx + 0x14], 0x4d
            //   8b5508               | mov                 edx, dword ptr [ebp + 8]
            //   8b02                 | mov                 eax, dword ptr [edx]
            //   b904000000           | mov                 ecx, 4
            //   6bd100               | imul                edx, ecx, 0
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   894c1018             | mov                 dword ptr [eax + edx + 0x18], ecx

        $sequence_8 = { 83c40c 8d95fcfeffff 52 8b85f4faffff 50 8b8df8faffff e8???????? }
            // n = 7, score = 200
            //   83c40c               | add                 esp, 0xc
            //   8d95fcfeffff         | lea                 edx, [ebp - 0x104]
            //   52                   | push                edx
            //   8b85f4faffff         | mov                 eax, dword ptr [ebp - 0x50c]
            //   50                   | push                eax
            //   8b8df8faffff         | mov                 ecx, dword ptr [ebp - 0x508]
            //   e8????????           |                     

        $sequence_9 = { 8b8df0feffff 668901 e9???????? 8b95dcfeffff 83ea01 8995dcfeffff 8b4508 }
            // n = 7, score = 200
            //   8b8df0feffff         | mov                 ecx, dword ptr [ebp - 0x110]
            //   668901               | mov                 word ptr [ecx], ax
            //   e9????????           |                     
            //   8b95dcfeffff         | mov                 edx, dword ptr [ebp - 0x124]
            //   83ea01               | sub                 edx, 1
            //   8995dcfeffff         | mov                 dword ptr [ebp - 0x124], edx
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]

    condition:
        7 of them and filesize < 3743744
}