rule win_warmcookie_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.warmcookie."
        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.warmcookie"
        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 = { c744242880000000 c744242003000000 41b900000000 41b807000000 ba00000080 }
            // n = 5, score = 900
            //   c744242880000000     | dec                 ecx
            //   c744242003000000     | mov                 eax, ebx
            //   41b900000000         | dec                 eax
            //   41b807000000         | mov                 ecx, ebx
            //   ba00000080           | dec                 ecx

        $sequence_1 = { 41b902000000 41b800000000 ba00000000 4889c1 }
            // n = 4, score = 900
            //   41b902000000         | inc                 ecx
            //   41b800000000         | mov                 eax, 7
            //   ba00000000           | mov                 edx, 0x80000000
            //   4889c1               | dec                 eax

        $sequence_2 = { 899c2498000000 488d5e02 48896c2470 8944242c 48b8fffffffffdffffff 4889842480000000 31c0 }
            // n = 7, score = 900
            //   899c2498000000       | mov                 eax, 0
            //   488d5e02             | mov                 edx, 0
            //   48896c2470           | dec                 eax
            //   8944242c             | mov                 ecx, eax
            //   48b8fffffffffdffffff     | dec    eax
            //   4889842480000000     | mov                 dword ptr [esp + 0x30], 0
            //   31c0                 | mov                 dword ptr [esp + 0x28], 0x80

        $sequence_3 = { 83e830 6683f809 0f8709060000 4183fe03 }
            // n = 4, score = 900
            //   83e830               | mov                 eax, 7
            //   6683f809             | mov                 edx, 0x80000000
            //   0f8709060000         | inc                 ecx
            //   4183fe03             | mov                 ecx, 0

        $sequence_4 = { 415c c3 55 4157 4156 4155 }
            // n = 6, score = 900
            //   415c                 | inc                 ecx
            //   c3                   | mov                 eax, 7
            //   55                   | mov                 edx, 0x80000000
            //   4157                 | dec                 eax
            //   4156                 | mov                 ecx, eax
            //   4155                 | dec                 eax

        $sequence_5 = { 4181f80080ffff 7470 8b4c2448 4889c2 }
            // n = 4, score = 900
            //   4181f80080ffff       | mov                 dword ptr [esp + 0x20], 3
            //   7470                 | inc                 ecx
            //   8b4c2448             | mov                 ecx, 0
            //   4889c2               | inc                 ecx

        $sequence_6 = { 0f8e1bffffff 01d0 89430c e9???????? 4157 4156 }
            // n = 6, score = 900
            //   0f8e1bffffff         | dec                 eax
            //   01d0                 | mov                 ecx, eax
            //   89430c               | inc                 ecx
            //   e9????????           |                     
            //   4157                 | mov                 ecx, 2
            //   4156                 | inc                 ecx

        $sequence_7 = { e8???????? 3dff2f0000 0f97c0 0fb6c0 }
            // n = 4, score = 700
            //   e8????????           |                     
            //   3dff2f0000           | cmp                 eax, 0x2fff
            //   0f97c0               | seta                al
            //   0fb6c0               | movzx               eax, al

        $sequence_8 = { ba19000000 488b4c2438 ff15???????? 85c0 }
            // n = 4, score = 700
            //   ba19000000           | mov                 edx, 0x19
            //   488b4c2438           | dec                 eax
            //   ff15????????         |                     
            //   85c0                 | mov                 ecx, dword ptr [esp + 0x38]

        $sequence_9 = { ff5010 b9e8030000 ff15???????? 83ef01 }
            // n = 4, score = 600
            //   ff5010               | std                 
            //   b9e8030000           | inc                 ecx
            //   ff15????????         |                     
            //   83ef01               | cmp                 eax, 0xffff8000

        $sequence_10 = { 85c0 7409 488b442428 48c1e814 }
            // n = 4, score = 600
            //   85c0                 | dec                 eax
            //   7409                 | mov                 ecx, eax
            //   488b442428           | call                ebx
            //   48c1e814             | test                eax, eax

        $sequence_11 = { 488d4c0301 4801c9 e8???????? 4889c3 4885c0 }
            // n = 5, score = 600
            //   488d4c0301           | add                 ecx, esi
            //   4801c9               | mov                 dword ptr [esi + 0x20], edi
            //   e8????????           |                     
            //   4889c3               | dec                 eax
            //   4885c0               | mov                 ebx, dword ptr [esp + 0x60]

        $sequence_12 = { ff15???????? 25ff0f0000 8d88b80b0000 ff15???????? }
            // n = 4, score = 600
            //   ff15????????         |                     
            //   25ff0f0000           | dec                 eax
            //   8d88b80b0000         | shr                 eax, 0x14
            //   ff15????????         |                     

        $sequence_13 = { ba18000000 4889c1 ffd3 85c0 }
            // n = 4, score = 600
            //   ba18000000           | cmp                 eax, 0x2fff
            //   4889c1               | seta                al
            //   ffd3                 | movzx               eax, al
            //   85c0                 | mov                 edx, 0x18

        $sequence_14 = { 488b01 ff9080000000 85c0 7815 }
            // n = 4, score = 600
            //   488b01               | test                eax, eax
            //   ff9080000000         | je                  0xb
            //   85c0                 | dec                 eax
            //   7815                 | mov                 eax, dword ptr [esp + 0x28]

        $sequence_15 = { 6642837c40fe00 75f3 4b8d1c00 4889d9 e8???????? 4989d8 }
            // n = 6, score = 500
            //   6642837c40fe00       | and                 eax, 0xfff
            //   75f3                 | lea                 ecx, [eax + 0xbb8]
            //   4b8d1c00             | dec                 eax
            //   4889d9               | mov                 eax, ebp
            //   e8????????           |                     
            //   4989d8               |                     

        $sequence_16 = { 4889e8 f0480fb13b 4885c0 75e2 488b3d???????? 31ed }
            // n = 6, score = 500
            //   4889e8               | dec                 eax
            //   f0480fb13b           | mov                 eax, dword ptr [ecx]
            //   4885c0               | call                dword ptr [eax + 0x80]
            //   75e2                 | test                eax, eax
            //   488b3d????????       |                     
            //   31ed                 | js                  0x1f

        $sequence_17 = { 488d542470 b901010000 ff15???????? 85c0 }
            // n = 4, score = 300
            //   488d542470           | inc                 ecx
            //   b901010000           | mov                 ecx, 0
            //   ff15????????         |                     
            //   85c0                 | inc                 ecx

        $sequence_18 = { 488b5c2460 8d4801 e8???????? 4c8bf8 }
            // n = 4, score = 300
            //   488b5c2460           | cmp                 eax, 0x2fff
            //   8d4801               | seta                al
            //   e8????????           |                     
            //   4c8bf8               | cmp                 eax, 0x2fff

        $sequence_19 = { ff15???????? 488be8 4883f8ff 7444 4533c9 }
            // n = 5, score = 300
            //   ff15????????         |                     
            //   488be8               | seta                al
            //   4883f8ff             | movzx               eax, al
            //   7444                 | test                eax, eax
            //   4533c9               | je                  0xb

        $sequence_20 = { 4b8d040b 4688441102 483d00010000 72c8 488b5c2408 488b742410 }
            // n = 6, score = 300
            //   4b8d040b             | mov                 eax, 7
            //   4688441102           | mov                 edx, 0x80000000
            //   483d00010000         | inc                 ecx
            //   72c8                 | mov                 ecx, 0
            //   488b5c2408           | inc                 ecx
            //   488b742410           | mov                 eax, 7

        $sequence_21 = { 83f805 7c34 e8???????? 83f804 720c e8???????? 3d000f0000 }
            // n = 7, score = 300
            //   83f805               | dec                 eax
            //   7c34                 | mov                 eax, dword ptr [esp + 0x28]
            //   e8????????           |                     
            //   83f804               | dec                 eax
            //   720c                 | shr                 eax, 0x14
            //   e8????????           |                     
            //   3d000f0000           | call                dword ptr [eax + 0x10]

        $sequence_22 = { ff15???????? 85c0 75c2 85f6 740f }
            // n = 5, score = 300
            //   ff15????????         |                     
            //   85c0                 | sub                 esp, 0x28
            //   75c2                 | cmp                 eax, 0x2fff
            //   85f6                 | seta                al
            //   740f                 | movzx               eax, al

        $sequence_23 = { 8bcf 498bd6 4803ce e8???????? 897e20 }
            // n = 5, score = 300
            //   8bcf                 | mov                 edx, 0x80000000
            //   498bd6               | dec                 eax
            //   4803ce               | mov                 ecx, eax
            //   e8????????           |                     
            //   897e20               | dec                 eax

    condition:
        7 of them and filesize < 331776
}