rule win_cutwail_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.cutwail."
        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.cutwail"
        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 = { 50 6800020000 8d8df8fdffff 51 8b95ecfdffff }
            // n = 5, score = 100
            //   50                   | push                eax
            //   6800020000           | push                0x200
            //   8d8df8fdffff         | lea                 ecx, [ebp - 0x208]
            //   51                   | push                ecx
            //   8b95ecfdffff         | mov                 edx, dword ptr [ebp - 0x214]

        $sequence_1 = { 6a00 6a00 8b8d50feffff 51 68???????? 6a00 6a00 }
            // n = 7, score = 100
            //   6a00                 | push                0
            //   6a00                 | push                0
            //   8b8d50feffff         | mov                 ecx, dword ptr [ebp - 0x1b0]
            //   51                   | push                ecx
            //   68????????           |                     
            //   6a00                 | push                0
            //   6a00                 | push                0

        $sequence_2 = { 034630 83c414 03462c 47 3bf8 }
            // n = 5, score = 100
            //   034630               | add                 eax, dword ptr [esi + 0x30]
            //   83c414               | add                 esp, 0x14
            //   03462c               | add                 eax, dword ptr [esi + 0x2c]
            //   47                   | inc                 edi
            //   3bf8                 | cmp                 edi, eax

        $sequence_3 = { 50 e8???????? 83c408 68???????? 8d8df8fdffff 51 ff15???????? }
            // n = 7, score = 100
            //   50                   | push                eax
            //   e8????????           |                     
            //   83c408               | add                 esp, 8
            //   68????????           |                     
            //   8d8df8fdffff         | lea                 ecx, [ebp - 0x208]
            //   51                   | push                ecx
            //   ff15????????         |                     

        $sequence_4 = { 3bc3 8945f8 0f840d030000 6a01 57 }
            // n = 5, score = 100
            //   3bc3                 | cmp                 eax, ebx
            //   8945f8               | mov                 dword ptr [ebp - 8], eax
            //   0f840d030000         | je                  0x313
            //   6a01                 | push                1
            //   57                   | push                edi

        $sequence_5 = { 833800 7511 837df800 7e0b }
            // n = 4, score = 100
            //   833800               | cmp                 dword ptr [eax], 0
            //   7511                 | jne                 0x13
            //   837df800             | cmp                 dword ptr [ebp - 8], 0
            //   7e0b                 | jle                 0xd

        $sequence_6 = { 57 50 ff7544 89455c }
            // n = 4, score = 100
            //   57                   | push                edi
            //   50                   | push                eax
            //   ff7544               | push                dword ptr [ebp + 0x44]
            //   89455c               | mov                 dword ptr [ebp + 0x5c], eax

        $sequence_7 = { eb77 83bd6cfeffff05 7d6e ff15???????? 89855cfeffff }
            // n = 5, score = 100
            //   eb77                 | jmp                 0x79
            //   83bd6cfeffff05       | cmp                 dword ptr [ebp - 0x194], 5
            //   7d6e                 | jge                 0x70
            //   ff15????????         |                     
            //   89855cfeffff         | mov                 dword ptr [ebp - 0x1a4], eax

        $sequence_8 = { 53 53 be58020000 56 8945fc }
            // n = 5, score = 100
            //   53                   | push                ebx
            //   53                   | push                ebx
            //   be58020000           | mov                 esi, 0x258
            //   56                   | push                esi
            //   8945fc               | mov                 dword ptr [ebp - 4], eax

        $sequence_9 = { 32c0 eb6c 6a00 8b4510 50 8b4d0c 034dfc }
            // n = 7, score = 100
            //   32c0                 | xor                 al, al
            //   eb6c                 | jmp                 0x6e
            //   6a00                 | push                0
            //   8b4510               | mov                 eax, dword ptr [ebp + 0x10]
            //   50                   | push                eax
            //   8b4d0c               | mov                 ecx, dword ptr [ebp + 0xc]
            //   034dfc               | add                 ecx, dword ptr [ebp - 4]

        $sequence_10 = { 33c0 e9???????? 57 57 6a08 }
            // n = 5, score = 100
            //   33c0                 | xor                 eax, eax
            //   e9????????           |                     
            //   57                   | push                edi
            //   57                   | push                edi
            //   6a08                 | push                8

        $sequence_11 = { 8b4e04 57 ff742420 03c8 }
            // n = 4, score = 100
            //   8b4e04               | mov                 ecx, dword ptr [esi + 4]
            //   57                   | push                edi
            //   ff742420             | push                dword ptr [esp + 0x20]
            //   03c8                 | add                 ecx, eax

        $sequence_12 = { 50 ff75fc e8???????? 83c410 ff45f0 }
            // n = 5, score = 100
            //   50                   | push                eax
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   e8????????           |                     
            //   83c410               | add                 esp, 0x10
            //   ff45f0               | inc                 dword ptr [ebp - 0x10]

        $sequence_13 = { 51 ff15???????? 85c0 0f8481000000 817dec03010000 750d 6888130000 }
            // n = 7, score = 100
            //   51                   | push                ecx
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   0f8481000000         | je                  0x87
            //   817dec03010000       | cmp                 dword ptr [ebp - 0x14], 0x103
            //   750d                 | jne                 0xf
            //   6888130000           | push                0x1388

        $sequence_14 = { 8955fc 8b4510 2b45f8 894510 eb9a 837d1400 }
            // n = 6, score = 100
            //   8955fc               | mov                 dword ptr [ebp - 4], edx
            //   8b4510               | mov                 eax, dword ptr [ebp + 0x10]
            //   2b45f8               | sub                 eax, dword ptr [ebp - 8]
            //   894510               | mov                 dword ptr [ebp + 0x10], eax
            //   eb9a                 | jmp                 0xffffff9c
            //   837d1400             | cmp                 dword ptr [ebp + 0x14], 0

        $sequence_15 = { 8b4720 8d740619 ff06 8b4578 }
            // n = 4, score = 100
            //   8b4720               | mov                 eax, dword ptr [edi + 0x20]
            //   8d740619             | lea                 esi, [esi + eax + 0x19]
            //   ff06                 | inc                 dword ptr [esi]
            //   8b4578               | mov                 eax, dword ptr [ebp + 0x78]

    condition:
        7 of them and filesize < 262144
}