0
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.

HackTheBox MonitorsTwo Writeup

Posted at

はじめに

本記事は「HackTheBox:MonitorsTwo」のwriteupです。

問題

リバースシェルに関する問題です。

回答

ポートスキャンします。
結果ssh(tcp/22)http(tcp/80)が公開されていることがわかりました。

┌──(kali㉿kali)-[~]
└─$ nmap -sV -p- --min-rate 5000 10.10.11.211                   
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-30 20:58 JST
Warning: 10.10.11.211 giving up on port because retransmission cap hit (10).
Nmap scan report for 10.10.11.211
Host is up (0.17s latency).
Not shown: 60331 closed tcp ports (conn-refused), 5202 filtered tcp ports (no-response)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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

ブラウザからhttpでアクセスするとサイトが表示されました。

1.png

サイトを探索するとthetoppers.htbというドメインが見つかります。
/etc/hostsにこのドメインとIPアドレスの紐付けを追記します。

以下余談

ffufを使用し、サブドメインを探します。
例えば以下のコマンドを実行するとwordlistに記載された文字列がFUZZ部分に置換されて、リクエストをしてくれます。

ffuf -w /usr/share/wordlists/wfuzz/general/common.txt -u http://10.129.50.135 -H "Host: FUZZ.thetoppers.htb"

メタですが解答欄のプレースホルダーは**.thetoppers.htbで、サードレベルドメインは2文字です。
wordlistは2文字の総当たりができるものを作成、使用した方がよさそうです。
kaliにはcrunchコマンドというパスワードリストを生成するコマンドがあります。

例えば以下のコマンドを実行すると1字のアルファベットすべてから3字のアルファベットすべてのパターンで生成します。

crunch 1 3

今回は2文字の英数字でwordlistを作成しました。

┌──(kali㉿kali)-[~]
└─$ crunch 2 2 0123456789abcdefghijklmnopqrstuvwxyz -o third_domain.txt
Crunch will now generate the following amount of data: 3888 bytes
0 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 1296 

crunch: 100% completed generating output

色々出力されましたが、目ぼしい情報をに見つけることができませんでした。

┌──(kali㉿kali)-[~]
└─$ ffuf -w third_domain.txt -u http://10.129.50.135 -H "Host: FUZZ.thetoppers.htb"          

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.0.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://10.129.50.135
 :: Wordlist         : FUZZ: /home/kali/third_domain.txt
 :: Header           : Host: FUZZ.thetoppers.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200,204,301,302,307,401,403,405,500
________________________________________________

[Status: 200, Size: 11952, Words: 1832, Lines: 235, Duration: 431ms]
    * FUZZ: 0o
.
.
.

余談終わり

gobusterにはvhostを探索する機能があり、こちらを使用してみます。指定するwordlistはこちらからダウンロードして使用しました。

--append-domainをつけないと-uに指定したURLの末尾?に指定した形で検索してしまうため、目的のものを見つけることができませんでした。
結果s3.thetoppers.htbというそれらしいサブドメインを見つけることができました。

┌──(kali㉿kali)-[/usr/share/seclists/discovery/dns]
└─$ gobuster vhost -w /usr/share/seclists/discovery/dns/subdomains-top1million-5000.txt -u http://thetoppers.htb --append-domain
===============================================================
Gobuster v3.5
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:             http://thetoppers.htb
[+] Method:          GET
[+] Threads:         10
[+] Wordlist:        /usr/share/seclists/discovery/dns/subdomains-top1million-5000.txt
[+] User Agent:      gobuster/3.5
[+] Timeout:         10s
[+] Append Domain:   true
===============================================================
2023/04/30 17:09:24 Starting gobuster in VHOST enumeration mode
===============================================================
Found: s3.thetoppers.htb Status: 404 [Size: 21]
Found: gc._msdcs.thetoppers.htb Status: 400 [Size: 306]
Progress: 4978 / 4990 (99.76%)
===============================================================
2023/04/30 17:10:59 Finished
===============================================================

/etc/hostss3.thetoppers.htbとIPアドレスの紐付けを追記します。

試しにブラウザでs3.thetoppers.htbにアクセスするとJson形式のレスポンスが表示されました。

2.png

S3へのアクセスにはAWS CLIを使用します。

┌──(kali㉿kali)-[/usr/share/seclists/discovery/dns]
└─$ aws --version
aws-cli/2.9.19 Python/3.11.2 Linux/6.1.0-kali5-amd64 source/x86_64.kali.2023 prompt/off

aws configureでアクセスキーなどを入力します。値は適当で良いです。

┌──(kali㉿kali)-[/usr/share/seclists/discovery/dns]
└─$ aws configure                                
AWS Access Key ID [None]: hoge
AWS Secret Access Key [None]: hoge
Default region name [None]: hoge
Default output format [None]: hoge

aws s3 lsでS3バケットの一覧を取得できます。
また、--endpoint-urlにリクエストを送信するURLを指定します。
結果thetoppers.htbというS3バケットがあることがわかりました。

┌──(kali㉿kali)-[/usr/share/seclists/discovery/dns]
└─$ aws --endpoint-url=http://s3.thetoppers.htb s3 ls
2023-04-30 14:54:37 thetoppers.htb

次にバケットに何が保存されているか確認します。
aws --endpoint-url=<エンドポイントURL> s3 ls s3://<S3バケット名>でS3バケット直下に保存されているオブジェクトの一覧を取得できます。

┌──(kali㉿kali)-[/usr/share/seclists/discovery/dns]
└─$ aws --endpoint-url=http://s3.thetoppers.htb s3 ls s3://thetoppers.htb
                           PRE images/
2023-04-30 14:54:37          0 .htaccess
2023-04-30 14:54:37      11952 index.php

ここから先はWalkthroughを見ながらなんとかやりました。

やっていることはリバースシェルです。
以下の記事を読むことで何をしているか理解できました。

ncコマンドに指定しているオプションについては以下を参照。

php-reverse-shell.phpも使えそう

参考

0
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
0
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?