{"id":5888,"date":"2019-02-02T01:46:51","date_gmt":"2019-02-02T01:46:51","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=5888"},"modified":"2019-02-02T12:55:00","modified_gmt":"2019-02-02T12:55:00","slug":"beyond-good-ol-run-key-part-101","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2019\/02\/02\/beyond-good-ol-run-key-part-101\/","title":{"rendered":"Beyond good ol\u2019 Run key, Part 101"},"content":{"rendered":"\n<p>This is a bit unusual way of establishing persistence. <\/p>\n\n\n\n<p>We don&#8217;t add any Registry entries. We also don&#8217;t really drop any malicious executable files, unless we have to (fileless malware could establish a persistence this way).<\/p>\n\n\n\n<p>How?<\/p>\n\n\n\n<p>By leveraging the omnipresent files: <em>unins000.dat<\/em> and <em>unins000.exe <\/em>that are dropped by any setup program that is built using the <a href=\"http:\/\/www.jrsoftware.org\/isinfo.php\">InnoSetup installer<\/a>.<\/p>\n\n\n\n<p>One can build a small InnoSetup script e.g. like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[Setup]<br> AppName=test<br> AppVersion=1<br> DefaultDirName=.<br> DefaultGroupName=test<br> [Run]<br> Filename: \"c:\\windows\\system32\\calc.exe\"<br> [UninstallRun]<br> Filename: \"c:\\windows\\system32\\notepad.exe\"<\/pre>\n\n\n\n<p>After installing the .exe, we can collect the <em>unins000.dat<\/em> and <em>unins000.exe<\/em> that are generated during this session. They ensure that Notepad is executed when the application is uninstalled. Attacker could simply &#8216;borrow&#8217; these and place these in a folder where there are already existing files <em>unins000.dat<\/em> and <em>unins000.exe<\/em> (<em>typically under c:\\Program Files, or c:\\Program Files (x86) subfolders<\/em>). <\/p>\n\n\n\n<p>We need to replace <em>unins000.exe<\/em> too, because the custom-made <em>unins000.exe<\/em> files that are dropped by installer may have dependencies that our <em>unins000.dat<\/em> doesn&#8217;t resolve.<\/p>\n\n\n\n<p>Once the user tries to uninstall the program that relies on InnoSetup uninstall process, the <em>unins000.exe<\/em> will process the content of the <em>unins000.dat<\/em> and will run the Notepad.<\/p>\n\n\n\n<p>Since the <em>unins000.exe<\/em> is clean, and only the <em>unins000.dat<\/em>  is really the bad guy here, it is a sort of Lolbin, or Lobinstaller. Security companies are forced to either detect the malicious content inside the .dat file, or rely on behavioral analysis.<\/p>\n\n\n\n<p>Obviously, another trivial persistence method that is related to Uninstallation process, and one I believe I have not discussed before here, and one which is actually not related to InnoSetup per se, is to modify the Uninstall\/QuietUninstall strings for the programs installed on the system. <\/p>\n\n\n\n<p>While they typically point to the native uninstallers, there is no problem in replacing them with commands that can run any other program:<\/p>\n\n\n\n<p><em>HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\&lt;program name&gt;=&lt;string&gt;<\/em><\/p>\n\n\n\n<p>and<\/p>\n\n\n\n<p><em>HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\<\/em>QuietUninstallString<em>\\&lt;program name&gt;=&lt;string&gt;<\/em><\/p>\n\n\n\n<p>Anytime someone runs the uninstaller, they will run the command of attacker&#8217;s choice. Again, the good news is that one needs rights to mod these entries since they are under HKLM key.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a bit unusual way of establishing persistence. We don&#8217;t add any Registry entries. We also don&#8217;t really drop any malicious executable files, unless we have to (fileless malware could establish a persistence this way). How? By leveraging the &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2019\/02\/02\/beyond-good-ol-run-key-part-101\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,35,56,64],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/5888"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=5888"}],"version-history":[{"count":5,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/5888\/revisions"}],"predecessor-version":[{"id":5896,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/5888\/revisions\/5896"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=5888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=5888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=5888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}