rule win_joanap_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.joanap."
        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.joanap"
        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 = { 83f8ff 740b 68e8030000 ff15???????? }
            // n = 4, score = 100
            //   83f8ff               | cmp                 eax, -1
            //   740b                 | je                  0xd
            //   68e8030000           | push                0x3e8
            //   ff15????????         |                     

        $sequence_1 = { 56 ffd7 85c0 a3???????? 7509 }
            // n = 5, score = 100
            //   56                   | push                esi
            //   ffd7                 | call                edi
            //   85c0                 | test                eax, eax
            //   a3????????           |                     
            //   7509                 | jne                 0xb

        $sequence_2 = { 8a4c241b 897c243c c1fb18 8a8900ba2c00 32cb 8bdf 884808 }
            // n = 7, score = 100
            //   8a4c241b             | mov                 cl, byte ptr [esp + 0x1b]
            //   897c243c             | mov                 dword ptr [esp + 0x3c], edi
            //   c1fb18               | sar                 ebx, 0x18
            //   8a8900ba2c00         | mov                 cl, byte ptr [ecx + 0x2cba00]
            //   32cb                 | xor                 cl, bl
            //   8bdf                 | mov                 ebx, edi
            //   884808               | mov                 byte ptr [eax + 8], cl

        $sequence_3 = { 83c404 40 894500 e9???????? }
            // n = 4, score = 100
            //   83c404               | add                 esp, 4
            //   40                   | inc                 eax
            //   894500               | mov                 dword ptr [ebp], eax
            //   e9????????           |                     

        $sequence_4 = { 5f 55 75a9 e8???????? }
            // n = 4, score = 100
            //   5f                   | pop                 edi
            //   55                   | push                ebp
            //   75a9                 | jne                 0xffffffab
            //   e8????????           |                     

        $sequence_5 = { 8b8c2404070000 64890d00000000 81c410070000 c3 8d54246b 52 56 }
            // n = 7, score = 100
            //   8b8c2404070000       | mov                 ecx, dword ptr [esp + 0x704]
            //   64890d00000000       | mov                 dword ptr fs:[0], ecx
            //   81c410070000         | add                 esp, 0x710
            //   c3                   | ret                 
            //   8d54246b             | lea                 edx, [esp + 0x6b]
            //   52                   | push                edx
            //   56                   | push                esi

        $sequence_6 = { 6800040000 68???????? 6a02 e8???????? 8b442420 83c41c 85c0 }
            // n = 7, score = 100
            //   6800040000           | push                0x400
            //   68????????           |                     
            //   6a02                 | push                2
            //   e8????????           |                     
            //   8b442420             | mov                 eax, dword ptr [esp + 0x20]
            //   83c41c               | add                 esp, 0x1c
            //   85c0                 | test                eax, eax

        $sequence_7 = { 897c2414 ff15???????? 8bf0 83feff }
            // n = 4, score = 100
            //   897c2414             | mov                 dword ptr [esp + 0x14], edi
            //   ff15????????         |                     
            //   8bf0                 | mov                 esi, eax
            //   83feff               | cmp                 esi, -1

        $sequence_8 = { c1fa18 8a8000b92c00 32c2 8b542430 8806 46 8d043a }
            // n = 7, score = 100
            //   c1fa18               | sar                 edx, 0x18
            //   8a8000b92c00         | mov                 al, byte ptr [eax + 0x2cb900]
            //   32c2                 | xor                 al, dl
            //   8b542430             | mov                 edx, dword ptr [esp + 0x30]
            //   8806                 | mov                 byte ptr [esi], al
            //   46                   | inc                 esi
            //   8d043a               | lea                 eax, [edx + edi]

        $sequence_9 = { 6a1e 57 55 e8???????? 8b5c2440 83c410 83f8ff }
            // n = 7, score = 100
            //   6a1e                 | push                0x1e
            //   57                   | push                edi
            //   55                   | push                ebp
            //   e8????????           |                     
            //   8b5c2440             | mov                 ebx, dword ptr [esp + 0x40]
            //   83c410               | add                 esp, 0x10
            //   83f8ff               | cmp                 eax, -1

    condition:
        7 of them and filesize < 270336
}