win.lokipws (Back to overview)

Loki Password Stealer (PWS)

aka: Loki, LokiPWS, LokiBot

Actor(s): SWEED, The Gorgon Group

URLhaus        

"Loki Bot is a commodity malware sold on underground sites which is designed to steal private data from infected machines, and then submit that info to a command and control host via HTTP POST. This private data includes stored passwords, login credential information from Web browsers, and a variety of cryptocurrency wallets." - PhishMe

Loki-Bot employs function hashing to obfuscate the libraries utilized. While not all functions are hashed, a vast majority of them are.

Loki-Bot accepts a single argument/switch of ‘-u’ that simply delays execution (sleeps) for 10 seconds. This is used when Loki-Bot is upgrading itself.

The Mutex generated is the result of MD5 hashing the Machine GUID and trimming to 24-characters. For example: “B7E1C2CC98066B250DDB2123“.

Loki-Bot creates a hidden folder within the %APPDATA% directory whose name is supplied by the 8th thru 13th characters of the Mutex. For example: “%APPDATA%\ C98066\”.

There can be four files within the hidden %APPDATA% directory at any given time: “.exe,” “.lck,” “.hdb” and “.kdb.” They will be named after characters 13 thru 18 of the Mutex. For example: “6B250D.” Below is the explanation of their purpose:

FILE EXTENSION FILE DESCRIPTION
.exe A copy of the malware that will execute every time the user account is logged into
.lck A lock file created when either decrypting Windows Credentials or Keylogging to prevent resource conflicts
.hdb A database of hashes for data that has already been exfiltrated to the C2 server
.kdb A database of keylogger data that has yet to be sent to the C2 server

If the user is privileged, Loki-Bot sets up persistence within the registry under HKEY_LOCAL_MACHINE. If not, it sets up persistence under HKEY_CURRENT_USER.

The first packet transmitted by Loki-Bot contains application data.

The second packet transmitted by Loki-Bot contains decrypted Windows credentials.

The third packet transmitted by Loki-Bot is the malware requesting C2 commands from the C2 server. By default, Loki-Bot will send this request out every 10 minutes after the initial packet it sent.

Communications to the C2 server from the compromised host contain information about the user and system including the username, hostname, domain, screen resolution, privilege level, system architecture, and Operating System.

The first WORD of the HTTP Payload represents the Loki-Bot version.

The second WORD of the HTTP Payload is the Payload Type. Below is the table of identified payload types:

BYTE PAYLOAD TYPE
0x26 Stolen Cryptocurrency Wallet
0x27 Stolen Application Data
0x28 Get C2 Commands from C2 Server
0x29 Stolen File
0x2A POS (Point of Sale?)
0x2B Keylogger Data
0x2C Screenshot

The 11th byte of the HTTP Payload begins the Binary ID. This might be useful in tracking campaigns or specific threat actors. This value value is typically “ckav.ru”. If you come across a Binary ID that is different from this, take note!

Loki-Bot encrypts both the URL and the registry key used for persistence using Triple DES encryption.

The Content-Key HTTP Header value is the result of hashing the HTTP Header values that precede it. This is likely used as a protection against researchers who wish to poke and prod at Loki-Bot’s C2 infrastructure.

Loki-Bot can accept the following instructions from the C2 Server:

BYTE INSTRUCTION DESCRIPTION
0x00 Download EXE & Execute
0x01 Download DLL & Load #1
0x02 Download DLL & Load #2
0x08 Delete HDB File
0x09 Start Keylogger
0x0A Mine & Steal Data
0x0E Exit Loki-Bot
0x0F Upgrade Loki-Bot
0x10 Change C2 Polling Frequency
0x11 Delete Executables & Exit

Suricata Signatures
RULE SID RULE NAME
2024311 ET TROJAN Loki Bot Cryptocurrency Wallet Exfiltration Detected
2024312 ET TROJAN Loki Bot Application/Credential Data Exfiltration Detected M1
2024313 ET TROJAN Loki Bot Request for C2 Commands Detected M1
2024314 ET TROJAN Loki Bot File Exfiltration Detected
2024315 ET TROJAN Loki Bot Keylogger Data Exfiltration Detected M1
2024316 ET TROJAN Loki Bot Screenshot Exfiltration Detected
2024317 ET TROJAN Loki Bot Application/Credential Data Exfiltration Detected M2
2024318 ET TROJAN Loki Bot Request for C2 Commands Detected M2
2024319 ET TROJAN Loki Bot Keylogger Data Exfiltration Detected M2

References
http://blog.fernandodominguez.me/lokis-antis-analysis/
http://www.malware-traffic-analysis.net/2017/06/12/index.html
https://blog.fortinet.com/2017/05/17/new-loki-variant-being-spread-via-pdf-file
https://blog.talosintelligence.com/2019/07/sweed-agent-tesla.html
https://cysinfo.com/nefarious-macro-malware-drops-loki-bot-across-gcc-countries/
https://github.com/R3MRUM/loki-parse
https://github.com/d00rt/hijacked_lokibot_version/blob/master/doc/LokiBot_hijacked_2018.pdf
https://isc.sans.edu/diary/24372
https://marcoramilli.com/2019/10/28/sweed-targeting-precision-engineering-companies-in-italy/
https://phishme.com/loki-bot-malware/
https://r3mrum.wordpress.com/2017/05/07/loki-bot-atrifacts/
https://researchcenter.paloaltonetworks.com/2018/08/unit42-gorgon-group-slithering-nation-state-cybercrime/
https://securelist.com/loki-bot-stealing-corporate-passwords/87595/
https://www.lastline.com/blog/password-stealing-malware-loki-bot/
https://www.sans.org/reading-room/whitepapers/malicious/loki-bot-information-stealer-keylogger-more-37850
Yara Rules
[TLP:WHITE] win_lokipws_auto (20190620 | autogenerated rule brought to you by yara-signator)
rule win_lokipws_auto {

    meta:
        author = "Felix Bilstein - yara-signator at cocacoding dot com"
        date = "2019-07-05"
        version = "1"
        description = "autogenerated rule brought to you by yara-signator"
        tool = "yara-signator 0.2a"
        malpedia_reference = "https://malpedia.caad.fkie.fraunhofer.de/details/win.lokipws"
        malpedia_version = "20190620"
        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 / approach 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 = { 99 52 50 ff75e0 ff75dc 53 e8???????? }
            // n = 7, score = 200
            //   99                   | cdq                 
            //   52                   | push                edx
            //   50                   | push                eax
            //   ff75e0               | push                dword ptr [ebp - 0x20]
            //   ff75dc               | push                dword ptr [ebp - 0x24]
            //   53                   | push                ebx
            //   e8????????           |                     

        $sequence_1 = { ffd0 85c0 0f8????????? 53 e8???????? 59 56 }
            // n = 7, score = 200
            //   ffd0                 | call                eax
            //   85c0                 | test                eax, eax
            //   0f8?????????         |                     
            //   53                   | push                ebx
            //   e8????????           |                     
            //   59                   | pop                 ecx
            //   56                   | push                esi

        $sequence_2 = { bb090d4100 bfa8874100 53 6a00 6a02 57 6a01 }
            // n = 7, score = 200
            //   bb090d4100           | mov                 ebx, 0x410d09
            //   bfa8874100           | mov                 edi, 0x4187a8
            //   53                   | push                ebx
            //   6a00                 | push                0
            //   6a02                 | push                2
            //   57                   | push                edi
            //   6a01                 | push                1

        $sequence_3 = { 668985bafeffff ab 6a43 ab 66ab 58 }
            // n = 6, score = 200
            //   668985bafeffff       | mov                 word ptr [ebp - 0x146], ax
            //   ab                   | stosd               dword ptr es:[edi], eax
            //   6a43                 | push                0x43
            //   ab                   | stosd               dword ptr es:[edi], eax
            //   66ab                 | stosw               word ptr es:[edi], ax
            //   58                   | pop                 eax

        $sequence_4 = { 6a0d 59 50 66a5 be98504100 8d7d90 f3a5 }
            // n = 7, score = 200
            //   6a0d                 | push                0xd
            //   59                   | pop                 ecx
            //   50                   | push                eax
            //   66a5                 | movsw               word ptr es:[edi], word ptr [esi]
            //   be98504100           | mov                 esi, 0x415098
            //   8d7d90               | lea                 edi, [ebp - 0x70]
            //   f3a5                 | rep movsd           dword ptr es:[edi], dword ptr [esi]

        $sequence_5 = { 74?? 85ff 74?? 57 e8???????? 8bf0 59 }
            // n = 7, score = 200
            //   74??                 |                     
            //   85ff                 | test                edi, edi
            //   74??                 |                     
            //   57                   | push                edi
            //   e8????????           |                     
            //   8bf0                 | mov                 esi, eax
            //   59                   | pop                 ecx

        $sequence_6 = { e8???????? 68b80b0000 e8???????? 56 e8???????? 83c418 85c0 }
            // n = 7, score = 200
            //   e8????????           |                     
            //   68b80b0000           | push                0xbb8
            //   e8????????           |                     
            //   56                   | push                esi
            //   e8????????           |                     
            //   83c418               | add                 esp, 0x18
            //   85c0                 | test                eax, eax

        $sequence_7 = { 85c0 0f8????????? 395df8 0f8????????? 8d45d8 50 ff15???????? }
            // n = 7, score = 200
            //   85c0                 | test                eax, eax
            //   0f8?????????         |                     
            //   395df8               | cmp                 dword ptr [ebp - 8], ebx
            //   0f8?????????         |                     
            //   8d45d8               | lea                 eax, [ebp - 0x28]
            //   50                   | push                eax
            //   ff15????????         |                     

        $sequence_8 = { 57 50 893d???????? 893d???????? 893d???????? e8???????? 83c40c }
            // n = 7, score = 200
            //   57                   | push                edi
            //   50                   | push                eax
            //   893d????????         |                     
            //   893d????????         |                     
            //   893d????????         |                     
            //   e8????????           |                     
            //   83c40c               | add                 esp, 0xc

        $sequence_9 = { 66894dea 66894df6 66894dfa e8???????? 83c418 8be5 5d }
            // n = 7, score = 200
            //   66894dea             | mov                 word ptr [ebp - 0x16], cx
            //   66894df6             | mov                 word ptr [ebp - 0xa], cx
            //   66894dfa             | mov                 word ptr [ebp - 6], cx
            //   e8????????           |                     
            //   83c418               | add                 esp, 0x18
            //   8be5                 | mov                 esp, ebp
            //   5d                   | pop                 ebp

    condition:
        7 of them
}
Download all Yara Rules