{"id":6972,"date":"2020-02-14T19:23:56","date_gmt":"2020-02-14T19:23:56","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=6972"},"modified":"2020-02-14T19:23:58","modified_gmt":"2020-02-14T19:23:58","slug":"run-dll-walk-this-way","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2020\/02\/14\/run-dll-walk-this-way\/","title":{"rendered":"Run DLL &#8211; Walk this way"},"content":{"rendered":"\n<p>The role of Rundll32 is to load DLLs. <\/p>\n\n\n\n<p>On a 32-bit OS it is a very straightforward task, but when you mix architectures interesting things happen. One of a side-effects of having more than one architecture on the same box is that Windows On Windows (WOW) layer gets involved so that we can run 32- and 64- bit code at the same time.<\/p>\n\n\n\n<p>This makes life of rundll32 developer harder. There are two version of rundll32 on a 64-bit Windows system: one inside system32 directory, and another one &#8211; in SysWOW64. But rundll32 users don&#8217;t want to known about these versions, couldn&#8217;t care less about multiple architectures, and when they run a command they simply expect their library to be loaded, and its function called.<\/p>\n\n\n\n<p>When 32-bit rundll32.exe is called to load a 64-bit DLL, 32-bit rundll32.exe will spawn 64-bit version of rundll32.exe and that 64-bit DLL will be loaded there. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/runddl32_2.png\"><img decoding=\"async\" loading=\"lazy\" width=\"224\" height=\"38\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/runddl32_2.png\" alt=\"\" class=\"wp-image-6979\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/runddl32_2.png 224w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/runddl32_2-222x38.png 222w\" sizes=\"(max-width: 224px) 100vw, 224px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>The very same happens when a 64-bit rundll32.exe is used to load a 32-bit library. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/runddl32_1.png\"><img decoding=\"async\" loading=\"lazy\" width=\"222\" height=\"37\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/runddl32_1.png\" alt=\"\" class=\"wp-image-6978\"\/><\/a><\/figure><\/div>\n\n\n\n<p> It&#8217;s like that&#8230; and that&#8217;s the way it is. <\/p>\n\n\n\n<p>This is a well-known stuff and you are probably wondering where I am going with it.<\/p>\n\n\n\n<p>Today most of applications are 64-bit, so one could exploit the rundll32.exe behavior I described in various ways:<\/p>\n\n\n\n<p><strong>Scenario 1<\/strong><\/p>\n\n\n\n<p>Set up a persistence Run key (or use any other common startup method)  to point to <em>rundll32.exe &lt;name of a 32-bit library><\/em><\/p>\n\n\n\n<p>This will keep the persistence entry clean (points to a signed 64-bit rundl32.exe, even if full path is not explicitly set in a startup entry to point to c:\\windows\\system32\\rundll32.exe), and will ensure cascading execution of a 32-bit rundll32.exe that will load the given 32-bit DLL (possibly malicious). <\/p>\n\n\n\n<p><strong>Scenario 2<\/strong><\/p>\n\n\n\n<p>Same as before, set up a persistence in any way you like, just pointing it to a rundll32.exe and using a file name of an existing, clean 32-bit DLL, and then place a malicious rundll32.exe under c:\\windows\\SysWOW64.<\/p>\n\n\n\n<p>This will launch the malicious 32-bit rundll32.exe.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The role of Rundll32 is to load DLLs. On a 32-bit OS it is a very straightforward task, but when you mix architectures interesting things happen. One of a side-effects of having more than one architecture on the same box &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2020\/02\/14\/run-dll-walk-this-way\/\">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,56,64],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6972"}],"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=6972"}],"version-history":[{"count":6,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6972\/revisions"}],"predecessor-version":[{"id":6980,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6972\/revisions\/6980"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=6972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=6972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=6972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}