rule win_secondhandtea_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2026-09-17"
        version = "1"
        description = "Detects win.secondhandtea."
        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.secondhandtea"
        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 = { c3 8b8374060000 238370060000 a802 7413 488bcb e8???????? }
            // n = 7, score = 100
            //   c3                   | dec                 eax
            //   8b8374060000         | mov                 dword ptr [esi + 0x10], ecx
            //   238370060000         | dec                 eax
            //   a802                 | mov                 eax, dword ptr [ebp]
            //   7413                 | dec                 eax
            //   488bcb               | mov                 dword ptr [eax + 0x6a0], ebp
            //   e8????????           |                     

        $sequence_1 = { e9???????? 39b7f0030000 7505 4885c9 7471 3d91010000 740f }
            // n = 7, score = 100
            //   e9????????           |                     
            //   39b7f0030000         | mov                 ecx, eax
            //   7505                 | dec                 eax
            //   4885c9               | mov                 dword ptr [ebx + 0x20], eax
            //   7471                 | dec                 eax
            //   3d91010000           | test                eax, eax
            //   740f                 | jne                 0x1613

        $sequence_2 = { b820000000 e8???????? 482be0 8b4110 48897c2430 488bd9 8bf8 }
            // n = 7, score = 100
            //   b820000000           | dec                 ebx
            //   e8????????           |                     
            //   482be0               | lea                 eax, [ebp + ecx]
            //   8b4110               | dec                 esp
            //   48897c2430           | mov                 ecx, dword ptr [esp + 0x50]
            //   488bd9               | dec                 esp
            //   8bf8                 | add                 ecx, eax

        $sequence_3 = { 8b4524 29454c 8b4528 8b5d08 294550 8b7d0c 8b7510 }
            // n = 7, score = 100
            //   8b4524               | je                  0x103e
            //   29454c               | dec                 eax
            //   8b4528               | test                eax, eax
            //   8b5d08               | je                  0x1054
            //   294550               | dec                 ecx
            //   8b7d0c               | mov                 edx, dword ptr [esp + 0x68]
            //   8b7510               | dec                 ebp

        $sequence_4 = { c3 488d1563290e00 41b881080000 b930000000 4c89642468 e8???????? 4c8be0 }
            // n = 7, score = 100
            //   c3                   | inc                 ecx
            //   488d1563290e00       | add                 eax, esp
            //   41b881080000         | dec                 ebp
            //   b930000000           | arpl                bp, ax
            //   4c89642468           | dec                 esp
            //   e8????????           |                     
            //   4c8be0               | mov                 dword ptr [ebp - 0x80], eax

        $sequence_5 = { c744242051000000 8d4a9b 448d42fb e8???????? e9???????? bf01000000 498bce }
            // n = 7, score = 100
            //   c744242051000000     | dec                 eax
            //   8d4a9b               | mov                 esi, ecx
            //   448d42fb             | dec                 eax
            //   e8????????           |                     
            //   e9????????           |                     
            //   bf01000000           | mov                 dword ptr [esp + 0x60], edx
            //   498bce               | cmp                 dword ptr [edi + 0xa08], 0

        $sequence_6 = { 8b7dfb 4433c1 8b4c2414 41c1c808 4503c8 4133c1 44894c2420 }
            // n = 7, score = 100
            //   8b7dfb               | test                edi, edi
            //   4433c1               | je                  0x49b
            //   8b4c2414             | dec                 eax
            //   41c1c808             | mov                 dword ptr [edi], 0xe
            //   4503c8               | dec                 esp
            //   4133c1               | mov                 ebx, eax
            //   44894c2420           | jmp                 0x4ad

        $sequence_7 = { e8???????? 0fb7f8 4103f9 8bcf 483bd9 0f823b010000 4c896c2428 }
            // n = 7, score = 100
            //   e8????????           |                     
            //   0fb7f8               | mov                 ebp, ebx
            //   4103f9               | dec                 esp
            //   8bcf                 | mov                 dword ptr [esp + 0x40], esp
            //   483bd9               | dec                 eax
            //   0f823b010000         | mov                 dword ptr [esp + 0x38], eax
            //   4c896c2428           | dec                 eax

        $sequence_8 = { c6400903 488b443e08 c740580000ff41 488b443e08 830810 488b5c2430 488b742438 }
            // n = 7, score = 100
            //   c6400903             | dec                 esp
            //   488b443e08           | mov                 ebx, dword ptr [esp + 0x80]
            //   c740580000ff41       | dec                 esp
            //   488b443e08           | mov                 esi, dword ptr [esp + 0xa0]
            //   830810               | dec                 eax
            //   488b5c2430           | mov                 dword ptr [esp + 0xc0], esi
            //   488b742438           | dec                 eax

        $sequence_9 = { 8d4828 41b831060000 e8???????? 4885c0 753b 8b05???????? 85c0 }
            // n = 7, score = 100
            //   8d4828               | dec                 eax
            //   41b831060000         | lea                 edx, [0x75b56]
            //   e8????????           |                     
            //   4885c0               | dec                 eax
            //   753b                 | mov                 ecx, ebx
            //   8b05????????         |                     
            //   85c0                 | dec                 eax

    condition:
        7 of them and filesize < 4452352
}