rule win_agfspy_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.agfspy."
        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.agfspy"
        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 = { e8???????? c645fc02 8b06 2b459c 8b7f18 d1f8 894594 }
            // n = 7, score = 400
            //   e8????????           |                     
            //   c645fc02             | mov                 byte ptr [ebp - 4], 2
            //   8b06                 | mov                 eax, dword ptr [esi]
            //   2b459c               | sub                 eax, dword ptr [ebp - 0x64]
            //   8b7f18               | mov                 edi, dword ptr [edi + 0x18]
            //   d1f8                 | sar                 eax, 1
            //   894594               | mov                 dword ptr [ebp - 0x6c], eax

        $sequence_1 = { 8955fc 8b4614 8b4e18 2500300000 894dc8 39561c 7f1b }
            // n = 7, score = 400
            //   8955fc               | mov                 dword ptr [ebp - 4], edx
            //   8b4614               | mov                 eax, dword ptr [esi + 0x14]
            //   8b4e18               | mov                 ecx, dword ptr [esi + 0x18]
            //   2500300000           | and                 eax, 0x3000
            //   894dc8               | mov                 dword ptr [ebp - 0x38], ecx
            //   39561c               | cmp                 dword ptr [esi + 0x1c], edx
            //   7f1b                 | jg                  0x1d

        $sequence_2 = { 85ff 7403 4f eb08 bf1f000000 83ee04 85db }
            // n = 7, score = 400
            //   85ff                 | test                edi, edi
            //   7403                 | je                  5
            //   4f                   | dec                 edi
            //   eb08                 | jmp                 0xa
            //   bf1f000000           | mov                 edi, 0x1f
            //   83ee04               | sub                 esi, 4
            //   85db                 | test                ebx, ebx

        $sequence_3 = { 8d45c0 0f4345c0 881408 c644080100 e9???????? b8ffffff7f 2bc1 }
            // n = 7, score = 400
            //   8d45c0               | lea                 eax, [ebp - 0x40]
            //   0f4345c0             | cmovae              eax, dword ptr [ebp - 0x40]
            //   881408               | mov                 byte ptr [eax + ecx], dl
            //   c644080100           | mov                 byte ptr [eax + ecx + 1], 0
            //   e9????????           |                     
            //   b8ffffff7f           | mov                 eax, 0x7fffffff
            //   2bc1                 | sub                 eax, ecx

        $sequence_4 = { 5b 8be5 5d c20800 83ec08 c6432801 }
            // n = 6, score = 400
            //   5b                   | pop                 ebx
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp
            //   c20800               | ret                 8
            //   83ec08               | sub                 esp, 8
            //   c6432801             | mov                 byte ptr [ebx + 0x28], 1

        $sequence_5 = { 7424 83f808 741f 83f80d 741a 83f802 75a8 }
            // n = 7, score = 400
            //   7424                 | je                  0x26
            //   83f808               | cmp                 eax, 8
            //   741f                 | je                  0x21
            //   83f80d               | cmp                 eax, 0xd
            //   741a                 | je                  0x1c
            //   83f802               | cmp                 eax, 2
            //   75a8                 | jne                 0xffffffaa

        $sequence_6 = { 6a20 e8???????? 8b4d08 0f57c0 83c404 89450c 0f1100 }
            // n = 7, score = 400
            //   6a20                 | push                0x20
            //   e8????????           |                     
            //   8b4d08               | mov                 ecx, dword ptr [ebp + 8]
            //   0f57c0               | xorps               xmm0, xmm0
            //   83c404               | add                 esp, 4
            //   89450c               | mov                 dword ptr [ebp + 0xc], eax
            //   0f1100               | movups              xmmword ptr [eax], xmm0

        $sequence_7 = { 837e4c5d 0f85a1000000 f7462c00010000 bb5d000000 740f 8b4630 53 }
            // n = 7, score = 400
            //   837e4c5d             | cmp                 dword ptr [esi + 0x4c], 0x5d
            //   0f85a1000000         | jne                 0xa7
            //   f7462c00010000       | test                dword ptr [esi + 0x2c], 0x100
            //   bb5d000000           | mov                 ebx, 0x5d
            //   740f                 | je                  0x11
            //   8b4630               | mov                 eax, dword ptr [esi + 0x30]
            //   53                   | push                ebx

        $sequence_8 = { 8be5 5d c20400 8b0e 85c9 7430 8b4608 }
            // n = 7, score = 400
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp
            //   c20400               | ret                 4
            //   8b0e                 | mov                 ecx, dword ptr [esi]
            //   85c9                 | test                ecx, ecx
            //   7430                 | je                  0x32
            //   8b4608               | mov                 eax, dword ptr [esi + 8]

        $sequence_9 = { 894a18 66a1???????? 6689421c a0???????? 88421e c6421f00 8b4dc8 }
            // n = 7, score = 400
            //   894a18               | mov                 dword ptr [edx + 0x18], ecx
            //   66a1????????         |                     
            //   6689421c             | mov                 word ptr [edx + 0x1c], ax
            //   a0????????           |                     
            //   88421e               | mov                 byte ptr [edx + 0x1e], al
            //   c6421f00             | mov                 byte ptr [edx + 0x1f], 0
            //   8b4dc8               | mov                 ecx, dword ptr [ebp - 0x38]

    condition:
        7 of them and filesize < 1482752
}