rule win_backswap_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.backswap."
        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.backswap"
        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 = { 3c2a 7508 8bdf 897508 }
            // n = 4, score = 400
            //   3c2a                 | cmp                 al, 0x2a
            //   7508                 | jne                 0xa
            //   8bdf                 | mov                 ebx, edi
            //   897508               | mov                 dword ptr [ebp + 8], esi

        $sequence_1 = { f366a5 59 5f 5e c9 }
            // n = 5, score = 400
            //   f366a5               | rep movsw           word ptr es:[edi], word ptr [esi]
            //   59                   | pop                 ecx
            //   5f                   | pop                 edi
            //   5e                   | pop                 esi
            //   c9                   | leave               

        $sequence_2 = { 7482 8b7508 ff4508 8bfb 3bd3 }
            // n = 5, score = 400
            //   7482                 | je                  0xffffff84
            //   8b7508               | mov                 esi, dword ptr [ebp + 8]
            //   ff4508               | inc                 dword ptr [ebp + 8]
            //   8bfb                 | mov                 edi, ebx
            //   3bd3                 | cmp                 edx, ebx

        $sequence_3 = { 33c9 33d2 8bdf 4b eb1c 85c9 }
            // n = 6, score = 400
            //   33c9                 | xor                 ecx, ecx
            //   33d2                 | xor                 edx, edx
            //   8bdf                 | mov                 ebx, edi
            //   4b                   | dec                 ebx
            //   eb1c                 | jmp                 0x1e
            //   85c9                 | test                ecx, ecx

        $sequence_4 = { 4b eb1c 85c9 7508 3bdf 7404 }
            // n = 6, score = 400
            //   4b                   | dec                 ebx
            //   eb1c                 | jmp                 0x1e
            //   85c9                 | test                ecx, ecx
            //   7508                 | jne                 0xa
            //   3bdf                 | cmp                 ebx, edi
            //   7404                 | je                  6

        $sequence_5 = { c9 c21000 83f0ff 5e 5f 5a }
            // n = 6, score = 400
            //   c9                   | leave               
            //   c21000               | ret                 0x10
            //   83f0ff               | xor                 eax, 0xffffffff
            //   5e                   | pop                 esi
            //   5f                   | pop                 edi
            //   5a                   | pop                 edx

        $sequence_6 = { e8???????? 74ed 33c0 eb04 8bc6 91 }
            // n = 6, score = 400
            //   e8????????           |                     
            //   74ed                 | je                  0xffffffef
            //   33c0                 | xor                 eax, eax
            //   eb04                 | jmp                 6
            //   8bc6                 | mov                 eax, esi
            //   91                   | xchg                eax, ecx

        $sequence_7 = { 7404 8bce 8bd3 397d14 0f8e99000000 39750c }
            // n = 6, score = 400
            //   7404                 | je                  6
            //   8bce                 | mov                 ecx, esi
            //   8bd3                 | mov                 edx, ebx
            //   397d14               | cmp                 dword ptr [ebp + 0x14], edi
            //   0f8e99000000         | jle                 0x9f
            //   39750c               | cmp                 dword ptr [ebp + 0xc], esi

        $sequence_8 = { 8bfb 3bd3 0f8572ffffff 33c9 }
            // n = 4, score = 400
            //   8bfb                 | mov                 edi, ebx
            //   3bd3                 | cmp                 edx, ebx
            //   0f8572ffffff         | jne                 0xffffff78
            //   33c9                 | xor                 ecx, ecx

        $sequence_9 = { 55 8bec 56 57 51 fc }
            // n = 6, score = 400
            //   55                   | push                ebp
            //   8bec                 | mov                 ebp, esp
            //   56                   | push                esi
            //   57                   | push                edi
            //   51                   | push                ecx
            //   fc                   | cld                 

    condition:
        7 of them and filesize < 122880
}