KandyKorn
- Type
- RAT
- Capabilities
- ReconnaissanceExfiltrationPersistenceDefense evasion
- Delivery
- SpearphishingLure
- Platforms
- macOS
KANDYKORN is a C++ memory-resident remote-access trojan targeting macOS, associated with North Korean threat activity linked to the Lazarus Group. Observed activity dates to at least April 2023 and targeted blockchain engineers at a cryptocurrency exchange. Its functionality provides operators with extensive remote control, reconnaissance, and data-exfiltration capabilities.
The documented infection chain began with attackers impersonating blockchain-community members on Discord and persuading a target to execute a malicious Python application presented as a cryptocurrency-arbitrage bot. Successive Python stages deployed SUGARLOADER, which retrieved and reflectively loaded KANDYKORN into memory. The chain used HLOADER, a Swift component that hijacked the legitimate Discord application's execution flow, to maintain access while preserving normal application behavior.
KANDYKORN runs as a background daemon and communicates with command-and-control infrastructure using RC4-encrypted traffic and a custom challenge-response handshake. It uses an encrypted configuration and a victim-specific identifier. Supported operations include gathering host information, enumerating processes and directories, calculating recursive file statistics, uploading and downloading files, archiving and exfiltrating directories, securely deleting files, terminating processes, executing arbitrary commands, and opening interactive pseudoterminal shells. Operators can also retrieve or replace its configuration and specify sleep intervals. Reflective loading limits the final payload's on-disk footprint, while the surrounding loader chain supplies persistence and additional evasion.
Associated threat actors
3 distinct threat actors Mallory has associated with this family across public reporting. Open in Mallory to see the full evidence chain and overlapping campaigns.
The engineer was targeted via a targeted social engineering engagement involving a fraudulent developer recruitment evaluation that delivered an obfuscated, memory-resident backdoor related to the RustBucket and KandyKorn malware lineages.
The engineer was targeted via a targeted social engineering engagement involving a fraudulent developer recruitment evaluation that delivered an obfuscated, memory-resident backdoor related to the RustBucket and KandyKorn malware lineages.
Given this execution flow and SugarLoader’s historical role in retrieving the KANDYKORN malware, it is likely that the final payload in the chain would be KANDYKORN or another fully-featured backdoor.
Techniques & procedures
28 distinct techniques documented for this family, organized by ATT&CK tactic.
Initial Access
2 techniques
Initial Access
By leveraging social media platforms like Discord with enticing lures, these actors are finding new paths into highly targeted environments.
Further analysis revealed that the intrusion began with a Python application disguised as a cryptocurrency arbitrage bot, which was distributed through a direct message on a public Discord server.
Execution
5 techniques
Execution
resp_cmd_create spawns a shell on the system and communicates with it via a pseudoterminal.
Python scripts were used to drop malware that hijacked the host’s installed Discord app... Watcher.py checks the local Python version and downloads and executes testSpeed.py. The script downloads and executes another Python script, FinderTools.
SUGARLOADER uses this to retrieve and execute the KANDYKORN remote access trojan in-memory via NSCreateObjectFileImageFromMemory and NSLinkModule.
A Discord user is socially engineered into downloading a malicious Python application, Cross-Platform Bridges.zip.
SUGARLOADER also downloads a Mach-O payload dubbed HLOADER and writes it to /Applications/Discord.app/Contents/MacOS/Discord. The genuine Discord executable is renamed as .lock in the same directory.
Persistence
2 techniques
Persistence
In the previous post, we analyzed how LaunchAgents work... LaunchAgents are great, but they have a flaw: macOS likes to scream about them with a “Background Items Added” notification... While their primary persistence was a LaunchAgent, they used shell configuration hijacking as a failsafe.
Today, I’ll talk about shell environment hijacking trick... The two most interesting files for us are: ~/.zshrc - executed for interactive shells... ~/.zshenv - executed for every instance of zsh... So, the main trick: we append a command to run our malware at the end of these files.
Privilege Escalation
2 techniques
Privilege Escalation
In the previous post, we analyzed how LaunchAgents work... LaunchAgents are great, but they have a flaw: macOS likes to scream about them with a “Background Items Added” notification... While their primary persistence was a LaunchAgent, they used shell configuration hijacking as a failsafe.
Today, I’ll talk about shell environment hijacking trick... The two most interesting files for us are: ~/.zshrc - executed for interactive shells... ~/.zshenv - executed for every instance of zsh... So, the main trick: we append a command to run our malware at the end of these files.
Stealth
6 techniques
Stealth
The victim believed they were installing an arbitrage bot, a software tool designed to profit from cryptocurrency rate differences between platforms.
Watcher.py deletes the testSpeed.py immediately following its execution... resp_file_wipe overwrites file content to zero and deletes the file.
When the breakpoint is hit, the code will already be decrypted in memory... The configuration file is encrypted using RC4... read into memory and decrypted.
When the malware first connects to the C2 server during the initialization phase, a handshake must be validated to proceed.
SUGARLOADER also downloads a Mach-O payload dubbed HLOADER and writes it to /Applications/Discord.app/Contents/MacOS/Discord. The genuine Discord executable is renamed as .lock in the same directory.
SUGARLOADER... download[s] a final stage payload... and execute[s] it directly in memory... leveraging APIs such as NSCreateObjectFileImageFromMemory or NSLinkModule.
Discovery
4 techniques
Discovery
resp_proc_list lists all running processes on the system along with their PID, UID and other information.
resp_basicinfo gathers information about the system such as hostname, uid, osinfo, and image path of the current process.
resp_file_dir lists content of a directory... resp_file_prop recursively read[s] a directory and count[s]... files, subdirectories, and total size.
When the malware first connects to the C2 server during the initialization phase, a handshake must be validated to proceed.
Lateral Movement
1 technique
Lateral Movement
resp_cmd_create Spawns a shell on the system and communicates with it via a pseudoterminal.
Collection
3 techniques
Collection
The newly created archive's name has the following pattern /tmp/tempXXXXXXX.
resp_file_zipdown Archives a directory and exfiltrates it to the C2 server.
resp_file_zipdown archive[s] a directory and exfiltrate[s] it to the C2 server.
Command and Control
6 techniques
Command and Control
It supports two C2 servers, one as the main server, and the second one as a fallback.
Operating covertly, KANDYKORN employs a feature-rich multi-staged loader paired with a custom network protocol to facilitate a range of post-compromise activities.
Watcher.py... fetches content from [a] Google Drive URL... written into the testSpeed.py file. testSpeed.py... fetches another Python file... FinderTools... downloading and executing... .sld.
The main feature of CosmicDoor is that it communicates with the C2 server using the WSS protocol, and it provides remote control functionality such as receiving and executing commands... SneakMain... receives additional AppleScript commands and uses the osascript -e command to execute them.
Both KANDYKORN and SUGARLOADER use the RC4 algorithm to encrypt their communications.
All the data is encrypted with RC4 and uses the same key previously referenced in the configuration file.
Exfiltration
1 technique
Exfiltration
resp_file_down [is] used by the adversary to transfer a file from the victim's computer to their infrastructure.
Observables
27 indicators attributed across vendor reports, sandbox runs, and researcher write-ups. Values are masked here and available in full in Mallory.
Recent activity
13 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.