rule win_shujin_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.shujin."
        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.shujin"
        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 = { 83c444 33c0 c9 c3 55 }
            // n = 5, score = 100
            //   83c444               | add                 esp, 0x44
            //   33c0                 | xor                 eax, eax
            //   c9                   | leave               
            //   c3                   | ret                 
            //   55                   | push                ebp

        $sequence_1 = { 8144241404210000 8b50e8 3350fc 8b68ec 33ea 896804 8910 }
            // n = 7, score = 100
            //   8144241404210000     | add                 dword ptr [esp + 0x14], 0x2104
            //   8b50e8               | mov                 edx, dword ptr [eax - 0x18]
            //   3350fc               | xor                 edx, dword ptr [eax - 4]
            //   8b68ec               | mov                 ebp, dword ptr [eax - 0x14]
            //   33ea                 | xor                 ebp, edx
            //   896804               | mov                 dword ptr [eax + 4], ebp
            //   8910                 | mov                 dword ptr [eax], edx

        $sequence_2 = { c3 2d00100000 8500 ebe9 55 8bec 6a10 }
            // n = 7, score = 100
            //   c3                   | ret                 
            //   2d00100000           | sub                 eax, 0x1000
            //   8500                 | test                dword ptr [eax], eax
            //   ebe9                 | jmp                 0xffffffeb
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   6a10                 | push                0x10

        $sequence_3 = { 75c4 8b45fc 8b4df8 8918 }
            // n = 4, score = 100
            //   75c4                 | jne                 0xffffffc6
            //   8b45fc               | mov                 eax, dword ptr [ebp - 4]
            //   8b4df8               | mov                 ecx, dword ptr [ebp - 8]
            //   8918                 | mov                 dword ptr [eax], ebx

        $sequence_4 = { 0101 8b31 8975e4 115104 8b4104 83615000 83615400 }
            // n = 7, score = 100
            //   0101                 | add                 dword ptr [ecx], eax
            //   8b31                 | mov                 esi, dword ptr [ecx]
            //   8975e4               | mov                 dword ptr [ebp - 0x1c], esi
            //   115104               | adc                 dword ptr [ecx + 4], edx
            //   8b4104               | mov                 eax, dword ptr [ecx + 4]
            //   83615000             | and                 dword ptr [ecx + 0x50], 0
            //   83615400             | and                 dword ptr [ecx + 0x54], 0

        $sequence_5 = { 59 56 8bd8 ff15???????? 3bdf }
            // n = 5, score = 100
            //   59                   | pop                 ecx
            //   56                   | push                esi
            //   8bd8                 | mov                 ebx, eax
            //   ff15????????         |                     
            //   3bdf                 | cmp                 ebx, edi

        $sequence_6 = { e8???????? 6a05 8d8e74040000 e8???????? 8b45f8 8145f822010000 }
            // n = 6, score = 100
            //   e8????????           |                     
            //   6a05                 | push                5
            //   8d8e74040000         | lea                 ecx, [esi + 0x474]
            //   e8????????           |                     
            //   8b45f8               | mov                 eax, dword ptr [ebp - 8]
            //   8145f822010000       | add                 dword ptr [ebp - 8], 0x122

        $sequence_7 = { 8b7df8 c1ef08 c1eb10 23f8 8b3cbde89d4000 23d8 333c9de8994000 }
            // n = 7, score = 100
            //   8b7df8               | mov                 edi, dword ptr [ebp - 8]
            //   c1ef08               | shr                 edi, 8
            //   c1eb10               | shr                 ebx, 0x10
            //   23f8                 | and                 edi, eax
            //   8b3cbde89d4000       | mov                 edi, dword ptr [edi*4 + 0x409de8]
            //   23d8                 | and                 ebx, eax
            //   333c9de8994000       | xor                 edi, dword ptr [ebx*4 + 0x4099e8]

        $sequence_8 = { 68c5000000 ffb714040000 ffd3 8db7f4030000 e8???????? 8d85fcfeffff 50 }
            // n = 7, score = 100
            //   68c5000000           | push                0xc5
            //   ffb714040000         | push                dword ptr [edi + 0x414]
            //   ffd3                 | call                ebx
            //   8db7f4030000         | lea                 esi, [edi + 0x3f4]
            //   e8????????           |                     
            //   8d85fcfeffff         | lea                 eax, [ebp - 0x104]
            //   50                   | push                eax

        $sequence_9 = { 8d45a4 894558 8d850cffffff 83c418 }
            // n = 4, score = 100
            //   8d45a4               | lea                 eax, [ebp - 0x5c]
            //   894558               | mov                 dword ptr [ebp + 0x58], eax
            //   8d850cffffff         | lea                 eax, [ebp - 0xf4]
            //   83c418               | add                 esp, 0x18

    condition:
        7 of them and filesize < 172032
}