{"id":8999,"date":"2023-12-28T23:14:48","date_gmt":"2023-12-28T23:14:48","guid":{"rendered":"https:\/\/www.hexacorn.com\/blog\/?p=8999"},"modified":"2024-12-25T23:20:00","modified_gmt":"2024-12-25T23:20:00","slug":"1-little-known-secret-of-regsvr32-exe-take-three","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2023\/12\/28\/1-little-known-secret-of-regsvr32-exe-take-three\/","title":{"rendered":"1 little known secret of regsvr32.exe, take three"},"content":{"rendered":"\n<p>In the past I <a href=\"https:\/\/www.hexacorn.com\/blog\/2020\/02\/14\/run-dll-walk-this-way\/\">wrote<\/a> <a href=\"https:\/\/www.hexacorn.com\/blog\/2019\/10\/10\/the-risk-of-falling-for-a-system32-blase\/\">a<\/a> <a href=\"https:\/\/www.hexacorn.com\/blog\/2020\/05\/23\/lolbin-wow-ltd\/\">few<\/a> times about the side-effect of having 2 binaries named the same way and residing in respective System32 and SysWOW64 directories.<\/p>\n\n\n\n<p><em>Regsvr32.exe<\/em> is not different. If you run a 32-bit <em>Regsvr32.exe<\/em> with a command line argument being a path to a 64-bit DLL or OCX, it will spawn its 64-bit twin <em>Regsvr32.exe<\/em> to handle the request:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_3.png\"><img decoding=\"async\" loading=\"lazy\" width=\"452\" height=\"34\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_3.png\" alt=\"\" class=\"wp-image-9000\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_3.png 452w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_3-300x23.png 300w\" sizes=\"(max-width: 452px) 100vw, 452px\" \/><\/a><\/figure>\n\n\n\n<p>I am happy to report that <em>regsvr32.exe<\/em> is using <em>GetSystemDirectoryW<\/em> and <em>GetSystemWow64Directory2W<\/em> APIs instead of relying on environmental variables to build the paths for respective binaries, so there is definitely less chances for lolbinish abuse.<\/p>\n\n\n\n<p>Now, this is not the little known secret yet.<\/p>\n\n\n\n<p>The secret is this:<\/p>\n\n\n\n<p>When you force the <em>regsvr32.exe<\/em> for one architecture to spawn the other <em>regsvr32.exe<\/em> with the other architecture, the command line argument that you started with will be passed to children <em>regsvr32.exe<\/em> process, in full.<\/p>\n\n\n\n<p>Do you see where it is going?<\/p>\n\n\n\n<p>Based on the idea from the <a href=\"https:\/\/www.hexacorn.com\/blog\/2023\/12\/25\/1-little-known-secret-of-regsvr32-exe\/\" data-type=\"post\" data-id=\"8988\">post number one in this series<\/a>, we now know we can pass a list of library names (limit is 256) to <em>regsvr32.exe<\/em> and it will load them all one by one. What if we passed a command line argument that interleaves 32-bit and 64-bit libraries?<\/p>\n\n\n\n<p>The result will be a never-ending, chain reaction-like tree of interleaving <em>regsvr32.exe<\/em> processes executed one bye one!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_4.png\"><img decoding=\"async\" loading=\"lazy\" width=\"462\" height=\"148\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_4.png\" alt=\"\" class=\"wp-image-9001\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_4.png 462w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2023\/12\/regsvr32_4-300x96.png 300w\" sizes=\"(max-width: 462px) 100vw, 462px\" \/><\/a><\/figure>\n\n\n\n<p>Do you want to test it at home?<\/p>\n\n\n\n<p>Warning: do not try this at home!<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">regsvr32.exe c:\\WINDOWS\\system32\\hhctrl.ocx c:\\WINDOWS\\syswow64\\hhctrl.ocx c:\\WINDOWS\\sysnative\\hhctrl.ocx<\/pre>\n\n\n\n<p>As far as I can tell this is the first documented case where <em>c:\\WINDOWS\\system32\\<\/em>, <em>c:\\WINDOWS\\syswow64\\<\/em>, and <em>c:\\WINDOWS\\sysnative\\<\/em> have ever been used together in a command line of any program.<\/p>\n\n\n\n<p>And yes, you can add <em>\/s<\/em> parameter to it too, that is &#8211; if you don&#8217;t want any control over it (<em>\/s<\/em>  stands for <span style=\"text-decoration: underline;\"><em>silent<\/em><\/span> and is disabling any GUI feedback from <em>regsvr32.exe<\/em>)! <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">regsvr32.exe \/s c:\\WINDOWS\\system32\\hhctrl.ocx c:\\WINDOWS\\syswow64\\hhctrl.ocx c:\\WINDOWS\\sysnative\\hhctrl.ocx<\/pre>\n\n\n\n<p>Be warned tough! This is a <em>regsvr32.exe<\/em> bomb! And it&#8217;s a possible <a href=\"https:\/\/x.com\/Hexacorn\/status\/1730708075655381503?s=20\">DOLBIN<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past I wrote a few times about the side-effect of having 2 binaries named the same way and residing in respective System32 and SysWOW64 directories. Regsvr32.exe is not different. If you run a 32-bit Regsvr32.exe with a command &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2023\/12\/28\/1-little-known-secret-of-regsvr32-exe-take-three\/\">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":[117,126,56,64],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/8999"}],"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=8999"}],"version-history":[{"count":9,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/8999\/revisions"}],"predecessor-version":[{"id":9016,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/8999\/revisions\/9016"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=8999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=8999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=8999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}