rule win_phobos_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.phobos."
        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.phobos"
        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 = { 1bc0 83c02c 50 e8???????? 59 59 8944242c }
            // n = 7, score = 100
            //   1bc0                 | sbb                 eax, eax
            //   83c02c               | add                 eax, 0x2c
            //   50                   | push                eax
            //   e8????????           |                     
            //   59                   | pop                 ecx
            //   59                   | pop                 ecx
            //   8944242c             | mov                 dword ptr [esp + 0x2c], eax

        $sequence_1 = { e8???????? 8b03 83c40c 83c020 6880000000 50 8d4728 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   8b03                 | mov                 eax, dword ptr [ebx]
            //   83c40c               | add                 esp, 0xc
            //   83c020               | add                 eax, 0x20
            //   6880000000           | push                0x80
            //   50                   | push                eax
            //   8d4728               | lea                 eax, [edi + 0x28]

        $sequence_2 = { 663b07 7429 ff4508 668b06 83c602 6685c0 }
            // n = 6, score = 100
            //   663b07               | cmp                 ax, word ptr [edi]
            //   7429                 | je                  0x2b
            //   ff4508               | inc                 dword ptr [ebp + 8]
            //   668b06               | mov                 ax, word ptr [esi]
            //   83c602               | add                 esi, 2
            //   6685c0               | test                ax, ax

        $sequence_3 = { c1ef18 0fb6bfd0c54000 c1e708 33df 8b7df4 c1ef08 23f8 }
            // n = 7, score = 100
            //   c1ef18               | shr                 edi, 0x18
            //   0fb6bfd0c54000       | movzx               edi, byte ptr [edi + 0x40c5d0]
            //   c1e708               | shl                 edi, 8
            //   33df                 | xor                 ebx, edi
            //   8b7df4               | mov                 edi, dword ptr [ebp - 0xc]
            //   c1ef08               | shr                 edi, 8
            //   23f8                 | and                 edi, eax

        $sequence_4 = { 8bcf d3ea 8890e0c64000 8b5654 d3ea 8890e4c64000 8b5658 }
            // n = 7, score = 100
            //   8bcf                 | mov                 ecx, edi
            //   d3ea                 | shr                 edx, cl
            //   8890e0c64000         | mov                 byte ptr [eax + 0x40c6e0], dl
            //   8b5654               | mov                 edx, dword ptr [esi + 0x54]
            //   d3ea                 | shr                 edx, cl
            //   8890e4c64000         | mov                 byte ptr [eax + 0x40c6e4], dl
            //   8b5658               | mov                 edx, dword ptr [esi + 0x58]

        $sequence_5 = { 8b5dfc c1eb18 333c9dd0b54000 8b5df8 23d8 }
            // n = 5, score = 100
            //   8b5dfc               | mov                 ebx, dword ptr [ebp - 4]
            //   c1eb18               | shr                 ebx, 0x18
            //   333c9dd0b54000       | xor                 edi, dword ptr [ebx*4 + 0x40b5d0]
            //   8b5df8               | mov                 ebx, dword ptr [ebp - 8]
            //   23d8                 | and                 ebx, eax

        $sequence_6 = { 884604 884e05 8bc8 c1e818 884607 8bc2 c1e808 }
            // n = 7, score = 100
            //   884604               | mov                 byte ptr [esi + 4], al
            //   884e05               | mov                 byte ptr [esi + 5], cl
            //   8bc8                 | mov                 ecx, eax
            //   c1e818               | shr                 eax, 0x18
            //   884607               | mov                 byte ptr [esi + 7], al
            //   8bc2                 | mov                 eax, edx
            //   c1e808               | shr                 eax, 8

        $sequence_7 = { 57 8d7e0c 57 ff15???????? 57 ff15???????? }
            // n = 6, score = 100
            //   57                   | push                edi
            //   8d7e0c               | lea                 edi, [esi + 0xc]
            //   57                   | push                edi
            //   ff15????????         |                     
            //   57                   | push                edi
            //   ff15????????         |                     

        $sequence_8 = { 8bc7 5f 5d c3 55 8bec 68a4000000 }
            // n = 7, score = 100
            //   8bc7                 | mov                 eax, edi
            //   5f                   | pop                 edi
            //   5d                   | pop                 ebp
            //   c3                   | ret                 
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   68a4000000           | push                0xa4

        $sequence_9 = { 83c40c 8945f8 8b4dfc 33d2 8955f4 0fb70453 8b7df8 }
            // n = 7, score = 100
            //   83c40c               | add                 esp, 0xc
            //   8945f8               | mov                 dword ptr [ebp - 8], eax
            //   8b4dfc               | mov                 ecx, dword ptr [ebp - 4]
            //   33d2                 | xor                 edx, edx
            //   8955f4               | mov                 dword ptr [ebp - 0xc], edx
            //   0fb70453             | movzx               eax, word ptr [ebx + edx*2]
            //   8b7df8               | mov                 edi, dword ptr [ebp - 8]

    condition:
        7 of them and filesize < 139264
}