rule win_moriagent_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-05-04"
        version = "1"
        description = "Detects win.moriagent."
        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.moriagent"
        malpedia_rule_date = "20260422"
        malpedia_hash = "a182e35da64e6d71cb55f125c4d4225196523f14"
        malpedia_version = "20260504"
        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 = { 8841ff 84c0 75f3 68027f0000 6a00 ff15???????? }
            // n = 6, score = 100
            //   8841ff               | mov                 byte ptr [ecx - 1], al
            //   84c0                 | test                al, al
            //   75f3                 | jne                 0xfffffff5
            //   68027f0000           | push                0x7f02
            //   6a00                 | push                0
            //   ff15????????         |                     

        $sequence_1 = { 8b4528 c78564efffff00000000 c78568efffff0f000000 c68554efffff00 89b5d0eeffff 898500efffff 3bf0 }
            // n = 7, score = 100
            //   8b4528               | mov                 eax, dword ptr [ebp + 0x28]
            //   c78564efffff00000000     | mov    dword ptr [ebp - 0x109c], 0
            //   c78568efffff0f000000     | mov    dword ptr [ebp - 0x1098], 0xf
            //   c68554efffff00       | mov                 byte ptr [ebp - 0x10ac], 0
            //   89b5d0eeffff         | mov                 dword ptr [ebp - 0x1130], esi
            //   898500efffff         | mov                 dword ptr [ebp - 0x1100], eax
            //   3bf0                 | cmp                 esi, eax

        $sequence_2 = { 3b7814 7308 8bc7 5f 5e 8be5 5d }
            // n = 7, score = 100
            //   3b7814               | cmp                 edi, dword ptr [eax + 0x14]
            //   7308                 | jae                 0xa
            //   8bc7                 | mov                 eax, edi
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp

        $sequence_3 = { e8???????? 03c7 8985d8eeffff 3bb550efffff 7432 52 c7461000000000 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   03c7                 | add                 eax, edi
            //   8985d8eeffff         | mov                 dword ptr [ebp - 0x1128], eax
            //   3bb550efffff         | cmp                 esi, dword ptr [ebp - 0x10b0]
            //   7432                 | je                  0x34
            //   52                   | push                edx
            //   c7461000000000       | mov                 dword ptr [esi + 0x10], 0

        $sequence_4 = { 50 c785e8feffff00000000 ff35???????? ff15???????? 50 8d85ecfeffff c7461000000000 }
            // n = 7, score = 100
            //   50                   | push                eax
            //   c785e8feffff00000000     | mov    dword ptr [ebp - 0x118], 0
            //   ff35????????         |                     
            //   ff15????????         |                     
            //   50                   | push                eax
            //   8d85ecfeffff         | lea                 eax, [ebp - 0x114]
            //   c7461000000000       | mov                 dword ptr [esi + 0x10], 0

        $sequence_5 = { 7202 8b01 8bb5bceeffff 66893410 c644100200 eb1d 6a02 }
            // n = 7, score = 100
            //   7202                 | jb                  4
            //   8b01                 | mov                 eax, dword ptr [ecx]
            //   8bb5bceeffff         | mov                 esi, dword ptr [ebp - 0x1144]
            //   66893410             | mov                 word ptr [eax + edx], si
            //   c644100200           | mov                 byte ptr [eax + edx + 2], 0
            //   eb1d                 | jmp                 0x1f
            //   6a02                 | push                2

        $sequence_6 = { 8b9568efffff 83fa10 722f 8b8d54efffff }
            // n = 4, score = 100
            //   8b9568efffff         | mov                 edx, dword ptr [ebp - 0x1098]
            //   83fa10               | cmp                 edx, 0x10
            //   722f                 | jb                  0x31
            //   8b8d54efffff         | mov                 ecx, dword ptr [ebp - 0x10ac]

        $sequence_7 = { e8???????? 83c408 8b45f0 03c7 893b 894304 8b45f8 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   83c408               | add                 esp, 8
            //   8b45f0               | mov                 eax, dword ptr [ebp - 0x10]
            //   03c7                 | add                 eax, edi
            //   893b                 | mov                 dword ptr [ebx], edi
            //   894304               | mov                 dword ptr [ebx + 4], eax
            //   8b45f8               | mov                 eax, dword ptr [ebp - 8]

        $sequence_8 = { 3bc6 0f42c6 3daaaaaa0a 0f872f010000 8d3c40 c1e703 81ff00100000 }
            // n = 7, score = 100
            //   3bc6                 | cmp                 eax, esi
            //   0f42c6               | cmovb               eax, esi
            //   3daaaaaa0a           | cmp                 eax, 0xaaaaaaa
            //   0f872f010000         | ja                  0x135
            //   8d3c40               | lea                 edi, [eax + eax*2]
            //   c1e703               | shl                 edi, 3
            //   81ff00100000         | cmp                 edi, 0x1000

        $sequence_9 = { 51 52 8d4dc8 e8???????? 8b45e4 8d4dc8 3bc1 }
            // n = 7, score = 100
            //   51                   | push                ecx
            //   52                   | push                edx
            //   8d4dc8               | lea                 ecx, [ebp - 0x38]
            //   e8????????           |                     
            //   8b45e4               | mov                 eax, dword ptr [ebp - 0x1c]
            //   8d4dc8               | lea                 ecx, [ebp - 0x38]
            //   3bc1                 | cmp                 eax, ecx

    condition:
        7 of them and filesize < 720896
}