rule win_bubblewrap_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.bubblewrap."
        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.bubblewrap"
        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 = { 51 e8???????? 83c42c 8d542464 52 ff15???????? }
            // n = 6, score = 100
            //   51                   | push                ecx
            //   e8????????           |                     
            //   83c42c               | add                 esp, 0x2c
            //   8d542464             | lea                 edx, [esp + 0x64]
            //   52                   | push                edx
            //   ff15????????         |                     

        $sequence_1 = { 6a00 e8???????? 83c418 68???????? ff15???????? b907000000 }
            // n = 6, score = 100
            //   6a00                 | push                0
            //   e8????????           |                     
            //   83c418               | add                 esp, 0x18
            //   68????????           |                     
            //   ff15????????         |                     
            //   b907000000           | mov                 ecx, 7

        $sequence_2 = { 8915???????? 8b15???????? a3???????? 66a1???????? 880d???????? b910000000 }
            // n = 6, score = 100
            //   8915????????         |                     
            //   8b15????????         |                     
            //   a3????????           |                     
            //   66a1????????         |                     
            //   880d????????         |                     
            //   b910000000           | mov                 ecx, 0x10

        $sequence_3 = { a4 8a841cb0000000 84c0 740d }
            // n = 4, score = 100
            //   a4                   | movsb               byte ptr es:[edi], byte ptr [esi]
            //   8a841cb0000000       | mov                 al, byte ptr [esp + ebx + 0xb0]
            //   84c0                 | test                al, al
            //   740d                 | je                  0xf

        $sequence_4 = { 880c2b 8bc8 8bd1 8d7c2b01 c1e902 }
            // n = 5, score = 100
            //   880c2b               | mov                 byte ptr [ebx + ebp], cl
            //   8bc8                 | mov                 ecx, eax
            //   8bd1                 | mov                 edx, ecx
            //   8d7c2b01             | lea                 edi, [ebx + ebp + 1]
            //   c1e902               | shr                 ecx, 2

        $sequence_5 = { e8???????? 83c408 be???????? b8???????? 8a10 }
            // n = 5, score = 100
            //   e8????????           |                     
            //   83c408               | add                 esp, 8
            //   be????????           |                     
            //   b8????????           |                     
            //   8a10                 | mov                 dl, byte ptr [eax]

        $sequence_6 = { 6800b00400 51 52 ff15???????? 85c0 752f }
            // n = 6, score = 100
            //   6800b00400           | push                0x4b000
            //   51                   | push                ecx
            //   52                   | push                edx
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   752f                 | jne                 0x31

        $sequence_7 = { 8d7c240c 2bf1 8d44241c 4e 50 8bce }
            // n = 6, score = 100
            //   8d7c240c             | lea                 edi, [esp + 0xc]
            //   2bf1                 | sub                 esi, ecx
            //   8d44241c             | lea                 eax, [esp + 0x1c]
            //   4e                   | dec                 esi
            //   50                   | push                eax
            //   8bce                 | mov                 ecx, esi

        $sequence_8 = { 52 894c2438 888c24b4010000 b940000000 895c246c }
            // n = 5, score = 100
            //   52                   | push                edx
            //   894c2438             | mov                 dword ptr [esp + 0x38], ecx
            //   888c24b4010000       | mov                 byte ptr [esp + 0x1b4], cl
            //   b940000000           | mov                 ecx, 0x40
            //   895c246c             | mov                 dword ptr [esp + 0x6c], ebx

        $sequence_9 = { 83c9ff 8dbc2470030000 f2ae f7d1 }
            // n = 4, score = 100
            //   83c9ff               | or                  ecx, 0xffffffff
            //   8dbc2470030000       | lea                 edi, [esp + 0x370]
            //   f2ae                 | repne scasb         al, byte ptr es:[edi]
            //   f7d1                 | not                 ecx

    condition:
        7 of them and filesize < 57136
}