rule win_mutabaha_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.mutabaha."
        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.mutabaha"
        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 = { 8bcf e8???????? 3bf0 741a 83ee02 ebd7 }
            // n = 6, score = 100
            //   8bcf                 | mov                 ecx, edi
            //   e8????????           |                     
            //   3bf0                 | cmp                 esi, eax
            //   741a                 | je                  0x1c
            //   83ee02               | sub                 esi, 2
            //   ebd7                 | jmp                 0xffffffd9

        $sequence_1 = { 8b0e 8b4604 894104 ff4a04 8b4f18 85c9 7406 }
            // n = 7, score = 100
            //   8b0e                 | mov                 ecx, dword ptr [esi]
            //   8b4604               | mov                 eax, dword ptr [esi + 4]
            //   894104               | mov                 dword ptr [ecx + 4], eax
            //   ff4a04               | dec                 dword ptr [edx + 4]
            //   8b4f18               | mov                 ecx, dword ptr [edi + 0x18]
            //   85c9                 | test                ecx, ecx
            //   7406                 | je                  8

        $sequence_2 = { 8d4d84 e9???????? 8b459c 83e001 0f840c000000 83659cfe 8b4d80 }
            // n = 7, score = 100
            //   8d4d84               | lea                 ecx, [ebp - 0x7c]
            //   e9????????           |                     
            //   8b459c               | mov                 eax, dword ptr [ebp - 0x64]
            //   83e001               | and                 eax, 1
            //   0f840c000000         | je                  0x12
            //   83659cfe             | and                 dword ptr [ebp - 0x64], 0xfffffffe
            //   8b4d80               | mov                 ecx, dword ptr [ebp - 0x80]

        $sequence_3 = { 33c5 8945fc 53 8b5d08 56 6a00 }
            // n = 6, score = 100
            //   33c5                 | xor                 eax, ebp
            //   8945fc               | mov                 dword ptr [ebp - 4], eax
            //   53                   | push                ebx
            //   8b5d08               | mov                 ebx, dword ptr [ebp + 8]
            //   56                   | push                esi
            //   6a00                 | push                0

        $sequence_4 = { e8???????? 8b0f 8b01 8b4004 f644080c01 0f8532040000 8b0f }
            // n = 7, score = 100
            //   e8????????           |                     
            //   8b0f                 | mov                 ecx, dword ptr [edi]
            //   8b01                 | mov                 eax, dword ptr [ecx]
            //   8b4004               | mov                 eax, dword ptr [eax + 4]
            //   f644080c01           | test                byte ptr [eax + ecx + 0xc], 1
            //   0f8532040000         | jne                 0x438
            //   8b0f                 | mov                 ecx, dword ptr [edi]

        $sequence_5 = { 50 56 8d45dc 50 e8???????? 837dec00 7504 }
            // n = 7, score = 100
            //   50                   | push                eax
            //   56                   | push                esi
            //   8d45dc               | lea                 eax, [ebp - 0x24]
            //   50                   | push                eax
            //   e8????????           |                     
            //   837dec00             | cmp                 dword ptr [ebp - 0x14], 0
            //   7504                 | jne                 6

        $sequence_6 = { 85c0 0f8556010000 ffb5f4f7ffff 8d85fcf7ffff 68???????? 6800020000 50 }
            // n = 7, score = 100
            //   85c0                 | test                eax, eax
            //   0f8556010000         | jne                 0x15c
            //   ffb5f4f7ffff         | push                dword ptr [ebp - 0x80c]
            //   8d85fcf7ffff         | lea                 eax, [ebp - 0x804]
            //   68????????           |                     
            //   6800020000           | push                0x200
            //   50                   | push                eax

        $sequence_7 = { e8???????? 83c404 c645fc0e 8d8d6ce6ffff 51 8bd0 8d8d3ce6ffff }
            // n = 7, score = 100
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   c645fc0e             | mov                 byte ptr [ebp - 4], 0xe
            //   8d8d6ce6ffff         | lea                 ecx, [ebp - 0x1994]
            //   51                   | push                ecx
            //   8bd0                 | mov                 edx, eax
            //   8d8d3ce6ffff         | lea                 ecx, [ebp - 0x19c4]

        $sequence_8 = { eb05 68???????? 6800020000 50 e8???????? 83c410 8d85fcf3ffff }
            // n = 7, score = 100
            //   eb05                 | jmp                 7
            //   68????????           |                     
            //   6800020000           | push                0x200
            //   50                   | push                eax
            //   e8????????           |                     
            //   83c410               | add                 esp, 0x10
            //   8d85fcf3ffff         | lea                 eax, [ebp - 0xc04]

        $sequence_9 = { 7426 8d442428 50 6a01 6a02 6a00 68ff010f00 }
            // n = 7, score = 100
            //   7426                 | je                  0x28
            //   8d442428             | lea                 eax, [esp + 0x28]
            //   50                   | push                eax
            //   6a01                 | push                1
            //   6a02                 | push                2
            //   6a00                 | push                0
            //   68ff010f00           | push                0xf01ff

    condition:
        7 of them and filesize < 1220608
}