Giter Club home page Giter Club logo

potato's Introduction

#Potato Privilege Escalation on Windows 7,8,10, Server 2008, Server 2012

###How it works Potato takes advantage of known issues in Windows to gain local privilege escalation, namely NTLM relay (specifically HTTP->SMB relay) and NBNS spoofing.

Using the techniques outlined below, it is possible for an unprivileged user to gain "NT AUTHORITY\SYSYTEM" level access to a Windows host in default configurations.

The exploit consists of 3 main parts, all of which are somewhat configurable through command-line switches:

#####1. Local NBNS Spoofer NBNS is a broadcast UDP protocol for name resolution commonly used in Windows environments. In penetration testing, we often sniff network traffic and respond to NBNS queries observed on a local network. For privilege escalation purposes, we can't assume that we are able to sniff network traffic, so how can we accomplish NBNS spoofing?

If we can know ahead of time which host a target machine (in this case our target is 127.0.0.1) will be sending an NBNS query for, we can craft a response and flood the target host with NBNS responses (since it is a UDP protocol). One complication is that a 2-byte field in the NBNS packet, the TXID, must match in the request and response. We can overcome this by flooding quickly and iterating over all 65536 possible values.

What if the host we are trying to spoof has a DNS record already? Well we can FORCE DNS lookups to fail in a funny way. Using a technique called "port exhaustion" we bind to every single UDP port. When you try to perform a DNS lookup it will fail because there will be no available source port for the DNS reply to come to.

In testing, this has proved to be 100% effective.

#####2. Fake WPAD Proxy Server With the ability to spoof NBNS responses, we can target our NBNS spoofer at 127.0.0.1. We flood the target machine (our own machine) with NBNS response packets for the host "WPAD", or "WPAD.DOMAIN.TLD", and we say that the WPAD host has IP address 127.0.0.1.

At the same time, we run an HTTP server locally on 127.0.0.1. When it receives a request for "http://wpad/wpad.dat", it responds with something like the following:

FindProxyForURL(url,host){
	if (dnsDomainIs(host, "localhost")) return "DIRECT";
	return "PROXY 127.0.0.1:80";}

This will cause all HTTP traffic on the target to be redirected through our server running on 127.0.0.1.

Interestingly, this attack when performed by even a low privilege user will affect all users of the machine. This includes administrators, and system accounts. See the screenshots "egoldstein_spoofing.png" and "dade_spoofed.png" for an example.

#####3. HTTP -> SMB NTLM Relay With all HTTP traffic now flowing through a server that we control, we can do things like request NTLM authentication...

In the Potato exploit, all requests are redirected with a 302 redirect to "http://localhost/GETHASHESxxxxx", where xxxxx is some unique identifier. Requests to "http://localhost/GETHASHESxxxxx" respond with a 401 request for NTLM authentication.

The NTLM credentials are relayed to the local SMB listener to create a new system service that runs a user-defined command. This command will run with "NT AUTHORITY\SYSTEM" privilege.

###Using the Exploit Usage is currently operating system dependant.

It is also a bit flaky sometimes, due to the quirks in how Windows handles proxy settings and the WPAD file. Often when the exploit doesn't work, it is required to leave it running and wait. When Windows already has a cached entry for WPAD, or is allowing direct internet access because no WPAD was found, it could take 30-60 minutes for it to refresh. It is necessary to leave the exploit running and try to trigger it again later, after this time has elapsed.

The techniques listed here are ordered from least to most complex. Any technique later in the list should work on all versions previous. Videos and screenshots are included for each.

#####Windows 7 - see https://www.youtube.com/watch?v=Nd6f5P3LSNM Windows 7 can be fairly reliably exploited through the Windows Defender update mechanism.

Potato.exe has code to automatically trigger this. Simply run the following: Potato.exe -ip <local ip> -cmd <command to run> -disable_exhaust true

This will spin up the NBNS spoofer, spoof "WPAD" to 127.0.0.1, then check for Windows Defender updates.

If your network has a DNS entry for "WPAD" already, you can try "-disable_exhaust false". This should cause the DNS lookup to fail and it should fallback to NBNS. We've tested this a couple times and had it work

#####Windows Server 2008 - see https://www.youtube.com/watch?v=z_IGPWgL5SY Since Windows Server doesn't come with Defender, we need an alternate method. Instead we'll simply check for Windows updates. The other caveat is that, at least on my domain, Server 2K8 wanted WPAD.DOMAIN.TLD instead of just WPAD. The following is an example usage:

Potato.exe -ip <local ip> -cmd <command to run> -disable_exhaust true -disable_defender true --spoof_host WPAD.EMC.LOCAL

After this runs successfully, simply check for Windows updates. If it doesn't trigger, wait about 30m with the exploit running and check again. If it still doesn't work, try actually downloading an update.

If your network has a DNS entry for "WPAD" already, you can try "-disable_exhaust false". This should cause the DNS lookup to fail and it should fallback to NBNS. We've tested this a couple times and had it work

#####Windows 8/10/Server 2012 - see https://www.youtube.com/watch?v=Kan58VeYpb8 In the newest versions of Windows, it appears that Windows Update may no longer respect the proxy settings set in "Internet Options", or check for WPAD. Instead proxy settings for Windows Update are controlled using "netsh winhttp proxy..."

Instead for these versions, we rely on a newer feature of Windows, the "automatic updater of untrusted certificates". Details can be found https://support.microsoft.com/en-us/kb/2677070 and https://technet.microsoft.com/en-us/library/dn265983.aspx

From the technet article "The Windows Server 2012 R2, Windows Server 2012, Windows 8.1, and Windows 8 operating systems include an automatic update mechanism that downloads certificate trust lists (CTLs) on a daily basis."

It appears that this part of Windows still uses WPAD, even when the winhttp proxy setting is set to direct.

In this case the usage of Potato is as follows: Potato.exe -ip <local ip> -cmd <cmd to run> -disable_exhaust true -disable_defender true

At this point, you will need to wait up to 24hrs or find another way to trigger this update.

If your network has a DNS entry for "WPAD" already, you can try "-disable_exhaust false". This should cause the DNS lookup to fail and it should fallback to NBNS. We've tested this a couple times and had it work

###Mitigations

Enabling "Extended Protection for Authentication" in Windows should stop NTLM relay attacks.

SMB Signing may also mitigate this type of attack, however this would require some more research on my part to confirm.

###Off Broadcast NBNS Spoofing Using the same NBNS spoofing technique as the Potato exploit, we can perform NBNS spoofing against any host for which we can talk to UDP 137. We simply need to send UDP packets quickly enough to sneak in a valid reply before the NBNS request times out.

A demo video of this can be seen at https://www.youtube.com/watch?v=Mzn7ozkyG5g

The demo lab has the following setup:

PFSense firewall 10.0.0.0/24 -> Corporate LAN 10.0.1.0 /24 -> Server network

From the corporate network, we’ll attack a machine on the server network.

Usage: python Responder.py –I eth0 –spoof <target>:<spoof address>:<spoof host>

potato's People

Contributors

breenmachine avatar foxglovesec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

potato's Issues

Potato.exe have stopped working

Hello, I'have download the Potato-master, and i'm trying to run it on Windows Server 2012 R2.

The command that I'm using:

Potato.exe -ip 172.16.21.89 -cmd "C:\Windows\System32\cmd.exe /K net localgroup administrators project /add" -disable_exhaust true -disable_defender true

Now the IP (of the system that running the potato.exe) & the account name "project" are correct, and every time when the programs says "Spoofed Target WPAD succesfully..." the Windows Server pop a "Potato.exe have stopped working".

.net framework

When I try to run it I get asked to install .net framework 3.5. Which I can't do because I don't have admin rights in the first place. Any recommendations or maybe I am doing something wrong?

Potato not hearing NBNS requests?

Since there are no instructions on how to 'install' the tool, I got Potato working by downloading the .exe and the two .dlls from Potato/source/Potato/Potato/bin/Release/

I ran the tool as suggested on my Win7 machine, and here is my output:

c:\Users***\Downloads>Potato.exe -ip -cmd "" -disable_exhaust true
Starting NBNS spoofer...WPAD = 127.0.0.1
Clearing dns and nbns cache...
Listening...
Clearing dns and nbns cache...
Clearing dns and nbns cache...
Clearing dns and nbns cache...

Continuing on like that until I hit ctrl+c. If I open up wireshark, I can see the NBNS broadcast requests for WPAD from my host hitting the network. Naturally, I don't see any repsonses as Wireshark cannot monitor the loopback interface on Windows.

I would expect to see the 'Got 127.0.0.1' in the output, but it never shows up. I've tried with and without admin privs, and with and without the Windows firewall enabled, and on two different Win7 machines with same results.

I've also tried setting diable_exhaust to false. In this case, my internet dies as all DNS requests from the host are failing.

Have I missed some steps in the setup? It looks to me like Potato is not receiving the NBNS or DNS requsts, but I verfied that UDP port 137 is listenening after I run Potato, but not before.

Unhandled Exception: FileNotFound

OS: Windows 7 Ultimate SP1 x64

.\Potato.exe -ip 10.1.11.108 -cmd notepad.exe -disable_exhaust true
Starting NBNS spoofer...WPAD = 127.0.0.1
Clearing dns and nbns cache... Got 127.0.0.1
Spoofed target WPAD succesfully...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...
Checking for windows defender updates...

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'NHttp, Version=0.1.8.0, Culture=neutral, PublicKeyToken=156364e4f7b202d9' or one of its dependencies. The system cannot find the file specified.
File name: 'NHttp, Version=0.1.8.0, Culture=neutral, PublicKeyToken=156364e4f7b202d9'
at Potato.HTTPNtlmHandler.startListening(String cmd, String[] wpad_exclude, Int32 port)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value HKLM\Software\Microsoft\Fusion!EnableLog to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

System.Exception: Not supported yet.

When trying to use I get this exception:

exception

Excepción no controlada: System.Exception: Not supported yet. en SharpCifs.Smb.QueuedNtlmContext.GetSigningKey() en \vmware-host\shared fo
lders\Potato\source\SharpCifs\SharpCifs\Smb\QueuedNtlmContext.cs:línea 33
en SharpCifs.Smb.SmbSession.SessionSetup(ServerMessageBlock andx, ServerMessa
geBlock andxResponse) en \vmware-host\shared folders\Potato\source\SharpCifs\Sh
arpCifs\Smb\SmbSession.cs:línea 461
en SharpCifs.Smb.SmbSession.Send(ServerMessageBlock request, ServerMessageBlo
ck response) en \vmware-host\shared folders\Potato\source\SharpCifs\SharpCifs\S
mb\SmbSession.cs:línea 289
en SharpCifs.Smb.SmbTree.TreeConnect(ServerMessageBlock andx, ServerMessageBl
ock andxResponse) en \vmware-host\shared folders\Potato\source\SharpCifs\SharpC
ifs\Smb\SmbTree.cs:línea 194
en SharpCifs.Smb.SmbFile.DoConnect() en \vmware-host\shared folders\Potato\s
ource\SharpCifs\SharpCifs\Smb\SmbFile.cs:línea 1189
en SharpCifs.Smb.SmbFile.Connect() en \vmware-host\shared folders\Potato\sou
rce\SharpCifs\SharpCifs\Smb\SmbFile.cs:línea 1250
en SharpCifs.Smb.SmbFile.Connect0() en \vmware-host\shared folders\Potato\so
urce\SharpCifs\SharpCifs\Smb\SmbFile.cs:línea 1140
en SharpCifs.Smb.SmbFileInputStream..ctor(SmbFile file, Int32 openFlags) en
\vmware-host\shared folders\Potato\source\SharpCifs\SharpCifs\Smb\SmbFileInputSt
ream.cs:línea 92
en SharpCifs.Smb.TransactNamedPipeInputStream..ctor(SmbNamedPipe pipe) en \v
mware-host\shared folders\Potato\source\SharpCifs\SharpCifs\Smb\TransactNamedPip
eInputStream.cs:línea 42
en SharpCifs.Smb.SmbNamedPipe.GetNamedPipeInputStream() en \vmware-host\shar
ed folders\Potato\source\SharpCifs\SharpCifs\Smb\SmbNamedPipe.cs:línea 169
en SharpCifs.Dcerpc.DcerpcPipeHandle.DoSendFragment(Byte[] buf, Int32 off, In
t32 length, Boolean isDirect) en \vmware-host\shared folders\Potato\source\Shar
pCifs\SharpCifs\Dcerpc\DcerpcPipeHandle.cs:línea 74
en SharpCifs.Dcerpc.DcerpcHandle.Sendrecv(DcerpcMessage msg) en \vmware-host

ipv6 dhcp would be a nice feature

I write this as an issue, but it could be a feature / improvement.

During a couple of penetration tests I observed that most Windows clients have ipv6 enabled but they do not have an ipv6 address assigned. In addition it seems that windows OS gives highest priority to the next received lease, does not matter if it's ipv4 or ipv6.

The result: ipv6 dhcp takes over already assigned ipv4 address.

Just presenting yourself as ipv6 dhcp server and serving ipv6 dhcp client requests is a very simple way to poisoning windows clients in the local network both dns and ip and get your "wpad" offered easily, as well as any other exploit.

spoof_host not fully works

Hi, I'm experticing some problem because my Windows 10 installation is part of a domain with a dns prefix like contoso.corp.com. In this case wpad is "wpad.contoso.corp.com". The spoofing part is working perfectly, but when something try to get the configuration file (wpad.dat) the requested URL is http://wpad.contoso.corp.com/wpad.dat and not http://127.0.0.1/wpad.dat so Potato is not replying with a config file but with an empty file.
I guess that the problem is on line #136 of Program.cs
<<else if (request.Url.AbsoluteUri.ToString().Equals("http://127.0.0.1/wpad.dat") || request.Url.AbsoluteUri.ToString().Equals("http://wpad/wpad.dat"))>>
We sould probably add the case with the hostname given with -spoof_host !
At the moment I've tried to open the progect on my Vistual Studio 2005 but I'me having problems with Imports (c:\Microsotf.CSharp.targets not found).
I'll try to solve my problems, but I think that many people will enjoin an official fix!

Thank you so much for your beautifull work !
Paolo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.