Windows Privilege Escalation (Part 2 of 2)

 





Token Impersonation

Token impersonation is an effective approach for a Windows local administrator to impersonate another user and issue commands in the name of that user. There are many tools that are created to particularly exploit this vulnerability. Windows consists of several privileges that, if enabled, may allow an attacker to escalate them to the SYSTEM.

Local users have privileges to carry out specific tasks, like managing volumes, changing the system's locale, and shutting down the system. An access token is used for all the security choices and holds the security identity of a process in Windows. So, whenever there is an attempt to interact with the objects laced with security descriptors, a user-spawned process or thread will automatically inherit the same token (securable objects).

Impersonation is a technique that allows a process to use another user's tokens, that can be used if a task necessitates increased privileges. Service accounts are generally created with impersonation privileges because they have to confirm that the user trying to connect has required credentials. Tokens that can be used for privilege escalations are as follows: 

  1. SeAssignPrimaryToken
  2. SeImpersonate
  3. SeBackupPrivilege
  4. SeBackup
  5. SeCreateToken
  6. SeDebug
  7. SeLoadDriver
  8. SeRestore
  9. SeTakeOwnership
  10. SeTcb

One of the exploits that can utilize access token to escalate privileges from a non-system user to system is called juicy potato. It is a fork and more known version of Rotten Potato. It make use of Windows access token handling features, mainly SeImpersonate and SeAssignPrimaryToken. The non-admin user must have one of the tokens mentioned above enabled. Only then the penetration tester can proceed to create the malicious payload. Then, he must transfer the payload to the victim's machine. Finally, the Juicy Potato binary execution with the malicious payload parameter proceeds. At this point, the pen tester should receive a reverse shell on the listening port with elevated privileges.

Some of the exploits that utilize token impersonation are: 

  1. Rogue Potato
  2. PrintSpoofer Exploit
  3. Metasploit Exploitation

Windows Kernel Exploits

If one is trying to attack system-level software like drivers or the kernel itself, then it is important to consider the target's operating system, version, and architecture. If these factors are not correctly identified, then running the exploit may result in a Blue Screen of Death. It might impact negatively the production system of client and may prevent accessing a useful target. 

Firstly, the pen tester must consider the system information to be dealt with. 

systeminfo - findstr /B /C: "OS Name" /C: "OS Version" /C: "System Type"

The above command will help the tester to learn about the system version and architecture. Keeping in mind these information, the tester must search for known vulnerabilities for the specific version of the system. However, additional reconnaissance and investigation is still required for a successful attack. Extra enumeration for useful information can be done by driverquery /v command.

Majority of the output is made of standard Microsoft installed drivers, with a very small number of third party drivers. Hence, it should be remembered that even if a driver is shown as stopped, it might still be loaded in the kernel memory space and may still be accessible. Third-party drivers generally offers a more enticing attack surface because Microsoft-installed drivers have a very strict patch cycle. To find a vulnerable third party driver, the penetration tester can check Exploit Database for potential exploits.

Mostly, the exploits targeting kernel-level vulnerabilities are created in low-level programming languages like C or C++, and must ideally be compiled on the platform version it is meant to run on. Pen tester can build a virtual machine identical to the target and compile the code there. However, the tester can also cross-compile the code to run on a different operating system from the targeted one without any problems. 

Conclusion

This part is all about token impersonation and Windows kernel exploits and completes the Windows Privilege Escalation. 



















































Comments

Popular posts from this blog

Query, Visualize, & Monitor Data in Azure Sentinel

Planning for Implementing SAP Solutions on Azure (Part 2 of 5)

Work with String Data Using KQL Statements