{"id":86293,"date":"2018-05-22T17:14:28","date_gmt":"2018-05-22T11:44:28","guid":{"rendered":"https:\/\/blogs_admin.quickheal.com\/?p=86293"},"modified":"2018-05-22T18:10:00","modified_gmt":"2018-05-22T12:40:00","slug":"cryptocurrency-mining-rampage-throttles-linux-machines","status":"publish","type":"post","link":"https:\/\/www.quickheal.com\/blogs\/cryptocurrency-mining-rampage-throttles-linux-machines\/","title":{"rendered":"Cryptocurrency mining rampage throttles Linux machines \u2013 an analysis by Quick Heal Security Labs"},"content":{"rendered":"<p>Quick Heal Security Labs recently came across a Linux-based Monero (XMR) miner. Monero (XMR) is one of the top 15 cryptocurrencies. It can be mined easily on any machine using its CPU computation power. This is one of the reasons why it is preferred to Bitcoin or Ethereum which are more famous than Monero. Earlier, we had also written about a <a href=\"https:\/\/blogs.quickheal.com\/mirus-cryptomining-virus\/\"><u>Windows-based cryptocurrency miner<\/u><\/a>. \u00a0In this blog post, we will dive into a detailed analysis of the Linux-based Monero miner.<\/p>\n<p><strong><b>Infection chain<\/b><\/strong><\/p>\n<p><strong><b>&#8216;c3.sh&#8217;<\/b><\/strong>\u00a0is a source file for this Monero mining campaign. Most probably, the script (c3.sh) might be injected in the targeted machine through SSH brute force attack.<\/p>\n<figure id=\"attachment_86304\" aria-describedby=\"caption-attachment-86304\" style=\"width: 662px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-86304\" src=\"https:\/\/blogs_admin.quickheal.com\/wp-content\/uploads\/2018\/05\/final_attackchain_edited-2.jpg\" alt=\"\" width=\"662\" height=\"616\" srcset=\"https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/final_attackchain_edited-2.jpg 662w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/final_attackchain_edited-2-300x279.jpg 300w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/final_attackchain_edited-2-419x390.jpg 419w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><figcaption id=\"caption-attachment-86304\" class=\"wp-caption-text\">Fig 1: Linux Monero miner infection chain<\/figcaption><\/figure>\n<p>Let\u2019s dive into the infection chain of Linux Monero miner.<\/p>\n<ul>\n<li>Shell scripts (<strong>c3.<b>sh<\/b><\/strong>) to deliver the Monero miner:<\/li>\n<\/ul>\n<figure id=\"attachment_86295\" aria-describedby=\"caption-attachment-86295\" style=\"width: 470px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-86295 size-full\" src=\"https:\/\/blogs_admin.quickheal.com\/wp-content\/uploads\/2018\/05\/c3-Copy.jpg\" alt=\"Fig 2: c3.sh script\" width=\"470\" height=\"347\" srcset=\"https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/c3-Copy.jpg 470w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/c3-Copy-300x221.jpg 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><figcaption id=\"caption-attachment-86295\" class=\"wp-caption-text\">Fig 2: c3.sh script<\/figcaption><\/figure>\n<p>As shown in fig 2, using the &#8216;<strong><b>nproc<\/b><\/strong>&#8216; command, &#8216;<strong><b>c3.sh&#8217;<\/b><\/strong>\u00a0Shell script checks for the number of CPU cores present in the user&#8217;s system. If it is less than or equal to 4, then the script will terminate otherwise it will perform the following tasks:<\/p>\n<ul>\n<li>Kill all processes related to Monero mining if already present on the user\u2019s system<\/li>\n<li>Download the Monero miner files (<strong><b>tar<\/b><\/strong>) from a remote location<\/li>\n<li>Unzip mine68b.tar and give permissions to all unzipped contents using the <strong><b>chmod <\/b><\/strong>command<\/li>\n<li>Execute script &#8216;x&#8217;<\/li>\n<\/ul>\n<p>After unzipping &#8216;<strong><b>mine68b.tar<\/b><\/strong>&#8216;, the following files are dropped:<\/p>\n<ul>\n<li><b><\/b><strong><b>x<\/b><\/strong>: Shell scripts<\/li>\n<li><b><\/b><strong><b>a<\/b><\/strong>: Shell script<\/li>\n<li><b><\/b><strong><b>run<\/b><\/strong>: Shell script<\/li>\n<li><b><\/b><strong><b>h32<\/b><\/strong>: Launcher of Monero miner for 32 bit system<\/li>\n<li><b><\/b><strong><b>h64<\/b><\/strong>: Launcher of Monero miner for 64 bit system<\/li>\n<li><b><\/b><strong><b>md<\/b><\/strong>: Monero Miner file<\/li>\n<li><b><\/b><strong><b>md32<\/b><\/strong>: Monero Miner file<\/li>\n<li><b><\/b><strong><b>mdx<\/b><\/strong>: Monero Miner file<\/li>\n<\/ul>\n<p>Let&#8217;s discuss the contents of <strong><b>mine68b.tar <\/b><\/strong>in detail.<\/p>\n<ul>\n<li>Script 1 &#8211; &#8216;<strong><b>x<\/b><\/strong>&#8216;:<\/li>\n<\/ul>\n<p>This one line shell script uses the &#8216;<strong><b>nohup<\/b><\/strong>&#8216; command to allow script &#8216;<strong><b>a<\/b><\/strong>&#8216; to continuously run in the background even after the user logs out or exit a shell.<\/p>\n<figure id=\"attachment_86297\" aria-describedby=\"caption-attachment-86297\" style=\"width: 279px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-86297\" src=\"https:\/\/blogs_admin.quickheal.com\/wp-content\/uploads\/2018\/05\/x-1.jpg\" alt=\"Fig 3: Use of nohup command to execute script 'a'\" width=\"279\" height=\"19\" \/><figcaption id=\"caption-attachment-86297\" class=\"wp-caption-text\">Fig 3: Use of nohup command to execute script &#8216;a&#8217;<\/figcaption><\/figure>\n<ul>\n<li>Script 2 &#8211; &#8216;<strong><b>a<\/b><\/strong>&#8216;:<\/li>\n<\/ul>\n<p>Creates a cron job to make the script persistent in the system.<\/p>\n<figure id=\"attachment_86298\" aria-describedby=\"caption-attachment-86298\" style=\"width: 519px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-86298\" src=\"https:\/\/blogs_admin.quickheal.com\/wp-content\/uploads\/2018\/05\/a.jpg\" alt=\"\" width=\"519\" height=\"249\" srcset=\"https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/a.jpg 519w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/a-300x144.jpg 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><figcaption id=\"caption-attachment-86298\" class=\"wp-caption-text\">Fig 4: Creation of cron job<\/figcaption><\/figure>\n<p>As shown in fig 4, script &#8216;a&#8217; is creating a <strong><b>cron <\/b><\/strong>job so that the script will be scheduled to run at regular intervals of time on the targeted computer. \u00a0After creating the cron job, it executes the &#8216;<strong><b>run<\/b><\/strong>&#8216; script.<\/p>\n<ul>\n<li>Script 3 &#8211; &#8216;<strong><b>run<\/b><\/strong>&#8216;:<\/li>\n<\/ul>\n<p>Launches Monero miner\u00a0 binaries<\/p>\n<figure id=\"attachment_86311\" aria-describedby=\"caption-attachment-86311\" style=\"width: 1207px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-86311 size-full\" src=\"https:\/\/blogs_admin.quickheal.com\/wp-content\/uploads\/2018\/05\/Run_Edit-4.jpg\" alt=\"\" width=\"1207\" height=\"376\" srcset=\"https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Run_Edit-4.jpg 1207w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Run_Edit-4-300x93.jpg 300w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Run_Edit-4-768x239.jpg 768w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Run_Edit-4-650x202.jpg 650w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Run_Edit-4-789x246.jpg 789w\" sizes=\"(max-width: 1207px) 100vw, 1207px\" \/><figcaption id=\"caption-attachment-86311\" class=\"wp-caption-text\">Fig 5: Execution of Monero miner file<\/figcaption><\/figure>\n<p>As shown in fig 5, this script first retrieves the system configuration in &#8216;ARCH&#8217; variable. Depending upon the value of &#8216;ARCH&#8217; variable, different miner files which are present in the current directory will get executed and start Monero mining process. Here &#8216;<strong><b>h32<\/b><\/strong>&#8216; and &#8216;<strong><b>h64<\/b><\/strong>&#8216; are launchers for Monero miner files. \u00a0Let&#8217;s look at few terms in this &#8216;<strong><b>run<\/b><\/strong>&#8216; script.<\/p>\n<p><strong><b>Cryptonight:<\/b><\/strong>\u00a0It is a proof-of-work algorithm. Currently, it is one of the suitable CPU based mining algorithms. Apart from Monero (XMR),<strong><b>\u00a0<\/b><\/strong>the<strong><b>\u00a0Cryptonight<\/b><\/strong>\u00a0algorithm can be used to mine other currencies like Bytecoin (BCN), Electroneum (ETN), etc. as well.<\/p>\n<p><strong><b>stratum+tcp: <\/b><\/strong>It\u2019s a cryptocurrency mining protocol.<\/p>\n<p><strong>Wallet Address : <\/strong>It\u2019s the wallet address wherein the Monero mining rewards will be transferred, thus its the Monero wallet address of the attacker.<\/p>\n<p>Thus the miner carries all the binaries with itself and executes the binary after identifying the system configuration.<\/p>\n<p><strong><b>Monero miner post-infection activity<\/b><\/strong><\/p>\n<p>On successful execution, the Monero miner generates the below post-infection traffic.<\/p>\n<figure id=\"attachment_86315\" aria-describedby=\"caption-attachment-86315\" style=\"width: 732px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-86315\" src=\"https:\/\/blogs_admin.quickheal.com\/wp-content\/uploads\/2018\/05\/User_Agent_Final-1.jpg\" alt=\"\" width=\"732\" height=\"143\" srcset=\"https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/User_Agent_Final-1.jpg 732w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/User_Agent_Final-1-300x59.jpg 300w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/User_Agent_Final-1-650x127.jpg 650w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><figcaption id=\"caption-attachment-86315\" class=\"wp-caption-text\">Fig 6. Post infection traffic of Monero Miner<\/figcaption><\/figure>\n<p>In fig 7, we see the mining activity in action. In this case, <strong><b>md32<\/b><\/strong>\u00a0miner has been executed and it\u2019s consuming 99.3% of CPU power to mine Monero (XMR) coin.<\/p>\n<figure id=\"attachment_86317\" aria-describedby=\"caption-attachment-86317\" style=\"width: 1239px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-86317 size-full\" src=\"https:\/\/blogs_admin.quickheal.com\/wp-content\/uploads\/2018\/05\/Mining_Activity_Latest2-1.jpg\" alt=\"\" width=\"1239\" height=\"640\" srcset=\"https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Mining_Activity_Latest2-1.jpg 1239w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Mining_Activity_Latest2-1-300x155.jpg 300w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Mining_Activity_Latest2-1-768x397.jpg 768w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Mining_Activity_Latest2-1-650x336.jpg 650w, https:\/\/www.quickheal.com\/blogs\/wp-content\/uploads\/2018\/05\/Mining_Activity_Latest2-1-789x408.jpg 789w\" sizes=\"(max-width: 1239px) 100vw, 1239px\" \/><figcaption id=\"caption-attachment-86317\" class=\"wp-caption-text\">Fig 7: Monero mining Activity<\/figcaption><\/figure>\n<p><strong>Safety Measures<\/strong><\/p>\n<ul>\n<li class=\"x_MsoListParagraph\">Disable SSH Protocol if not used.<\/li>\n<li>Always have strong username and password for SSH login.<\/li>\n<li>Set a lockout policy which hinders guessing of credentials.<\/li>\n<li>Use a VPN to access a network, instead of exposing SSH to the Internet.<\/li>\n<li>Configure your Firewall in the following ways:\n<ol>\n<li>Deny access to Public IPs to important ports<\/li>\n<li>Allow access to only IPs which are under your control<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p><strong><b>Conclusion<\/b><\/strong><\/p>\n<p>It is a myth that Linux is safe from malware and the fact is, attackers are well prepared to use Linux machines for mining. The market for cryptocurrencies is large and we can expect a rise in the attacks on Linux machines to mine cryptocurrencies.<\/p>\n<p><strong>Subject Matter Expert<\/strong><\/p>\n<p>Yogesh Bane, Quick Heal Security Labs<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick Heal Security Labs recently came across a Linux-based Monero (XMR) miner. Monero (XMR) is one of the top 15 cryptocurrencies. It can be mined easily on any machine using its CPU computation power. This is one of the reasons why it is preferred to Bitcoin or Ethereum which are more famous than Monero. Earlier, [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":86305,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,5],"tags":[1556,1053,49,1607,1533],"class_list":["post-86293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-malware","category-security","tag-cryptocurrency","tag-linux","tag-malware","tag-mining","tag-monero"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/posts\/86293"}],"collection":[{"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/comments?post=86293"}],"version-history":[{"count":8,"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/posts\/86293\/revisions"}],"predecessor-version":[{"id":86320,"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/posts\/86293\/revisions\/86320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/media\/86305"}],"wp:attachment":[{"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/media?parent=86293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/categories?post=86293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickheal.com\/blogs\/wp-json\/wp\/v2\/tags?post=86293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}