Sitemap

Ready — HackTheBox Write-up (L-M)

4 min readApr 19, 2021
Press enter or click to view image in full size

Reconnaissance

Press enter or click to view image in full size

Looking at http://10.10.10.220:5080, we could see that this is a self hosted instance of Gitlab Community Edition

Press enter or click to view image in full size

I ran a enumeration using dirbuster and found the following directories

Press enter or click to view image in full size

As seen also during the NMAP scan, the robots.txt file of the site contains a lot of directories

# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-Agent: *
# Disallow: /
# Add a 1 second delay between successive requests to the same server, limits resources used by crawler
# Only some crawlers respect this setting, e.g. Googlebot does not
# Crawl-delay: 1
# Based on details in https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/routes.rb, https://gitlab.com/gitlab-org/gitlab-ce/blob/master/spec/routing, and using application
User-Agent: *
Disallow: /autocomplete/users
Disallow: /search
Disallow: /api
Disallow: /admin
Disallow: /profile
Disallow: /dashboard
Disallow: /projects/new
Disallow: /groups/new
Disallow: /groups/*/edit
Disallow: /users
Disallow: /help
# Only specifically allow the Sign In page to avoid very ugly search results
Allow: /users/sign_in
# Global snippets
User-Agent: *
Disallow: /s/
Disallow: /snippets/new
Disallow: /snippets/*/edit
Disallow: /snippets/*/raw
# Project details
User-Agent: *
Disallow: /*/*.git
Disallow: /*/*/fork/new
Disallow: /*/*/repository/archive*
Disallow: /*/*/activity
Disallow: /*/*/new
Disallow: /*/*/edit
Disallow: /*/*/raw
Disallow: /*/*/blame
Disallow: /*/*/commits/*/*
Disallow: /*/*/commit/*.patch
Disallow: /*/*/commit/*.diff
Disallow: /*/*/compare
Disallow: /*/*/branches/new
Disallow: /*/*/tags/new
Disallow: /*/*/network
Disallow: /*/*/graphs
Disallow: /*/*/milestones/new
Disallow: /*/*/milestones/*/edit
Disallow: /*/*/issues/new
Disallow: /*/*/issues/*/edit
Disallow: /*/*/merge_requests/new
Disallow: /*/*/merge_requests/*.patch
Disallow: /*/*/merge_requests/*.diff
Disallow: /*/*/merge_requests/*/edit
Disallow: /*/*/merge_requests/*/diffs
Disallow: /*/*/project_members/import
Disallow: /*/*/labels/new
Disallow: /*/*/labels/*/edit
Disallow: /*/*/wikis/*/edit
Disallow: /*/*/snippets/new
Disallow: /*/*/snippets/*/edit
Disallow: /*/*/snippets/*/raw
Disallow: /*/*/deploy_keys
Disallow: /*/*/hooks
Disallow: /*/*/services
Disallow: /*/*/protected_branches
Disallow: /*/*/uploads/

Most of the directories are inaccessible and requires an account. So I created one just to see more information about this gitlab instance.

Press enter or click to view image in full size

Initial Foothold and User Flag

A quick search on google would tell you that this version of GitLab CE is vulnerable to remote code execution. Git and ExploitDB reference.

Press enter or click to view image in full size

It worked!

Since we have established a connection, we can looking for the user flag

Privilege Escalation

We need to stabilize our shell first before we do anything. There are lot of ways but my go to is via python

sudo -l is not working so I don’t know the privilege and allowed commands for the user git. I’m sure that there are other ways but I don’t know.

Enumeration some more, I found gitlab.rb. It’s a config file.

Press enter or click to view image in full size

And it contains a password

Press enter or click to view image in full size
gitlab_rails[‘smtp_password’] = “wW59U!ZKMbG9+*#h”

It works on root user!

Root Flag

Since we’re now a root user. It’s just a matter of finding the root.txt file

--

--

No responses yet