{"id":11926,"date":"2018-04-04T08:10:02","date_gmt":"2018-04-04T16:10:02","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2018\/04\/04\/news-5695\/"},"modified":"2018-04-04T08:10:02","modified_gmt":"2018-04-04T16:10:02","slug":"news-5695","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2018\/04\/04\/news-5695\/","title":{"rendered":"LockCrypt ransomware: weakness in code can lead to recovery"},"content":{"rendered":"<p><strong>Credit to Author: Malwarebytes Labs| Date: Wed, 04 Apr 2018 15:00:54 +0000<\/strong><\/p>\n<p>At the start of the year, it seemed that 2018 was going to be all about cryptominers. They so overwhelmingly dominated the landscape that it looked like no other threat had a chance. However, ransomware is not giving up the field so fast. There have been new variants popping up every couple of months, peering rather shyly around the corner.<\/p>\n<p>At the moment, the most popular ransomware is GandCrab. However, a lesser-known family called\u00a0LockCrypt has been creeping around under the radar since\u00a0<a href=\"https:\/\/www.bleepingcomputer.com\/forums\/t\/648384\/lockcrypt-lock-support-topic-readmetxt\/\" target=\"_blank\" rel=\"noopener\">June 2017<\/a>. Since it is spread via RDP brute-force attacks that must be manually installed, it has never been a massive threat\u2014and therefore had never been described in detail.<\/p>\n<p>But recently we were contacted by some victims of LockCrypt, so we decided to take a closer look. Our investigation led to some interesting findings, especially when we discovered that the ransomware authors decided to ignore popular advice not to roll your own crypto. As we could easily guess, it introduced weaknesses to the code, along with the possibility to recover the data in some cases.<\/p>\n<h3>Analyzed sample<\/h3>\n<p><a href=\"https:\/\/www.virustotal.com\/#\/file\/67c7b46aed4f9b505b492b700839609c39f05ac60c58fe320eca69316fe3a06c\/community\" target=\"_blank\" rel=\"noopener\">99a3d049f11474fac6844447ac2da430<\/a><\/p>\n<h3>Behavioral analysis<\/h3>\n<p>In order to execute properly, the malware must be run as an Administrator. Due to the fact that it is deployed manually by attackers, it doesn&#8217;t use any tricks or exploits to automatically elevate its privileges.<\/p>\n<p>Once it is run, it deletes the original sample and drops itself in <code>C:Windows<\/code> under the name <code>wwvcm.exe<\/code>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21492\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/dropped_in_windows\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/dropped_in_windows.png\" data-orig-size=\"448,116\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"dropped_in_windows\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/dropped_in_windows-300x78.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/dropped_in_windows.png\" class=\"size-full wp-image-21492 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/dropped_in_windows.png\" alt=\"\" width=\"448\" height=\"116\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/dropped_in_windows.png 448w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/dropped_in_windows-300x78.png 300w\" sizes=\"auto, (max-width: 448px) 100vw, 448px\" \/><\/p>\n<p>It also adds persistence using a registry key:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21493\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/persistence-4\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/persistence.png\" data-orig-size=\"561,61\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"persistence\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/persistence-300x33.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/persistence.png\" class=\"size-full wp-image-21493 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/persistence.png\" alt=\"\" width=\"561\" height=\"61\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/persistence.png 561w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/persistence-300x33.png 300w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/p>\n<p>This ransomware encrypts all the files it can possibly reach. During the process, it enumerates and tries to terminate all running applications so that they will not be blocking access to the attacked files. Executables are also attacked.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21482\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/encrypted-10\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/encrypted.png\" data-orig-size=\"844,94\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"encrypted\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/encrypted-300x33.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/encrypted-600x67.png\" class=\"size-full wp-image-21482 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/encrypted.png\" alt=\"\" width=\"844\" height=\"94\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/encrypted.png 844w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/encrypted-300x33.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/encrypted-600x67.png 600w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><\/p>\n<p>The names of the encrypted files are obfuscated\u2014first encrypted and then converted to base64. The random ID is also a part of the name. The extension used is &#8216;1btc&#8217;.<\/p>\n<p>The ransom note is dropped as a TXT file:<\/p>\n<p><a href=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note.png\" target=\"_blank\" rel=\"noopener\" data-rel=\"lightbox-0\" title=\"\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21483\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/note-2\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note.png\" data-orig-size=\"1414,287\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"note\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note-300x61.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note-600x122.png\" class=\"size-full wp-image-21483 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note.png\" alt=\"\" width=\"1414\" height=\"287\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note.png 1414w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note-300x61.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/note-600x122.png 600w\" sizes=\"auto, (max-width: 1414px) 100vw, 1414px\" \/><\/a><\/p>\n<p>Which pops up at the end of the execution.<\/p>\n<p>Looking inside the encrypted files, we saw that they have pretty high entropy. The example below shows a BMP file before and after encryption:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"11700\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2016\/03\/maktub-locker-beautiful-and-dangerous\/attachment\/enc_square1-5\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2016\/03\/enc_square1.png\" data-orig-size=\"219,219\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"enc_square1\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2016\/03\/enc_square1.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2016\/03\/enc_square1.png\" class=\"size-full wp-image-11700 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2016\/03\/enc_square1.png\" alt=\"\" width=\"219\" height=\"219\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2016\/03\/enc_square1.png 219w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2016\/03\/enc_square1-150x150.png 150w\" sizes=\"auto, (max-width: 219px) 100vw, 219px\" \/> <img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21490\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/enc_ejwtgnhksbvfrzlfakk0snyweempbq-id-y8rasu473r6t35c7-1btc\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/enc_ejwtGnhKSBVfRzlFAkk0SnYweEMpBQ-ID-Y8RASU473R6T35c7.1btc.png\" data-orig-size=\"219,219\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"enc_ejwtGnhKSBVfRzlFAkk0SnYweEMpBQ== ID Y8RASU473R6T35c7.1btc\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/enc_ejwtGnhKSBVfRzlFAkk0SnYweEMpBQ-ID-Y8RASU473R6T35c7.1btc.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/enc_ejwtGnhKSBVfRzlFAkk0SnYweEMpBQ-ID-Y8RASU473R6T35c7.1btc.png\" class=\"size-full wp-image-21490 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/enc_ejwtGnhKSBVfRzlFAkk0SnYweEMpBQ-ID-Y8RASU473R6T35c7.1btc.png\" alt=\"\" width=\"219\" height=\"219\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/enc_ejwtGnhKSBVfRzlFAkk0SnYweEMpBQ-ID-Y8RASU473R6T35c7.1btc.png 219w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/enc_ejwtGnhKSBVfRzlFAkk0SnYweEMpBQ-ID-Y8RASU473R6T35c7.1btc-150x150.png 150w\" sizes=\"auto, (max-width: 219px) 100vw, 219px\" \/><\/p>\n<p>Our initial assessment of the image was that the authors didn&#8217;t use a trivial XOR here. It may also look like a file <a href=\"https:\/\/speakerdeck.com\/hshrzd\/virus-bulletin-2016-challenges-and-approaches-of-cracking-ransomware\" target=\"_blank\" rel=\"noopener\">encrypted by stream ciphers (or any ciphers in CBC mode)<\/a>. After looking inside the code, we will know more about it.<\/p>\n<p>Looking at the changes made in the registry, we found more data left there by the ransomware, such as the unique ID of the victim:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21494\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/hacked_key\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/hacked_key.png\" data-orig-size=\"610,308\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"hacked_key\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/hacked_key-300x151.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/hacked_key-600x303.png\" class=\"size-full wp-image-21494 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/hacked_key.png\" alt=\"\" width=\"610\" height=\"308\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/hacked_key.png 610w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/hacked_key-300x151.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/hacked_key-600x303.png 600w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/p>\n<h3>Network communication<\/h3>\n<p>The malware is capable of encrypting without an Internet connection. However, if we run it on a connected machine, it beacons to its CnC. The CnC IP is <a href=\"https:\/\/www.abuseipdb.com\/whois\/46.32.17.222\" target=\"_blank\" rel=\"noopener\">46.32.17.222 (located in Iran)<\/a>.<\/p>\n<p>Here&#8217;s a fragment of the communication:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21484\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/beacon-5\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/beacon.png\" data-orig-size=\"860,232\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"beacon\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/beacon-300x81.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/beacon-600x162.png\" class=\"size-full wp-image-21484 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/beacon.png\" alt=\"\" width=\"860\" height=\"232\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/beacon.png 860w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/beacon-300x81.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/beacon-600x162.png 600w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><\/p>\n<p>The bot sends base64 encoded data about the attacked machine, such as the random ID, username, operating system, and the path from where the malware was deployed. Example:<\/p>\n<pre>WThSQVNVNDczUjZUMzVjNycsJ1dpbmRvd3MgNyBQcm9mZXNzaW9uYWx8dGVzdGVyfEM6XFVzZXJzXHRlc3RlclxEZXNrdG9wXGxvY2tjcnlwdC5leGU=  <\/pre>\n<p>Decodes to:<\/p>\n<pre>Y8RASU473R6T35c7','Windows 7 Professional|tester|C:UserstesterDesktoplockcrypt.exe  <\/pre>\n<p>The server sends back a block of bytes, which looks like some random or encrypted data. Its exact role we will find out by looking into the code.<\/p>\n<h3>Inside the code<\/h3>\n<p>The sample is not packed by any external crypter, nor is it obfuscated. Once we open it, we can directly see all that it has inside.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21470\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/start-3\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/start.png\" data-orig-size=\"479,320\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"start\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/start-300x200.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/start.png\" class=\"size-full wp-image-21470 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/start.png\" alt=\"\" width=\"479\" height=\"320\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/start.png 479w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/start-300x200.png 300w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/p>\n<p>At the beginning, the ransomware checks the folder from which it is running. It tries to make a copy in the Windows folder and redeploys itself from that location.<\/p>\n<p>Then, it creates a thread that continuously enumerates all the running processes and tries to terminate them.<\/p>\n<p>It reads the registry to check if it was already deployed. Finding the appropriate keys can stop the infection\u2014the malware will recognize the machine as already attacked. Otherwise, it will proceed further.<\/p>\n<h3>Encryption<\/h3>\n<p>The infection starts from the attempt to communicate with the CnC.<\/p>\n<p>Looking inside this function, we could now understand the role of the mysterious buffer of bytes seen during the behavioral analysis. The downloaded buffer is validated by its CRC32 checksum. Then, it sets in a global variable for the further use of the encryption routine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"22109\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/init_buffer\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/init_buffer.png\" data-orig-size=\"930,378\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"init_buffer\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/init_buffer-300x122.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/init_buffer-600x244.png\" class=\"size-full wp-image-22109 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/init_buffer.png\" alt=\"\" width=\"930\" height=\"378\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/init_buffer.png 930w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/init_buffer-300x122.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/init_buffer-600x244.png 600w\" sizes=\"auto, (max-width: 930px) 100vw, 930px\" \/><\/p>\n<p>It turns out that this buffer is like a pad used for the encryption schema. The authors probably wanted to achieve something like a\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/One-time_pad\" target=\"_blank\" rel=\"noopener\">one-time-pad encryption<\/a>. However, they reused the buffer, and because of this, they made their algorithm vulnerable for a plain text attack.<\/p>\n<p>If for some reason downloading the buffer from the Internet is not possible, it is generated by a simple, pseudo-random algorithm:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"22110\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/scramble_buf\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/scramble_buf.png\" data-orig-size=\"616,419\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"scramble_buf\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/scramble_buf-300x204.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/scramble_buf-600x408.png\" class=\"size-full wp-image-22110 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/scramble_buf.png\" alt=\"\" width=\"616\" height=\"419\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/scramble_buf.png 616w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/scramble_buf-300x204.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/03\/scramble_buf-600x408.png 600w\" sizes=\"auto, (max-width: 616px) 100vw, 616px\" \/><\/p>\n<p>The authors did not make the best choice for the random generator. Rather than using a cryptographically strong one, they went for the GetTickCount function.<\/p>\n<p>Looking inside the encryption routine, we can see that the file is scrambled by a pretty simple function:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21496\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/scrambling_content\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/scrambling_content.png\" data-orig-size=\"451,533\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"scrambling_content\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/scrambling_content-254x300.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/scrambling_content.png\" class=\"size-full wp-image-21496 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/scrambling_content.png\" alt=\"\" width=\"451\" height=\"533\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/scrambling_content.png 451w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/scrambling_content-254x300.png 254w\" sizes=\"auto, (max-width: 451px) 100vw, 451px\" \/><\/p>\n<p>The scrambling algorithm has two different rounds. The reconstructed code of both rounds can be seen below.<\/p>\n<h4>Round 1<\/h4>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div class=\"gist-oembed\" data-gist=\"hasherezade\/781c18d902bbba023cef6a272c0b0624.json\"><\/div>\n<p>This round uses only XOR operation, but there is a twist that prevents you from recovering the original key. Although the DWORD from the input is XORed with a DWORD from the key, the input is also tainted with the previous output. On every step, the first half of the input DWORD is taken from the previous output, while only the second half is fresh. That makes it a simple stream cipher.<\/p>\n<h4>Round 2<\/h4>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div class=\"gist-oembed\" data-gist=\"hasherezade\/ed8366cf0fd007a2a416f2531d5251e4.json\"><\/div>\n<p>This round looks more complicated\u2014Not only is XOR operation used here, but also ROL and bitwise swap. However, there is no input tainting this time, so it is easily reversible.<\/p>\n<p>Those two simple rounds, together with the &#8220;pad&#8221; buffer that is 2,500 bytes long, were able to generate the output with pretty high entropy.<\/p>\n<h3>File names obfuscation<\/h3>\n<p>The names of the files are first XORed with the pad buffer, and then base64 encoded. The offset of the XOR key is 1111 characters from the beginning of the buffer.<\/p>\n<p>The part of code responsible for this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21521\" data-permalink=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/attachment\/name_obfuscation\/\" data-orig-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/name_obfuscation.png\" data-orig-size=\"504,417\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"name_obfuscation\" data-image-description=\"\" data-medium-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/name_obfuscation-300x248.png\" data-large-file=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/name_obfuscation.png\" class=\"size-full wp-image-21521 aligncenter\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/name_obfuscation.png\" alt=\"\" width=\"504\" height=\"417\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/name_obfuscation.png 504w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2018\/02\/name_obfuscation-300x248.png 300w\" sizes=\"auto, (max-width: 504px) 100vw, 504px\" \/><\/p>\n<h3>Conclusion<\/h3>\n<p>LockCrypt is an example of yet another simple ransomware created and used by unsophisticated attackers. Its authors ignored well-known guidelines about the proper use of cryptography. The internal structure of the application is also unprofessional.<\/p>\n<p>Sloppy, unprofessional code is pretty commonplace when ransomware is created for manual distribution. Authors don&#8217;t take much time preparing the attack or the payload. Instead, they&#8217;re rather focused on a fast and easy gain, rather than on creating something for the long run. Because of this, they could easily be defeated.<\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/\">LockCrypt ransomware: weakness in code can lead to recovery<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\">Malwarebytes Labs<\/a>.<\/p>\n<p><a href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/\" target=\"bwo\" >https:\/\/blog.malwarebytes.com\/feed\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><strong>Credit to Author: Malwarebytes Labs| Date: Wed, 04 Apr 2018 15:00:54 +0000<\/strong><\/p>\n<table cellpadding='10'>\n<tr>\n<td valign='top' align='center'><a href='https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/' title='LockCrypt ransomware: weakness in code can lead to recovery'><img src='https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2016\/11\/photodune-11607095-ransomware-m.jpg' border='0'  width='300px'  \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign='top' align='left'>A lesser-known variant called\u00a0LockCrypt ransomware has been creeping around under the radar since\u00a0June 2017. We take a look inside its code and expose its flaws.<\/p>\n<p>Categories: <\/p>\n<ul class=\"post-categories\">\n<li><a href=\"https:\/\/blog.malwarebytes.com\/category\/threat-analysis\/malware-threat-analysis\/\" rel=\"category tag\">Malware<\/a><\/li>\n<li><a href=\"https:\/\/blog.malwarebytes.com\/category\/threat-analysis\/\" rel=\"category tag\">Threat analysis<\/a><\/li>\n<\/ul>\n<p>Tags: <a href=\"https:\/\/blog.malwarebytes.com\/tag\/lockcrypt\/\" rel=\"tag\">LockCrypt<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/lockcrypt-ransomware\/\" rel=\"tag\">LockCrypt ransomware<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/ransomware\/\" rel=\"tag\">ransomware<\/a><\/p>\n<table width='100%'>\n<tr>\n<td align=right>\n<p><b>(<a href='https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/' title='LockCrypt ransomware: weakness in code can lead to recovery'>Read more&#8230;<\/a>)<\/b><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<\/td>\n<\/tr>\n<\/table>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2018\/04\/lockcrypt-ransomware\/\">LockCrypt ransomware: weakness in code can lead to recovery<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\">Malwarebytes Labs<\/a>.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10488,10378],"tags":[18018,18019,3764,3765,10494],"class_list":["post-11926","post","type-post","status-publish","format-standard","hentry","category-malwarebytes","category-security","tag-lockcrypt","tag-lockcrypt-ransomware","tag-malware","tag-ransomware","tag-threat-analysis"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/11926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=11926"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/11926\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=11926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=11926"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=11926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}