πŸ“ŽStapler

Average beginner/intermediate VM, only a few twists

1. Reconnaissance

Scanning the network to find vulnerable machine's IP

sudo arp-scan -l
Interface: enp0s3, type: EN10MB, MAC: 08:00:27:9c:9d:c8, IPv4: 192.168.10.25
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.10.1	52:54:00:12:35:00	QEMU
192.168.10.2	52:54:00:12:35:00	QEMU
192.168.10.3	08:00:27:da:3d:d3	PCS Systemtechnik GmbH
192.168.10.42	08:00:27:8a:e0:f7	PCS Systemtechnik GmbH
  • We find the IP of the vulnerable machine to be 192.168.10.42

2. Scanning

2.1 Nmap

  • Using nmap to find the open ports and their services

nmsudo nmap -Pn -p- -sV -O 192.168.10.42
Starting Nmap 7.92 ( https://nmap.org ) at 2022-06-25 18:57 IST
Nmap scan report for 192.168.10.42
Host is up (0.0011s latency).
Not shown: 65523 filtered tcp ports (no-response)
PORT      STATE  SERVICE     VERSION
20/tcp    closed ftp-data
21/tcp    open   ftp         vsftpd 2.0.8 or later
22/tcp    open   ssh         OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
53/tcp    open   domain      dnsmasq 2.75
80/tcp    open   http        PHP cli server 5.5 or later
123/tcp   closed ntp
137/tcp   closed netbios-ns
138/tcp   closed netbios-dgm
139/tcp   open   netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
666/tcp   open   doom?
3306/tcp  open   mysql       MySQL 5.7.12-0ubuntu1
12380/tcp open   http        Apache httpd 2.4.18 ((Ubuntu))
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port666-TCP:V=7.92%I=7%D=6/25%Time=62B70DB3%P=x86_64-pc-linux-gnu%r(NUL
SF:L,2D58,PK\x03\x04\x14\0\x02\0\x08\0d\x80\xc3Hp\xdf\x15\x81\xaa,\0\0\x1
SF:52\0\0\x0c\0\x1c\0message2\.jpgUT\t\0\x03\+\x9cQ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f\xab4\xcfC\xcd\
SF:x88\x8e}\xac\x15\xf6~\xc4R\x8ewT\x96\xa8KT\x1cam\xdb\x99f\xfb\n\xbc\xb
SF:cL}AJ\xe5H\x912\x88\(O\0k\xc9\xa9\x1a\x93\xb8\x84\x8fdN\xbf\x17\xf5\xf0
SF:\.npy\.9\x04\xcf\x14\x1d\x89Rr9\xe4\xd2\xae\x91#\xfbOg\xed\xf6\x15\x04\
SF:xf6~\xf1\]V\xdcBGu\xeb\xaa=\x8e\xef\xa4HU\x1e\x8f\x9f\x9bI\xf4\xb6GTQ\x
SF:f3\xe9\xe5\x8e\x0b\x14L\xb2\xda\x92\x12\xf3\x95\xa2\x1c\xb3\x13\*P\x11\
SF:?\xfb\xf3\xda\xcaDfv\x89\xa9\xe4k\xc4S\x0e\xd6P0);
MAC Address: 08:00:27:8A:E0:F7 (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: Host: RED; OS: Linux; CPE: cpe:/o:linux:linux_kernel

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 119.53 seconds
  • We get open ports 21, 22, 53, 80, 139, 3306, 12380 with ftp with anonymous login, ssh, dns, http server, netbios, mysql and another http server running respectively.

2.2 FTP

  • Since FTP has anonymous login, we can check it out first.

  • We get a file note.txt and a potential username, Harry

  • We can download the note to our local machine

  • Reading the note, we get two more potential usernames Elly and John. Could be useful for later.

2.2 Http

  • Port 80 is a dead end. There is no useful information and directories there

  • Port 12380, however has a webpage

2.3 Nikto

  • We can scan this webpage using nikto for any potential vulnerabilities or misconfigurations

  • We find a few interesting things here :

    • There is an SSL certificate, which means that there is a secure verion of the webpage

    • There is a robots.txt file which contains two directory entrie /admin112233 and /blogblog

    • There is also a /phpmyadmin directory.Make sense since there is an sql database running

  • Going over to /admin112233 via https, we find that we are redirected to xss-payloads.com

  • Going over to /blogblog, we find an internal blog

  • Scrolling down, we can see that it is a wordpress site

2.4 WPScan

  • We can use WPScan to enumerate for potentialvulnerabilitiess as well as credentials to login to WordPress admin page.We can use the switch --disable-tls-checks to bypass the certificate check

  • We get a number of vulnerable plugins as well as a list of usernames

  • We can try brute forcing the passwords of any user for the login page starting with the first user, John

    This might take some time to brute force, so another way of solving the box is to exploit the LFI vulnerability in the WP plugin advanced-video-embed-embed-videos-or-playlists which can be found by running wpscan --url https://192.168.10.42:12380/blogblog -e ap --plugins-detection aggressive --disable-tls-checks

  • We get a login credential

john : incorrect

3. Gaining Access

3.1 PHP Reverse Shell

  • We can log in to https://192.168.10.42:12380/blogblog/wp-admin with the above credentials

  • We are greeted with an old version of WP admin panel

  • We can get a php reverse shell from pentestmonkey(Make sure to change the IP address to your local machine) and save it as rev.php

  • We can upload it from Plugins > Upload Plugin

  • Click on install now to upload it.

  • We can provide localhost as the hostname and anonymous as FTP login credentials

  • Start a netcat session to capture the reverse shell on port 1234

  • Navigate to https://192.168.10.42:12380/blogblog/wp-content/uploads/ and click on the uploaded rev.php to run the reverse shell

  • We get a shell

  • Stabilizing the shell

4. Privilege escalation

4.1 Linux exploit suggester

4.2 Double-fdput exploit

  • There are a lot of exploit suggestions offered, but we are going to use [CVE-2016-4557] double-fdput(). There is the exploit link also provided with it, so we can directly download it to the system.

  • It is a zip file, unzipping it we get

  • The exploit is in exploit.tar, extracting it

  • Now we need to run compile.sh to compile doubleput.c

  • We get some errors, but after compilation, we get a file doubleput. Executing it will give us root

  • Reading the flag

Last updated