rule win_tofsee_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.tofsee."
        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.tofsee"
        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 = { ff75fc ffd7 85c0 0f84f2000000 0fb7859cfeffff 8b4dbc 56 }
            // n = 7, score = 400
            //   ff75fc               | push                dword ptr [ebp - 4]
            //   ffd7                 | call                edi
            //   85c0                 | test                eax, eax
            //   0f84f2000000         | je                  0xf8
            //   0fb7859cfeffff       | movzx               eax, word ptr [ebp - 0x164]
            //   8b4dbc               | mov                 ecx, dword ptr [ebp - 0x44]
            //   56                   | push                esi

        $sequence_1 = { 50 ff7570 e8???????? 59 59 ff7568 ff756c }
            // n = 7, score = 400
            //   50                   | push                eax
            //   ff7570               | push                dword ptr [ebp + 0x70]
            //   e8????????           |                     
            //   59                   | pop                 ecx
            //   59                   | pop                 ecx
            //   ff7568               | push                dword ptr [ebp + 0x68]
            //   ff756c               | push                dword ptr [ebp + 0x6c]

        $sequence_2 = { 8bce ff5004 8bf0 ff7608 ff15???????? 85c0 750d }
            // n = 7, score = 400
            //   8bce                 | mov                 ecx, esi
            //   ff5004               | call                dword ptr [eax + 4]
            //   8bf0                 | mov                 esi, eax
            //   ff7608               | push                dword ptr [esi + 8]
            //   ff15????????         |                     
            //   85c0                 | test                eax, eax
            //   750d                 | jne                 0xf

        $sequence_3 = { 53 50 ff7514 c60702 e8???????? 83c410 85c0 }
            // n = 7, score = 400
            //   53                   | push                ebx
            //   50                   | push                eax
            //   ff7514               | push                dword ptr [ebp + 0x14]
            //   c60702               | mov                 byte ptr [edi], 2
            //   e8????????           |                     
            //   83c410               | add                 esp, 0x10
            //   85c0                 | test                eax, eax

        $sequence_4 = { 57 6a07 33c9 8bc2 }
            // n = 4, score = 400
            //   57                   | push                edi
            //   6a07                 | push                7
            //   33c9                 | xor                 ecx, ecx
            //   8bc2                 | mov                 eax, edx

        $sequence_5 = { 6a00 6a00 ff7564 8d852cffffff 6880000000 50 e8???????? }
            // n = 7, score = 400
            //   6a00                 | push                0
            //   6a00                 | push                0
            //   ff7564               | push                dword ptr [ebp + 0x64]
            //   8d852cffffff         | lea                 eax, [ebp - 0xd4]
            //   6880000000           | push                0x80
            //   50                   | push                eax
            //   e8????????           |                     

        $sequence_6 = { 7443 8b5dfc 85db 7433 837d0c00 742d 57 }
            // n = 7, score = 400
            //   7443                 | je                  0x45
            //   8b5dfc               | mov                 ebx, dword ptr [ebp - 4]
            //   85db                 | test                ebx, ebx
            //   7433                 | je                  0x35
            //   837d0c00             | cmp                 dword ptr [ebp + 0xc], 0
            //   742d                 | je                  0x2f
            //   57                   | push                edi

        $sequence_7 = { 8bf7 741c 8b1e 53 ff742418 55 e8???????? }
            // n = 7, score = 400
            //   8bf7                 | mov                 esi, edi
            //   741c                 | je                  0x1e
            //   8b1e                 | mov                 ebx, dword ptr [esi]
            //   53                   | push                ebx
            //   ff742418             | push                dword ptr [esp + 0x18]
            //   55                   | push                ebp
            //   e8????????           |                     

        $sequence_8 = { 50 ff15???????? 8d4564 50 8d4550 50 ff15???????? }
            // n = 7, score = 400
            //   50                   | push                eax
            //   ff15????????         |                     
            //   8d4564               | lea                 eax, [ebp + 0x64]
            //   50                   | push                eax
            //   8d4550               | lea                 eax, [ebp + 0x50]
            //   50                   | push                eax
            //   ff15????????         |                     

        $sequence_9 = { e8???????? 80781000 75d4 56 8bcb e8???????? 837d0c03 }
            // n = 7, score = 400
            //   e8????????           |                     
            //   80781000             | cmp                 byte ptr [eax + 0x10], 0
            //   75d4                 | jne                 0xffffffd6
            //   56                   | push                esi
            //   8bcb                 | mov                 ecx, ebx
            //   e8????????           |                     
            //   837d0c03             | cmp                 dword ptr [ebp + 0xc], 3

    condition:
        7 of them and filesize < 147456
}