rule win_defray_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.defray."
        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.defray"
        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 = { 81c630020000 83eb01 75e3 8d8dc8fdffff e8???????? 8d8d98fbffff e8???????? }
            // n = 7, score = 200
            //   81c630020000         | add                 esi, 0x230
            //   83eb01               | sub                 ebx, 1
            //   75e3                 | jne                 0xffffffe5
            //   8d8dc8fdffff         | lea                 ecx, [ebp - 0x238]
            //   e8????????           |                     
            //   8d8d98fbffff         | lea                 ecx, [ebp - 0x468]
            //   e8????????           |                     

        $sequence_1 = { 3bc6 734a 807da100 8a8884e64600 8b4598 8808 7505 }
            // n = 7, score = 200
            //   3bc6                 | cmp                 eax, esi
            //   734a                 | jae                 0x4c
            //   807da100             | cmp                 byte ptr [ebp - 0x5f], 0
            //   8a8884e64600         | mov                 cl, byte ptr [eax + 0x46e684]
            //   8b4598               | mov                 eax, dword ptr [ebp - 0x68]
            //   8808                 | mov                 byte ptr [eax], cl
            //   7505                 | jne                 7

        $sequence_2 = { ab ab ab 33c0 8dbdf4f9ffff a5 a5 }
            // n = 7, score = 200
            //   ab                   | stosd               dword ptr es:[edi], eax
            //   ab                   | stosd               dword ptr es:[edi], eax
            //   ab                   | stosd               dword ptr es:[edi], eax
            //   33c0                 | xor                 eax, eax
            //   8dbdf4f9ffff         | lea                 edi, [ebp - 0x60c]
            //   a5                   | movsd               dword ptr es:[edi], dword ptr [esi]
            //   a5                   | movsd               dword ptr es:[edi], dword ptr [esi]

        $sequence_3 = { 83c40c 83601000 8b4df0 68???????? 8d4918 e8???????? 8d45ec }
            // n = 7, score = 200
            //   83c40c               | add                 esp, 0xc
            //   83601000             | and                 dword ptr [eax + 0x10], 0
            //   8b4df0               | mov                 ecx, dword ptr [ebp - 0x10]
            //   68????????           |                     
            //   8d4918               | lea                 ecx, [ecx + 0x18]
            //   e8????????           |                     
            //   8d45ec               | lea                 eax, [ebp - 0x14]

        $sequence_4 = { 6685c0 75ef 46 c785b8fdffff01000000 8935???????? 8d85b8fdffff 33f6 }
            // n = 7, score = 200
            //   6685c0               | test                ax, ax
            //   75ef                 | jne                 0xfffffff1
            //   46                   | inc                 esi
            //   c785b8fdffff01000000     | mov    dword ptr [ebp - 0x248], 1
            //   8935????????         |                     
            //   8d85b8fdffff         | lea                 eax, [ebp - 0x248]
            //   33f6                 | xor                 esi, esi

        $sequence_5 = { 8d4918 e8???????? 8d45ec c645fc04 50 }
            // n = 5, score = 200
            //   8d4918               | lea                 ecx, [ecx + 0x18]
            //   e8????????           |                     
            //   8d45ec               | lea                 eax, [ebp - 0x14]
            //   c645fc04             | mov                 byte ptr [ebp - 4], 4
            //   50                   | push                eax

        $sequence_6 = { 52 e8???????? 8bc7 e8???????? c21000 55 8bec }
            // n = 7, score = 200
            //   52                   | push                edx
            //   e8????????           |                     
            //   8bc7                 | mov                 eax, edi
            //   e8????????           |                     
            //   c21000               | ret                 0x10
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp

        $sequence_7 = { 0f85f0030000 8d85c0fdffff 50 ff15???????? 83f8ff 0f84da030000 8d85c0fdffff }
            // n = 7, score = 200
            //   0f85f0030000         | jne                 0x3f6
            //   8d85c0fdffff         | lea                 eax, [ebp - 0x240]
            //   50                   | push                eax
            //   ff15????????         |                     
            //   83f8ff               | cmp                 eax, -1
            //   0f84da030000         | je                  0x3e0
            //   8d85c0fdffff         | lea                 eax, [ebp - 0x240]

        $sequence_8 = { 83c410 8bf0 8d4dbc 895dfc e8???????? 8b0e c745bc48114800 }
            // n = 7, score = 200
            //   83c410               | add                 esp, 0x10
            //   8bf0                 | mov                 esi, eax
            //   8d4dbc               | lea                 ecx, [ebp - 0x44]
            //   895dfc               | mov                 dword ptr [ebp - 4], ebx
            //   e8????????           |                     
            //   8b0e                 | mov                 ecx, dword ptr [esi]
            //   c745bc48114800       | mov                 dword ptr [ebp - 0x44], 0x481148

        $sequence_9 = { 8975f0 8b4508 8d4e10 83660c00 8906 8b450c }
            // n = 6, score = 200
            //   8975f0               | mov                 dword ptr [ebp - 0x10], esi
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   8d4e10               | lea                 ecx, [esi + 0x10]
            //   83660c00             | and                 dword ptr [esi + 0xc], 0
            //   8906                 | mov                 dword ptr [esi], eax
            //   8b450c               | mov                 eax, dword ptr [ebp + 0xc]

    condition:
        7 of them and filesize < 1253376
}