{"id":8200,"date":"2017-06-29T09:10:48","date_gmt":"2017-06-29T17:10:48","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/06\/29\/news-1976\/"},"modified":"2017-06-29T09:10:48","modified_gmt":"2017-06-29T17:10:48","slug":"news-1976","status":"publish","type":"post","link":"https:\/\/www.palada.net\/index.php\/2017\/06\/29\/news-1976\/","title":{"rendered":"EternalPetya and the lost Salsa20 key"},"content":{"rendered":"<p><strong>Credit to Author: Malwarebytes Labs| Date: Thu, 29 Jun 2017 16:39:24 +0000<\/strong><\/p>\n<p>We have recently been\u00a0facing a huge outbreak of the new version of Petya-like malware armed with a infector in WannaCry-style. The research is still in progress, and the full report will be published soon.<\/p>\n<p>In this post we will focus on some new important aspects\u00a0that the current malware has. The low level attack works in the same style as in the first Petya described <a href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2016\/04\/petya-ransomware\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>. As before, the beginning of the disk is overwritten by the malicious Petya kernel and bootoader. When the malicious kernel is booted, it encrypts the\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/NTFS#Master_File_Table\" target=\"_blank\" rel=\"noopener noreferrer\">Master File Table<\/a>\u00a0with Salsa20 and by this way, makes the disk inaccessible.<\/p>\n<p>The code from Petya&#8217;s kernel didn&#8217;t change much\u00a0but the new logic implemented in the high level part (the Windows executable) caused the change in the malware&#8217;s mission. In the past, after paying the ransom, the Salsa key from\u00a0the victim was restored and with its help, the Petya kernel was able to decrypt the <a href=\"https:\/\/en.wikipedia.org\/wiki\/NTFS#Master_File_Table\" target=\"_blank\" rel=\"noopener noreferrer\">Master File Table<\/a>. Now, the necessary key seems to be lost for eternity. Thus, the malware appears to have only damaging intentions.<\/p>\n<p>Let&#8217;s have a look at\u00a0the implementation and discuss the details.<\/p>\n<h3>How is the disk encrypted?<\/h3>\n<p>The low level attack, affecting the <a href=\"https:\/\/en.wikipedia.org\/wiki\/NTFS#Master_File_Table\" target=\"_blank\" rel=\"noopener noreferrer\">Master File Table<\/a> didn&#8217;t change since <a href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2016\/12\/goldeneye-ransomware-the-petyamischa-combo-rebranded\/\" target=\"_blank\" rel=\"noopener noreferrer\">Goldeneye<\/a>. It is executed by the Petya kernel.<\/p>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Salsa20\" target=\"_blank\" rel=\"noopener noreferrer\">Salsa20 algorithm<\/a>, that was implemented incorrectly in the early versions of Petya and caused it to be cracked, has been fixed in the version 3 (read more <a href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2016\/07\/third-time-unlucky-improved-petya-is-out\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>). Now it looks almost the same as in Goldeneye (that was the 4-th step in the evolution) and it\u00a0 does not seem to have any bugs. Thus, once the data is encrypted. having the valid key is the only way to restore it.<\/p>\n<p>Comparison of the changes in the code between the current version and the Goldeneye one:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18650\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/comparison.png\" alt=\"\" width=\"519\" height=\"736\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/comparison.png 519w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/comparison-212x300.png 212w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/comparison-423x600.png 423w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/p>\n<p>Looking inside the code we can see, that the significant changes has been made only the elements responsible for displaying the screen with information, i.e.:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18649\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/info_screen.png\" alt=\"\" width=\"641\" height=\"512\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/info_screen.png 641w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/info_screen-300x240.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/info_screen-600x479.png 600w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" \/><\/p>\n<h3>How is the Salsa key generated?<\/h3>\n<p>Generating the Salsa key and the nonce, as before, is done by the PE file (in the higher level of the infector), inside the function that is preparing the stub to be written on the disk beginning:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-18634\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/prepare.png\" alt=\"\" width=\"783\" height=\"497\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/prepare.png 783w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/prepare-300x190.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/prepare-600x381.png 600w\" sizes=\"auto, (max-width: 783px) 100vw, 783px\" \/><\/p>\n<p>In all versions of Petya, a secure random generator was used. In the current version we can find it as well &#8211; it uses <em>CryptGenRandom<\/em>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18636\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/gen_random.png\" alt=\"\" width=\"499\" height=\"423\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/gen_random.png 499w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/gen_random-300x254.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/p>\n<p>The generated Salsa key and nonce are stored in the dedicated sector, for further use by the kernel during encryption.<\/p>\n<p>Example of the stored data:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18639\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/stored_data-1.png\" alt=\"\" width=\"734\" height=\"288\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/stored_data-1.png 734w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/stored_data-1-300x118.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/stored_data-1-600x235.png 600w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<p>The byte at the offset 0x4000 is the flag. 0 means that the disk is not encrypted yet, 1 means encrypted.<\/p>\n<p>From the offset 0x4001 the Salsa20 key starts. It is 32 bytes long. After that, at offset 0x4021 there is the random Salsa20 nonce.<\/p>\n<h3>What happens with the Salsa key after the encryption?<\/h3>\n<p>After being read and used for the encrypting algorithm, the stored Salsa key is erased from the disk. You can see the comparison of the disk image before and after the encryption phase:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18631\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/salsakey_erased.png\" alt=\"\" width=\"609\" height=\"174\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/salsakey_erased.png 609w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/salsakey_erased-300x86.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/salsakey_erased-600x171.png 600w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/salsakey_erased-604x174.png 604w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/p>\n<p>As we can see, after use the key is erased.<\/p>\n<h3>What is the relationship between the victim ID and the Salsa key?<\/h3>\n<p>In the previous versions of Petya, the victim ID was, in fact, the victim&#8217;s Salsa20 key, encrypted with attackers public key and converted to Base58 string. So, although the Salsa key is erased from the disk, still there was a backup &#8211; accessible only for to the attackers, who had the private key to decrypt it.<\/p>\n<p>Now, it is no longer true. The victim ID is generated randomly, BEFORE the random Salsa key is even made. So, in the current version, the relationship of the Salsa key and the victim ID is none. The victim ID is just &#8216;trash&#8217;. You can see the process of generating it on the video:<\/p>\n<p><iframe  src='https:\/\/www.youtube.com\/embed\/LS0nWpRfVs8?version=3&#038;rel=1&#038;fs=1&#038;autohide=2&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' width=\"100%\" height=\"420\" frameborder=\"0\" ><\/iframe> <\/p>\n<h3>Conclusion<\/h3>\n<p>According to our current status of knowledge, the malware is intentionally corrupt in a way that the Salsa key was never meant the be restored. Nevertheless, it is still effective in making people to pay ransom. We can observe, that to the bitcoin account new payments are being made. You can see the link to the bitcoin address here: <a href=\"https:\/\/blockchain.info\/address\/1Mz7153HMuxXTuR2R1t78mGSdzaAtNbBWX\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/blockchain.info\/address\/1Mz7153HMuxXTuR2R1t78mGSdzaAtNbBWX<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18641\" src=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/examples.png\" alt=\"\" width=\"960\" height=\"359\" srcset=\"https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/examples.png 960w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/examples-300x112.png 300w, https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/examples-600x224.png 600w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/p>\n<p>If you are a victim of this malware and you are thinking about\u00a0paying the ransom, we warn you &#8211; don&#8217;t do this. It is scam and most probably you will never get your data back.<\/p>\n<p>We will keep you posted with the updates about our findings.<\/p>\n<h3>Appendix<\/h3>\n<p><a href=\"https:\/\/blogs.technet.microsoft.com\/mmpc\/2017\/06\/27\/new-ransomware-old-techniques-petya-adds-worm-capabilities\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/blogs.technet.microsoft.com\/mmpc\/2017\/06\/27\/new-ransomware-old-techniques-petya-adds-worm-capabilities\/<\/a> &#8211; Microsoft&#8217;s report about the new version of Petya<\/p>\n<p>About the previous version (Goldeneye):<\/p>\n<blockquote data-secret=\"LjClwmBxxV\" class=\"wp-embedded-content\">\n<p><a href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2016\/12\/goldeneye-ransomware-the-petyamischa-combo-rebranded\/\">Goldeneye Ransomware &#8211; the Petya\/Mischa combo rebranded<\/a><\/p>\n<\/blockquote>\n<p><iframe loading=\"lazy\"  src=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2016\/12\/goldeneye-ransomware-the-petyamischa-combo-rebranded\/embed\/#?secret=LjClwmBxxV\" width=\"100%\" height=\"420\" frameborder=\"0\" ><\/iframe> <\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p class=\"p1\"><em><span class=\"s1\">This was a guest post written by Hasherezade, an independent researcher and programmer with a strong interest in InfoSec. <\/span><span class=\"s1\">She loves going in details about malware and sharing threat information with the community. <\/span><span class=\"s2\">Check her out on Twitter @<a href=\"https:\/\/twitter.com\/hasherezade\" target=\"_blank\" rel=\"noopener noreferrer\">hasherezade<\/a> and her personal blog: <a href=\"https:\/\/hshrzd.wordpress.com\/\"><span class=\"s3\">https:\/\/hshrzd.wordpress.com<\/span><\/a>.<\/span><\/em><\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/blog.malwarebytes.com\/threat-analysis\/2017\/06\/eternalpetya-lost-salsa20-key\/\">EternalPetya and the lost Salsa20 key<\/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\/2017\/06\/eternalpetya-lost-salsa20-key\/\" target=\"bwo\" >https:\/\/blog.malwarebytes.com\/feed\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><strong>Credit to Author: Malwarebytes Labs| Date: Thu, 29 Jun 2017 16:39:24 +0000<\/strong><\/p>\n<table cellpadding='10'>\n<tr>\n<td valign='top' align='center'><a href='https:\/\/blog.malwarebytes.com\/threat-analysis\/2017\/06\/eternalpetya-lost-salsa20-key\/' title='EternalPetya and the lost Salsa20 key'><img src='https:\/\/blog.malwarebytes.com\/wp-content\/uploads\/2017\/06\/shutterstock_571661536-1.jpg' border='0'  width='300px'  \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign='top' align='left'>The latest Petya seems to be broken on purpose: the victims&#8217; keys are lost forever.<\/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\/eternalpetya\/\" rel=\"tag\">EternalPetya<\/a><a href=\"https:\/\/blog.malwarebytes.com\/tag\/petya\/\" rel=\"tag\">petya<\/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\/2017\/06\/eternalpetya-lost-salsa20-key\/' title='EternalPetya and the lost Salsa20 key'>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\/2017\/06\/eternalpetya-lost-salsa20-key\/\">EternalPetya and the lost Salsa20 key<\/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":[12849,3764,12823,3765,10494],"class_list":["post-8200","post","type-post","status-publish","format-standard","hentry","category-malwarebytes","category-security","tag-eternalpetya","tag-malware","tag-petya","tag-ransomware","tag-threat-analysis"],"_links":{"self":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/8200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=8200"}],"version-history":[{"count":0,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/8200\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=8200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=8200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=8200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}