rule win_koobface_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.koobface."
        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.koobface"
        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 = { 3b45e4 72cf 8b4db0 8d45d4 50 e8???????? 6aff }
            // n = 7, score = 100
            //   3b45e4               | cmp                 eax, dword ptr [ebp - 0x1c]
            //   72cf                 | jb                  0xffffffd1
            //   8b4db0               | mov                 ecx, dword ptr [ebp - 0x50]
            //   8d45d4               | lea                 eax, [ebp - 0x2c]
            //   50                   | push                eax
            //   e8????????           |                     
            //   6aff                 | push                -1

        $sequence_1 = { 68???????? 57 ffb608040000 8bce e8???????? 53 53 }
            // n = 7, score = 100
            //   68????????           |                     
            //   57                   | push                edi
            //   ffb608040000         | push                dword ptr [esi + 0x408]
            //   8bce                 | mov                 ecx, esi
            //   e8????????           |                     
            //   53                   | push                ebx
            //   53                   | push                ebx

        $sequence_2 = { 8b4510 832000 33c0 40 5d c20c00 55 }
            // n = 7, score = 100
            //   8b4510               | mov                 eax, dword ptr [ebp + 0x10]
            //   832000               | and                 dword ptr [eax], 0
            //   33c0                 | xor                 eax, eax
            //   40                   | inc                 eax
            //   5d                   | pop                 ebp
            //   c20c00               | ret                 0xc
            //   55                   | push                ebp

        $sequence_3 = { 57 e8???????? 59 50 57 8d8ee0000000 }
            // n = 6, score = 100
            //   57                   | push                edi
            //   e8????????           |                     
            //   59                   | pop                 ecx
            //   50                   | push                eax
            //   57                   | push                edi
            //   8d8ee0000000         | lea                 ecx, [esi + 0xe0]

        $sequence_4 = { 50 e8???????? 399de4f7ffff 0f848a010000 899df4f7ffff 8b85e4f7ffff }
            // n = 6, score = 100
            //   50                   | push                eax
            //   e8????????           |                     
            //   399de4f7ffff         | cmp                 dword ptr [ebp - 0x81c], ebx
            //   0f848a010000         | je                  0x190
            //   899df4f7ffff         | mov                 dword ptr [ebp - 0x80c], ebx
            //   8b85e4f7ffff         | mov                 eax, dword ptr [ebp - 0x81c]

        $sequence_5 = { 897de8 8b4508 8b08 8d55e8 52 50 897dfc }
            // n = 7, score = 100
            //   897de8               | mov                 dword ptr [ebp - 0x18], edi
            //   8b4508               | mov                 eax, dword ptr [ebp + 8]
            //   8b08                 | mov                 ecx, dword ptr [eax]
            //   8d55e8               | lea                 edx, [ebp - 0x18]
            //   52                   | push                edx
            //   50                   | push                eax
            //   897dfc               | mov                 dword ptr [ebp - 4], edi

        $sequence_6 = { e8???????? b8???????? e9???????? 8d8d20f4ffff e9???????? 8d8d1cf4ffff e9???????? }
            // n = 7, score = 100
            //   e8????????           |                     
            //   b8????????           |                     
            //   e9????????           |                     
            //   8d8d20f4ffff         | lea                 ecx, [ebp - 0xbe0]
            //   e9????????           |                     
            //   8d8d1cf4ffff         | lea                 ecx, [ebp - 0xbe4]
            //   e9????????           |                     

        $sequence_7 = { e8???????? 8d8528ffffff 50 8d8d10feffff e8???????? 8b8dd0fdffff 8d8510feffff }
            // n = 7, score = 100
            //   e8????????           |                     
            //   8d8528ffffff         | lea                 eax, [ebp - 0xd8]
            //   50                   | push                eax
            //   8d8d10feffff         | lea                 ecx, [ebp - 0x1f0]
            //   e8????????           |                     
            //   8b8dd0fdffff         | mov                 ecx, dword ptr [ebp - 0x230]
            //   8d8510feffff         | lea                 eax, [ebp - 0x1f0]

        $sequence_8 = { 0fb78538c1ffff 50 ffb534c1ffff 8d85f0e8ffff ffb530c1ffff 68???????? }
            // n = 6, score = 100
            //   0fb78538c1ffff       | movzx               eax, word ptr [ebp - 0x3ec8]
            //   50                   | push                eax
            //   ffb534c1ffff         | push                dword ptr [ebp - 0x3ecc]
            //   8d85f0e8ffff         | lea                 eax, [ebp - 0x1710]
            //   ffb530c1ffff         | push                dword ptr [ebp - 0x3ed0]
            //   68????????           |                     

        $sequence_9 = { 7427 50 ffb608040000 8bce e8???????? 68d0070000 }
            // n = 6, score = 100
            //   7427                 | je                  0x29
            //   50                   | push                eax
            //   ffb608040000         | push                dword ptr [esi + 0x408]
            //   8bce                 | mov                 ecx, esi
            //   e8????????           |                     
            //   68d0070000           | push                0x7d0

    condition:
        7 of them and filesize < 368640
}