{"id":1144,"date":"2021-12-14T13:58:12","date_gmt":"2021-12-14T12:58:12","guid":{"rendered":"https:\/\/lab52.io\/blog\/?p=1144"},"modified":"2021-12-14T14:10:18","modified_gmt":"2021-12-14T13:10:18","slug":"cuba-ransomware-analysis","status":"publish","type":"post","link":"https:\/\/lab52.io\/blog\/cuba-ransomware-analysis\/","title":{"rendered":"Cuba Ransomware Analysis"},"content":{"rendered":"\n<p>Due to the recent warning published by the FBI <a href=\"https:\/\/threatpost.com\/cuba-ransomware-gang-44m-payouts\/176790\/\">about Cuba ransomware<\/a> (original FBI warning no longer available online for unknown reasons), from Lab52 we decided to publish some information about this ransomware family. Despite the fact that the ransomware has been named Cuba, there is no clear evidence linking the country to the implementation or perpetration of this type of attacks.<\/p>\n\n\n\n<p>Nonetheless, the geopolitical analysis has revealed a few details of strategic interest. Firstly, the fact that most of the countries attacked, according to a<a href=\"https:\/\/www.mcafee.com\/enterprise\/en-us\/assets\/reports\/rp-cuba-ransomware.pdf\"> McAfee report<\/a>, correspond to those located in Latin America, North America and Europe. Of these, the most targeted were: Spain, Colombia and Germany. However, when looking at the possible link between the countries attacked and the sectors compromised, it has not been possible to identify a clear interest in the attack, since although Colombia is a US ally in Latin America and a NATO observer state, and Spain is a member of the European Union and NATO with a good geostrategic position, none of them stand out among the critical sectors that have been attacked.<\/p>\n\n\n\n<p>Secondly, it has also been observed that the profile of the countries attacked is common to apt groups that share certain ideological lines, which may be contrary to those of the countries that have been targeted. However, this has not yet allowed us to identify the link between this ransomware and any specific country or APT group.<\/p>\n\n\n\n<p>For this post, we have analyzed a recent public sample, which has a compiler timestamp dated from August 23rd, 2021:<\/p>\n\n\n\n<p>936119bc1811aeef01299a0150141787865a0dbe2667288f018ad24db5a7bc27<\/p>\n\n\n\n<p>In this sample, we have observed some changes from the version <a href=\"https:\/\/www.mcafee.com\/enterprise\/en-us\/assets\/reports\/rp-cuba-ransomware.pdf\">described by McAfee in April 2021<\/a>, which is the only and most recent published analysis about this ransomware family.<\/p>\n\n\n\n<p>Firstly, the process retrieves the Input Locale identifiers (formerly called Keyboard Layout Handles) corresponding to the current set of input languages in the infected system. In case of finding the Russian language identifier (0x19) among the obtained list, the process terminates. Otherwise, it starts with its main activity.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"762\" height=\"652\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image.png\" alt=\"\" class=\"wp-image-1145\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image.png 762w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-300x257.png 300w\" sizes=\"(max-width: 762px) 100vw, 762px\" \/><figcaption>Main function of the Cuba Ransomware sample<\/figcaption><\/figure><\/div>\n\n\n\n<p>Since the program accepts one argument, the main activity will start by parsing the given argument, looking for either &#8220;network&#8221;, some IP address, &#8220;local&#8221; or a specific path to encrypt. Thus, the usage of this sample by an operator would be as follows:<\/p>\n\n\n\n<p>cuba.exe [ network | [IP_addr] | local | [specific_path] ]<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"908\" height=\"680\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-3.png\" alt=\"\" class=\"wp-image-1148\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-3.png 908w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-3-300x225.png 300w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-3-768x575.png 768w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><figcaption>Principal function of Cuba Ransomware<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"812\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-4-1024x812.png\" alt=\"\" class=\"wp-image-1149\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-4-1024x812.png 1024w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-4-300x238.png 300w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-4-768x609.png 768w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-4.png 1159w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Flow diagram of the Cuba Ransomware sample<\/figcaption><\/figure><\/div>\n\n\n\n<p>According to this, we could distinguish between two network modes and two local modes. The network mode triggered by the &#8220;network&#8221; argument will call the windows API GetIPNetTable in order to obtain the ARP table and call NetShareEnum using each IP as the serverName parameter for this second API call. In the case of specifying an IP address, it will just enumerate the shares of that specific address.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1012\" height=\"644\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-5.png\" alt=\"\" class=\"wp-image-1150\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-5.png 1012w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-5-300x191.png 300w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-5-768x489.png 768w\" sizes=\"(max-width: 1012px) 100vw, 1012px\" \/><figcaption>Pseudocode of the &#8220;network&#8221; argument function calls<\/figcaption><\/figure><\/div>\n\n\n\n<p>The default (no argument given) or &#8220;local&#8221; argument mode will enumerate the volumes by their Device IDs in the system. If a path is specified as the argument, the ransomware will only encrypt that specified path.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"542\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-6.png\" alt=\"\" class=\"wp-image-1151\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-6.png 644w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-6-300x252.png 300w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><figcaption>Pseudocode of the default &#8220;local&#8221; mode<\/figcaption><\/figure><\/div>\n\n\n\n<p>Depending on the case there will be between 2 and 4 threads encrypting the information, which will be created by the same function, for which a different target will be given also depending on the initial argument.<\/p>\n\n\n\n<p>Before starting the encryption there are two different cases where the binary will first terminate some harcoded processes or services. As shown in the elaborated flow diagram, this will happen only if no argument or &#8220;local&#8221; is given, or if the specified IP address is 127.0.0.1.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"534\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-7.png\" alt=\"\" class=\"wp-image-1152\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-7.png 638w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-7-300x251.png 300w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><figcaption>Elevation of privileges prior to termination of processes<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"692\" height=\"172\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-8.png\" alt=\"\" class=\"wp-image-1153\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-8.png 692w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-8-300x75.png 300w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><figcaption>Hardcoded services and processes names to terminate, along with the function calls to do so<\/figcaption><\/figure><\/div>\n\n\n\n<p>Just like the previous versions, this sample will use SeDebugPrivilege in order to obtain the necessary rights to terminate processes and services, in this sample they only added one new process to terminate: the Store Worker Process (Microsoft.Exchange.Store.Worker.exe), responsible for executing RPC operations for mailboxes on a database.<\/p>\n\n\n\n<p>Unlike the majority of ransomware families, two different instances of the same process could be executed at the same time, which could cause interferences between each other. However, to avoid double cyphering, the RANSOMWARE still adds to the encrypted file a 240 bytes header, with nothing but the string &#8220;FIDEL.CA&#8221; and four extra values in the consecutive words. Before encypting a file, the presence of this &#8220;file signature&#8221; will be checked.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"642\" height=\"376\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-9.png\" alt=\"\" class=\"wp-image-1154\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-9.png 642w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-9-300x176.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><figcaption>Encrypted file header<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"202\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-10.png\" alt=\"\" class=\"wp-image-1155\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-10.png 640w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-10-300x95.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><figcaption>Encryption header check<\/figcaption><\/figure><\/div>\n\n\n\n<p>In the version analyzed by McAfee, they found that their sample could take a different list of arguments such as \/min, \/max, \/dm, \/net, or \/scan. However, the sample we analyzed only accepts one of the arguments described above. This means that for this version THERE IS NO POSSIBILITY THAT the ransomware operator CAN specify a maximum or minimunm file size to encrypt. Though, large files will only get encrypted their first MB for EVERY 9MB.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"641\" height=\"300\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-11.png\" alt=\"\" class=\"wp-image-1156\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-11.png 641w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-11-300x140.png 300w\" sizes=\"(max-width: 641px) 100vw, 641px\" \/><figcaption>End of first Megabyte from encryption file<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"634\" height=\"340\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-12.png\" alt=\"\" class=\"wp-image-1157\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-12.png 634w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-12-300x161.png 300w\" sizes=\"(max-width: 634px) 100vw, 634px\" \/><figcaption>Beginning of 9th Megabyte of encrypted file<\/figcaption><\/figure><\/div>\n\n\n\n<p>Most likely in order to avoid system failures, the ransomware will not encrypt files with extensions .exe, .dll, .sys, .ini, .lnk, .cuba, and it will ignore paths containing &#8220;\\windows\\&#8221;.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"470\" src=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-13-1024x470.png\" alt=\"\" class=\"wp-image-1158\" srcset=\"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-13-1024x470.png 1024w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-13-300x138.png 300w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-13-768x352.png 768w, https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/image-13.png 1140w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Cypher function checking files and routes to skip, with snippets of the called functions<\/figcaption><\/figure><\/div>\n\n\n\n<p>Once the threads have finished the cyphering task, the function to delete itself from disk will be called, INDEPENDENTLY FROM the argument provided, unlike the McAfee sample, where they affirmed that this function would be called when giving the &#8220;\/dm&#8221; argument. For this, the sample will call the Windows API CreateProcessW with &#8220;\\\\system32\\\\cmd.exe&#8221; as the ApplicationName and &#8221; \/c \\del [exe_path] &gt;&gt; NULL &#8221; as command line arguments.<\/p>\n\n\n\n<p>The complete list of stopped processes and services is shown in the following tables:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>MySQL<\/td><td>MSExchangePOP3BE<\/td><\/tr><tr><td>MySQL80<\/td><td>MSExchangePop3<\/td><\/tr><tr><td>SQLSERVERAGENT<\/td><td>MSExchangeNotificationsBroker<\/td><\/tr><tr><td>MSSQLSERVER<\/td><td>MSExchangeMailboxReplication<\/td><\/tr><tr><td>SQLWriter<\/td><td>MSExchangeMailboxAssistants<\/td><\/tr><tr><td>SQLTELEMETRY<\/td><td>MSExchangeIS<\/td><\/tr><tr><td>MSDTC<\/td><td>MSExchangeIMAP4BE<\/td><\/tr><tr><td>SQLBrowser<\/td><td>MSExchangeImap4<\/td><\/tr><tr><td>vmcompute<\/td><td>MSExchangeHMRecovery<\/td><\/tr><tr><td>vmms<\/td><td>MSExchangeHM<\/td><\/tr><tr><td>MSExchangeUMCR<\/td><td>MSExchangeFrontEndTransport<\/td><\/tr><tr><td>MSExchangeUM<\/td><td>MSExchangeFastSearch<\/td><\/tr><tr><td>MSExchangeTransportLogSearch<\/td><td>MSExchangeEdgeSync<\/td><\/tr><tr><td>MSExchangeTransport<\/td><td>MSExchangeDiagnostics<\/td><\/tr><tr><td>MSExchangeThrottling<\/td><td>MSExchangeDelivery<\/td><\/tr><tr><td>MSExchangeSubmission<\/td><td>MSExchangeDagMgmt<\/td><\/tr><tr><td>MSExchangeServiceHost<\/td><td>MSExchangeCompliance<\/td><\/tr><tr><td>MSExchangeRPC<\/td><td>MSExchangeAntispamUpdate<\/td><\/tr><tr><td>MSExchangeRepl<\/td><td><\/td><\/tr><\/tbody><\/table><figcaption>Stopped services<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>sqlagent.exe<\/td><td>sqlbrowser.exe<\/td><\/tr><tr><td>sqlservr.exe<\/td><td>vmwp.exe<\/td><\/tr><tr><td>sqlwriter.exe<\/td><td>outlook.exe<\/td><\/tr><tr><td>sqlceip.exe<\/td><td>vmsp.exe<\/td><\/tr><tr><td>msdtc.exe<\/td><td>Microsoft.Exchange.Store.Worker.exe<\/td><\/tr><\/tbody><\/table><figcaption>Tertminated processes<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Due to the recent warning published by the FBI about Cuba ransomware (original FBI warning no longer available online for unknown reasons), from Lab52 we decided to publish some information about this ransomware family. Despite the fact that the ransomware has been named Cuba, there is no clear evidence linking the country to the implementation [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":1165,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-1144","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-uncategorised","8":"entry"},"featured_image_src":"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/cubaransom.jpeg","featured_image_src_square":"https:\/\/lab52.io\/blog\/wp-content\/uploads\/2021\/12\/cubaransom.jpeg","author_info":{"display_name":"Dex","author_link":"https:\/\/lab52.io\/blog\/author\/dex\/"},"_links":{"self":[{"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/posts\/1144"}],"collection":[{"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/comments?post=1144"}],"version-history":[{"count":6,"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/posts\/1144\/revisions"}],"predecessor-version":[{"id":1166,"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/posts\/1144\/revisions\/1166"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/media\/1165"}],"wp:attachment":[{"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/media?parent=1144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/categories?post=1144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab52.io\/blog\/wp-json\/wp\/v2\/tags?post=1144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}