Vulnhub-dc7

信息收集

# nmap -sT -p- --min-rate 10000 192.168.1.96 -oN port.nmap
Starting Nmap 7.94 ( https://nmap.org ) at 2024-01-27 22:26 CST
Nmap scan report for 192.168.1.96
Host is up (0.00076s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: 00:0C:29:19:A1:86 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 3.29 seconds

nmap探测到的开放端口信息为22 80两个端口,突破点无疑是80端口!

# nmap -sT -sC -sV -O -p80,22 192.168.1.96 -oN details.nmap
Starting Nmap 7.94 ( https://nmap.org ) at 2024-01-27 22:27 CST
Nmap scan report for 192.168.1.96
Host is up (0.00053s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
| ssh-hostkey: 
|   2048 d0:02:e9:c7:5d:95:32:ab:10:99:89:84:34:3d:1e:f9 (RSA)
|   256 d0:d6:40:35:a7:34:a9:0a:79:34:ee:a9:6a:dd:f4:8f (ECDSA)
|_  256 a8:55:d5:76:93:ed:4f:6f:f1:f7:a1:84:2f:af:bb:e1 (ED25519)
80/tcp open  http    Apache httpd 2.4.25 ((Debian))
|_http-generator: Drupal 8 (https://www.drupal.org)
|_http-title: Welcome to DC-7 | D7
|_http-server-header: Apache/2.4.25 (Debian)
| 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/
MAC Address: 00:0C:29:19:A1:86 (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: 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.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 10.60 seconds

80端口上的服务是Drupal 8 Apache的服务 2.4.25 同时存在roboots文件!应该是Drupal的漏洞进行利用~

# nmap -sT --script=vuln -p80,22 192.168.1.96 -oN vuln.nmap 
Starting Nmap 7.94 ( https://nmap.org ) at 2024-01-27 22:28 CST
Pre-scan script results:
| broadcast-avahi-dos: 
|   Discovered hosts:
|     224.0.0.251
|   After NULL UDP avahi packet DoS (CVE-2011-1002).
|_  Hosts are all up (not vulnerable).
Nmap scan report for 192.168.1.96
Host is up (0.0022s latency).

PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
| http-csrf: 
| Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=192.168.1.96
|   Found the following possible CSRF vulnerabilities: 
|     
|     Path: http://192.168.1.96:80/
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node
|     Form id: search-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/user/login
|     Form id: user-login-form
|     Form action: /user/login
|     
|     Path: http://192.168.1.96:80/user/login
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/node/1
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node
|     Form id: search-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node/help
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node
|     Form id: search-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/user/login
|     Form id: user-login-form
|     Form action: /user/login
|     
|     Path: http://192.168.1.96:80/user/login
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/user/password
|     Form id: user-pass
|     Form action: /user/password
|     
|     Path: http://192.168.1.96:80/user/password
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/node/
|     Form id: search-block-form
|     Form action: /search/node
|     
|     Path: http://192.168.1.96:80/search/node/
|     Form id: search-form
|     Form action: /search/node/
|     
|     Path: http://192.168.1.96:80/search/node/
|     Form id: search-block-form
|_    Form action: /search/node
| http-enum: 
|   /rss.xml: RSS or Atom feed
|   /robots.txt: Robots file
|   /INSTALL.txt: Drupal file
|   /: Drupal version 8 
|_  /README.txt: Interesting, a readme.
MAC Address: 00:0C:29:19:A1:86 (VMware)

80端口上的漏洞可能存在csrf,还有相关的敏感文件,同时再次暴露出来Drupal的信息!

渗透测试

Vulnhub-dc7_第1张图片

首页可以看到存在登录的页面,和Drupal的信息;查看一下robots文件:

Vulnhub-dc7_第2张图片

发现了这些文件和目录信息;由于存在后台的登陆界面,所以说我们可以尝试弱口令进行登录:

Vulnhub-dc7_第3张图片

尝试访问了admin目录,但是没有权限~

Vulnhub-dc7_第4张图片

点击log in尝试用户登录!

Vulnhub-dc7_第5张图片

查询到我们的drupal的默认凭证是admin admin 尝试进行登录!

Vulnhub-dc7_第6张图片

登陆失败~ 尝试几个弱口令~依然是失败,并且尝试次数超过了5次,便暂时锁定了该账号!

Vulnhub-dc7_第7张图片

searchsploit搜索公开利用exp:

Vulnhub-dc7_第8张图片

查看了几个文件,包括源码中的信息,无法确定详细的Drupal的版本信息!

那就挨个尝试吧!先排除掉metasploit的利用和POC;

Vulnhub-dc7_第9张图片

但是没有成功的执行漏洞脚本,这里回到了首页中的欢迎界面:

Vulnhub-dc7_第10张图片

尝试去翻译了一下,这里告诉我们需要跳出思维定式,不需要暴力破解或者字典攻击等行为了!那我们就去了解一下Drupal 8 中的漏洞;

Vulnhub-dc7_第11张图片

还是先去看了一下:CVE-2019–6340 攻击者未通过网站身份验证,因此任何有权访问/node/id页面的人都可以利用该漏洞;因此我们尝试去访问一下/node/id,看一下是否有权限去访问!

Vulnhub-dc7_第12张图片

/node/1节点是有权限去访问,但是/node/2节点是没有权限的!

Vulnhub-dc7_第13张图片

其他的节点是404状态的!但是再次尝试利用脚本去测试,并没发现可以利用:

Vulnhub-dc7_第14张图片

尝试清除浏览器缓存之后,还是这个样子~ 手动尝试利用:

Vulnhub-dc7_第15张图片

还是失败的样子~ 后面继续查看和利用了其他的漏洞:

Vulnhub-dc7_第16张图片

然后又去google查询了一下什么是Drupalgeddon2:

Vulnhub-dc7_第17张图片

尝试github上找到的漏洞利用脚本,进行利用,但是还是利用失败,不知道什么原因:

Vulnhub-dc7_第18张图片

兜兜转转看到了首页下面貌似是一个用户:

Vulnhub-dc7_第19张图片

尝试google一下这个用户:

Vulnhub-dc7_第20张图片

发现了这个github的用户,发现config.php文件!

Vulnhub-dc7_第21张图片

这个密码是数据库的密码,但是并没有对外开放3306端口,尝试网站的用户,进行碰撞!

Vulnhub-dc7_第22张图片

还是不对,尝试下22端口,能否碰撞吧:

Vulnhub-dc7_第23张图片

22端口成功登陆了~ 哎还在前面一直尝试Drupal 8 的RCE~ 人麻了 这里既然拿到了立足点,下面就是要进行提权了!

提权

Vulnhub-dc7_第24张图片

先确定下,靶机就是我们的目标,然后查看当前用户是否具有sudo权限:

Vulnhub-dc7_第25张图片

但是没有sudo命令,尝试查看了/etc/passwd文件,看到了只有当前的一个活跃用户!

Vulnhub-dc7_第26张图片

查看了suid权限和当前靶机的内核版本信息!查看到当前用户的家目录下面存在backups目录,下面存在两个gpg后缀的文件,这种后缀没见过,file等命令查看一下这个文件的属性等:

Vulnhub-dc7_第27张图片

使用了对称加密算法进行的加密!AES256 先看看其他的东西,实在不行回来继续看这里!同时在家目录下面看到了邮箱的一个文件:

Vulnhub-dc7_第28张图片

看看邮件的内容:

Vulnhub-dc7_第29张图片

Vulnhub-dc7_第30张图片

这个邮件最重要的信息,就是存在定时任务,backup.sh会不断的去备份网站,属于日常维护的工作!那我们就看一下是不是存在定时任务!

Vulnhub-dc7_第31张图片

但是并没有寻找到定时任务~ 于是通过find命令去查找backups.sh文件!

Vulnhub-dc7_第32张图片

同时找到了网站备份的脚本,查看发现了里面存在加密密码!那么我们就尝试利用gpg去解密这两个文件!

Vulnhub-dc7_第33张图片

gpg --output website.sql --decrypt website.sql.gpg 命令之后便是上面的输入密码阶段,由于之前我们已经得到了密码,直接输入即可!

Vulnhub-dc7_第34张图片

于是成功解密,得到了两个文件,尝试下载到本地看一下里面的内容!发现全是日志一样的信息:

Vulnhub-dc7_第35张图片

于是上传了linpeas进行执行!

Vulnhub-dc7_第36张图片

'database' => 'd7db',
  'username' => 'db7user',
  'password' => 'yNv3Po00',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '',
  'driver' => 'mysql',

当时发现了数据库账号密码,还没进去看一下呢!使用上述的账号和密码便可以成功的进入mysql数据库!还是没什么信息,只是发现了一个用户admin,权限比较高:administrator 于是有尝试了内核漏洞提权,靶机没有gcc环境,而攻击机编译的文件,上传到靶机执行还报错,缺失库~

Vulnhub-dc7_第37张图片

然后看了下大佬们的wp,用到了一款工具:drush(Drupal drush 常用命令_drush命令-CSDN博客)

Vulnhub-dc7_第38张图片

Vulnhub-dc7_第39张图片

尝试执行命令的时候,报错了,这里需要切换到网站的目录下再次执行:

Vulnhub-dc7_第40张图片

执行成功了,可以更改密码!

尝试更改密码成功,利用账号密码登录到后台!

Vulnhub-dc7_第41张图片

这里想到backups.sh这个文件的权限是root 和 www-data组!

那么既然已经进入了后台,一旦能getshell,权限应该就是www-data,那就可以去更改这个备份的脚本文件了!

尝试修改欢迎界面的代码,但是只支持html,于是看到扩展,尝试上传php的扩展:

Vulnhub-dc7_第42张图片

Vulnhub-dc7_第43张图片

Vulnhub-dc7_第44张图片

https://ftp.drupal.org/files/projects/php-8.x-1.0.tar.gz php插件的下载地址!安装完成之后在修改代码!

Vulnhub-dc7_第45张图片

尝试在欢迎界面去修改代码:

Vulnhub-dc7_第46张图片

修改完成之后,尝试去访问!

Vulnhub-dc7_第47张图片

使用蚁剑链接,然后修改一下backups脚本:

Vulnhub-dc7_第48张图片

刚好是www-data权限,接下来就是写反弹shell到backups脚本中!

Vulnhub-dc7_第49张图片

等待反弹shell的执行!(观察邮件可以知道该脚本每15分钟执行一次,时间有点长)

Vulnhub-dc7_第50张图片

提升一下shell的交互性,之后便是读取flag!

Vulnhub-dc7_第51张图片

你可能感兴趣的:(Vulnhub,数据库,网络,安全,学习,网络安全)