VulnHubDC系列之DC1靶机

admin 2024年5月7日11:32:26评论14 views字数 3347阅读11分9秒阅读模式

主机发现以及信息收集

VulnHubDC系列之DC1靶机

VulnHubDC系列之DC1靶机

通过mac地址来确定主机,其实一眼就能看出来哪个是直接就是虚拟主机

VulnHubDC系列之DC1靶机

使用nmap对其进行详细扫描

VulnHubDC系列之DC1靶机

这边使用whatweb做一下探测发现是一个Drupal的cms,有cms的话我们可以来看一下有没有什么漏洞是可以利用的。

VulnHubDC系列之DC1靶机

有很多哇,我们直接上MSF

MSF利用Drupal漏洞

VulnHubDC系列之DC1靶机

发现有很多可以利用的,我们首先来探测一下漏洞是否存在

VulnHubDC系列之DC1靶机

利用Auxiliary好像没有探测出来哇,尴尬了!直接上EXP

VulnHubDC系列之DC1靶机

这里我们进入到前面编号为1 的exp,然后查看一下需要我们配置的参数(在这里也用了一下那个最新的,但是没有创建会话)

VulnHubDC系列之DC1靶机

我们设置靶机IP,然后直接开始攻击,我们看到攻击成功了

get shell

VulnHubDC系列之DC1靶机

看到是一个普通的权限,在找一些有没有啥有用的东西

VulnHubDC系列之DC1靶机

这里它说每个优秀的内容管理系统都需要配置文件,你也一样。那我们就来找一下它的配置文件

VulnHubDC系列之DC1靶机

这边利用python实现交互式的shell,方便一点

VulnHubDC系列之DC1靶机

上百度搜索一些发现是一个settings.php的文件,但是文件的路径找不到,想起来可以使用find命令来查找

VulnHubDC系列之DC1靶机

到根目录下寻找我们的settings.php文件

VulnHubDC系列之DC1靶机

在里面看到了我们的第二个flag,并且得到了一个数据库的用户名密码,我们来看一下它给了啥提示

VulnHubDC系列之DC1靶机

怎么说!还是需要提权,先来看一下我们得到的数据库

VulnHubDC系列之DC1靶机

VulnHubDC系列之DC1靶机

通过数据库表查询到表,在通过表查到用户名和密码信息,额这么简单就出来了?

admin | $S$DvQI6Y600iNeXRIeEMF94Y6FvN8nujJcEDTCP9nS5.i38jnEKuDR
Fred | $S$DWGrxef6.D0cwB5Ts.GlnLw15chRRWH2s1R3QBwC0EkvBQ/9TCGg

看到这个加密方式我人傻了,这什么东西。试着解了一下,没戏。上网看了一下发现说可以修改admin的密码和添加admin用户,这里我们修改admin密码。

1.修改admin密码

我们要找到加密 文件,Drupal的加密文件在

/var/www/scripts/password-hash.sh

进入到里面看下

#!/usr/bin/php
<?php

/**
* Drupal hash script - to generate a hash from a plaintext password
*
* Check for your PHP interpreter - on Windows you'll probably have to
* replace line 1 with
* #!c:/program files/php/php.exe
*
* @param password1 [password2 [password3 ...]]
* Plain-text passwords in quotes (or with spaces backslash escaped).
*/

if (version_compare(PHP_VERSION, "5.2.0", "<")) {
$version = PHP_VERSION;
echo <<<EOF

ERROR: This script requires at least PHP version 5.2.0. You invoked it with
PHP version {$version}.
n
EOF;
exit;
}

$script = basename(array_shift($_SERVER['argv']));

if (in_array('--help', $_SERVER['argv']) || empty($_SERVER['argv'])) {
echo <<<EOF

Generate Drupal password hashes from the shell.

Usage: {$script} [OPTIONS] "<plan-text password>"
Example: {$script} "mynewpassword"

All arguments are long options.

--help Print this page.

--root <path>

Set the working directory for the script to the specified path.
To execute this script this has to be the root directory of your
Drupal installation, e.g. /home/www/foo/drupal (assuming Drupal
running on Unix). Use surrounding quotation marks on Windows.

"<password1>" ["<password2>" ["<password3>" ...]]

One or more plan-text passwords enclosed by double quotes. The
output hash may be manually entered into the {users}.pass field to
change a password via SQL to a known value.

To run this script without the --root argument invoke it from the root directory
of your Drupal installation as

./scripts/{$script}
n
EOF;
exit;
}

$passwords = array();

// Parse invocation arguments.
while ($param = array_shift($_SERVER['argv'])) {
switch ($param) {
case '--root':
// Change the working directory.
$path = array_shift($_SERVER['argv']);
if (is_dir($path)) {
chdir($path);
}
break;
default:
// Add a password to the list to be processed.
$passwords[] = $param;
break;
}
}

define('DRUPAL_ROOT', getcwd());

include_once DRUPAL_ROOT . '/includes/password.inc';
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';

foreach ($passwords as $password) {
print("npassword: $password tthash: ". user_hash_password($password) ."n");
}
print("n");

看到脚本是php写的,而且可以加参数运行,直接得到加密后的密码

VulnHubDC系列之DC1靶机

这里直接给它新增一个密码

password: 123456                hash: $S$DLa2QqvbUWtyOCn83OgOnjrRDOFdPE8PQ2HUntu7t51jsH0ZT6v1

VulnHubDC系列之DC1靶机

然后给他替换!等等不对哇,我这里为啥还要在这里加密嘞,我直接改不就可以了吗?

VulnHubDC系列之DC1靶机

疑惑,这里先这样改,出问题了在说。

然后使用我们的账户密码登录HTTP服务

VulnHubDC系列之DC1靶机

哎竟然登录不进来,看来前面要通过他那个编码方式加密才行

VulnHubDC系列之DC1靶机

修改之后成功进来了。看来还是这里校验了那个加密方式。

VulnHubDC系列之DC1靶机

成功找到flag3,这里说到passwd和shadow文件,看一下是干什么的。

/etc/passwd
该文件存储了系统用户的基本信息,所有用户都可以对其进行文件操作读
/etc/shadow
该文件存储了系统用户的密码等信息,只有root权限用户才能读取

VulnHubDC系列之DC1靶机

利用tac反向连接文件,发现有一个flag4用户,直接上hydra爆破用户(中间断开了一下,然后这里ip改变了)

VulnHubDC系列之DC1靶机

成果爆破出flag4的密码

VulnHubDC系列之DC1靶机

成功登录进来,看到flag4,好像没啥用

你能用同样的方法找到或访问 root 中的标志吗?也许可以。但也许没那么容易。又或许可以?

Linux提权

利用fiad命令找到具有suid权限的可执行的二进制文件

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

VulnHubDC系列之DC1靶机

find / -name index.php -exec "/bin/sh" ;
find可以执行root权限的命令找查文件

VulnHubDC系列之DC1靶机

提权成功

VulnHubDC系列之DC1靶机

在root目录下成功找到最后一个flag

原文始发于微信公众号(船山信安):VulnHubDC系列之DC1靶机

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年5月7日11:32:26
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   VulnHubDC系列之DC1靶机http://cn-sec.com/archives/2714202.html

发表评论

匿名网友 填写信息