rule win_xagent_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.xagent."
        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.xagent"
        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 = { c1ea02 6bd20d b801000000 2bc2 }
            // n = 4, score = 2900
            //   c1ea02               | shr                 edx, 2
            //   6bd20d               | imul                edx, edx, 0xd
            //   b801000000           | mov                 eax, 1
            //   2bc2                 | sub                 eax, edx

        $sequence_1 = { ff15???????? 8bd8 e8???????? 03d8 }
            // n = 4, score = 2900
            //   ff15????????         |                     
            //   8bd8                 | mov                 ebx, eax
            //   e8????????           |                     
            //   03d8                 | add                 ebx, eax

        $sequence_2 = { 7407 8b4d08 8b11 8910 83460404 }
            // n = 5, score = 2600
            //   7407                 | je                  9
            //   8b4d08               | mov                 ecx, dword ptr [ebp + 8]
            //   8b11                 | mov                 edx, dword ptr [ecx]
            //   8910                 | mov                 dword ptr [eax], edx
            //   83460404             | add                 dword ptr [esi + 4], 4

        $sequence_3 = { 57 8b7a08 c1e802 83e103 }
            // n = 4, score = 2600
            //   57                   | push                edi
            //   8b7a08               | mov                 edi, dword ptr [edx + 8]
            //   c1e802               | shr                 eax, 2
            //   83e103               | and                 ecx, 3

        $sequence_4 = { 8b0482 8b0488 8b4e10 85c9 7423 }
            // n = 5, score = 2600
            //   8b0482               | mov                 eax, dword ptr [edx + eax*4]
            //   8b0488               | mov                 eax, dword ptr [eax + ecx*4]
            //   8b4e10               | mov                 ecx, dword ptr [esi + 0x10]
            //   85c9                 | test                ecx, ecx
            //   7423                 | je                  0x25

        $sequence_5 = { 33d2 eb02 8b11 8b4808 8bc1 57 }
            // n = 6, score = 2600
            //   33d2                 | xor                 edx, edx
            //   eb02                 | jmp                 4
            //   8b11                 | mov                 edx, dword ptr [ecx]
            //   8b4808               | mov                 ecx, dword ptr [eax + 8]
            //   8bc1                 | mov                 eax, ecx
            //   57                   | push                edi

        $sequence_6 = { 55 8bec 33c0 83ec0c 39412c }
            // n = 5, score = 2600
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   33c0                 | xor                 eax, eax
            //   83ec0c               | sub                 esp, 0xc
            //   39412c               | cmp                 dword ptr [ecx + 0x2c], eax

        $sequence_7 = { ff15???????? 6a08 e8???????? 83c404 85c0 }
            // n = 5, score = 2600
            //   ff15????????         |                     
            //   6a08                 | push                8
            //   e8????????           |                     
            //   83c404               | add                 esp, 4
            //   85c0                 | test                eax, eax

        $sequence_8 = { 8be5 5d c20400 8d4de4 e8???????? b8???????? c3 }
            // n = 7, score = 2600
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp
            //   c20400               | ret                 4
            //   8d4de4               | lea                 ecx, [ebp - 0x1c]
            //   e8????????           |                     
            //   b8????????           |                     
            //   c3                   | ret                 

        $sequence_9 = { ff460c 03ff 03ff 3b7e0c 7707 }
            // n = 5, score = 2600
            //   ff460c               | inc                 dword ptr [esi + 0xc]
            //   03ff                 | add                 edi, edi
            //   03ff                 | add                 edi, edi
            //   3b7e0c               | cmp                 edi, dword ptr [esi + 0xc]
            //   7707                 | ja                  9

        $sequence_10 = { 84c0 740c 488b07 4c8b13 488903 4c8917 488b13 }
            // n = 7, score = 1300
            //   84c0                 | dec                 eax
            //   740c                 | mov                 ecx, dword ptr [ebx]
            //   488b07               | dec                 eax
            //   4c8b13               | mov                 dword ptr [ebx], eax
            //   488903               | dec                 eax
            //   4c8917               | mov                 dword ptr [edi], ecx
            //   488b13               | je                  0xe

        $sequence_11 = { 4883ec30 4883792800 498bf9 498bf0 488bea }
            // n = 5, score = 1300
            //   4883ec30             | jmp                 6
            //   4883792800           | xor                 al, al
            //   498bf9               | cmp                 al, 1
            //   498bf0               | mov                 eax, 0xa57eb503
            //   488bea               | mul                 esi

        $sequence_12 = { e8???????? 48833b00 740a 488b4308 }
            // n = 4, score = 1300
            //   e8????????           |                     
            //   48833b00             | mov                 ecx, edi
            //   740a                 | dec                 esp
            //   488b4308             | mov                 eax, esi

        $sequence_13 = { 4889742418 57 4883ec30 4883792800 }
            // n = 4, score = 1300
            //   4889742418           | shr                 edx, 6
            //   57                   | imul                edx, edx, 0x63
            //   4883ec30             | jne                 0xfffffffa
            //   4883792800           | dec                 ecx

        $sequence_14 = { 740c 488b07 488b0b 488903 }
            // n = 4, score = 1300
            //   740c                 | dec                 eax
            //   488b07               | cmp                 dword ptr [ebx], 0
            //   488b0b               | je                  0x10
            //   488903               | dec                 eax

        $sequence_15 = { e8???????? 488b4328 4c8bcf 4c8bc6 }
            // n = 4, score = 1300
            //   e8????????           |                     
            //   488b4328             | dec                 eax
            //   4c8bcf               | mov                 eax, dword ptr [ebx + 0x28]
            //   4c8bc6               | dec                 esp

        $sequence_16 = { 83f820 7512 8d48f4 ff15???????? }
            // n = 4, score = 1300
            //   83f820               | je                  0xe
            //   7512                 | dec                 eax
            //   8d48f4               | mov                 eax, dword ptr [edi]
            //   ff15????????         |                     

        $sequence_17 = { e8???????? 90 0fb705???????? 6689442420 }
            // n = 4, score = 1300
            //   e8????????           |                     
            //   90                   | nop                 
            //   0fb705????????       |                     
            //   6689442420           | mov                 word ptr [esp + 0x20], ax

        $sequence_18 = { b803b57ea5 f7e6 c1ea06 6bd263 }
            // n = 4, score = 500
            //   b803b57ea5           | jmp                 6
            //   f7e6                 | xor                 al, al
            //   c1ea06               | cmp                 al, 1
            //   6bd263               | jne                 6

        $sequence_19 = { 75f8 498bfb 482bfb 498b4c2428 }
            // n = 4, score = 200
            //   75f8                 | mov                 al, 1
            //   498bfb               | jmp                 6
            //   482bfb               | xor                 al, al
            //   498b4c2428           | cmp                 al, 1

        $sequence_20 = { 75f8 4c2bc0 488b4ef8 49ffc0 }
            // n = 4, score = 200
            //   75f8                 | dec                 ebp
            //   4c2bc0               | test                ebp, ebp
            //   488b4ef8             | jne                 0xd
            //   49ffc0               | dec                 eax

        $sequence_21 = { 75f8 492bfe ff15???????? ba08000000 }
            // n = 4, score = 200
            //   75f8                 | cmp                 al, 1
            //   492bfe               | jne                 6
            //   ff15????????         |                     
            //   ba08000000           | mov                 al, 1

        $sequence_22 = { 75f8 498bc7 4d85ff 7413 }
            // n = 4, score = 200
            //   75f8                 | mov                 al, 1
            //   498bc7               | jmp                 6
            //   4d85ff               | xor                 al, al
            //   7413                 | cmp                 al, 1

        $sequence_23 = { 75f8 492bfc 498bf5 4d85ed }
            // n = 4, score = 200
            //   75f8                 | mov                 al, 1
            //   492bfc               | jmp                 6
            //   498bf5               | xor                 al, al
            //   4d85ed               | cmp                 al, 1

        $sequence_24 = { 75f8 4c2bc1 49ffc0 33d2 }
            // n = 4, score = 200
            //   75f8                 | dec                 ecx
            //   4c2bc1               | mov                 eax, edi
            //   49ffc0               | dec                 ebp
            //   33d2                 | test                edi, edi

        $sequence_25 = { 75f8 4c2bc1 4803d7 498bcf }
            // n = 4, score = 200
            //   75f8                 | inc                 esp
            //   4c2bc1               | lea                 eax, [edx + 1]
            //   4803d7               | dec                 eax
            //   498bcf               | mov                 ecx, eax

    condition:
        7 of them and filesize < 729088
}