Alternatively this box gives us the ip address we need to scan for nmap , however it's not common that vulhub boxes have a banner to give local ip address when they bootup.
<imgsrc="https://imgur.com/ruFBezk.png"/>
## NMAP
Now that we have the IP address of our target let's run nmap scan on it
|_ Project type: PHP application (guessed from .gitignore)
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Corp - DevGuru
MAC Address: 08:00:27:C2:2E:66 (Oracle VirtualBox virtual NIC)
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 13.61 seconds
```
So from the nmap scan we have 2 ports http and ssh but we see something intersting which `.git/` also we see a domain name `devguru.local`. Add the domain to `/etc/hosts`
<imgsrc="https://imgur.com/4cGfA58.png"/>
<imgsrc="https://imgur.com/Rt5p5UR.png"/>
On going to `register` tab we won't be able to register any user also we haven't found any creds.
<imgsrc="https://imgur.com/oHgxDf5.png"/>
On port 80 we can also see a home page with clicking on the tabs pretty much doesn't do anything
<imgsrc="https://imgur.com/UdhpGQU.png"/>
So I tried ruuning gobuster and found something interesting
<imgsrc="https://imgur.com/AxkMwmb.png"/>
<imgsrc="https://imgur.com/XMYfJ1y.png"/>
But it's the same thing we need credentials.
I did try to find some exploits for `gitea` and `october` but end up failing so the next thing we can do is try to dump the git repository that we saw from the nmap scan.To dump the git repository what you need is called GitTools , really an awesome tool
`https://github.com/internetwache/GitTools`
<imgsrc="https://imgur.com/Jf8YhjE.png"/>
This script is going to download whatever it can from the repository.
<imgsrc="https://imgur.com/X24yjss.png"/>
When it finishes it will look something like this
<imgsrc="https://imgur.com/myHKpaI.png"/>
<imgsrc="https://imgur.com/XNe3OSF.png"/>
Going through `objects` folder you'll find bunch of directories and you won't understand how would you read it so another script of extracting useful files from `.git` is called `Extractor` which comes with `GitTools`
<imgsrc="https://imgur.com/nn9KMFV.png"/>
As you can see it will extract all the files we'll need so you definitely want to have it in your arsenal when it comes to dealing with `.git` on the webserver
<imgsrc="https://imgur.com/79tIOWm.png"/>
<imgsrc="https://imgur.com/rkuLmuZ.png"/>
Now two files that you want to look at ,first `adminer.php` which is database management tool means there's a databse which is connected to web application also in `config` folder you'll find `database.php` in which you can get credentials for logging into the database
<imgsrc="https://imgur.com/RpcLZ62.png"/>
<imgsrc="https://imgur.com/FBGzWYp.png"/>
<imgsrc="https://imgur.com/E2fuSWE.png"/>
Now we are logged in and we can pretty much do everything with the database so let's try creating a new user in the database or we can just clone the `frank` user but here we have to specify the password in that hash which is `bcrypt` seeing identifying it as it is starting from `$2$`
Goto `cyberchef` or any other website from which you can generate a text to bcrypt hash and add it in the password field
<imgsrc="https://imgur.com/xEAStaA.png"/>
<imgsrc="https://imgur.com/nJG03cp.png"/>
<imgsrc="https://imgur.com/fuF2FRk.png"/>
Now we have added a new user and we should be able to login to the page we found through `gobuster`
<imgsrc="https://imgur.com/FC2sUxX.png"/>
In order to get a shell from the october cms there something we can do is run php code inside html page but it's a little different.
Through goolging around a little I was able to find a forum where people asked about this thing and got several answers but the code that worked for me was
<imgsrc="https://imgur.com/xlofAzs.png"/>
So let's try testing if this actually works
<imgsrc="https://imgur.com/weWym8c.png"/>
<imgsrc="https://imgur.com/qaJC62U.png"/>
This works so now we just have to setup a GET parameter in the code and run system commands
<imgsrc="https://imgur.com/wbN92tc.png"/>
<imgsrc="https://imgur.com/mTTcV5c.png"/>
We are almost just there (not really it is a real pain), just need a reverse shell.
By going through it explained we can get `remote code execution` if we have an administrator account on `gitea` because we need to have `githooks` to be enabled which is just a script that runs automatically whenever an event occurs on github repository. So what we are going to do is
1. Create a repository (doesn't matter if it's empty)
2. Go to settings of the repository , githooks , click on update then add a reverse shell
3. Clone the repository
4. Add a file to the repository
5. Commit
6. Push
<imgsrc="https://imgur.com/q8vnYmY.png"/>
<imgsrc="https://imgur.com/QWfOLok.png"/>
<imgsrc="https://imgur.com/SAlRS1q.png"/>
<imgsrc="https://imgur.com/vlcqvrH.png"/>
<imgsrc="https://imgur.com/saEKeue.png"/>
<imgsrc="https://imgur.com/CFuHZLz.png"/>
And now if we go to our netcat listener , we will have a shell as `frank`
<imgsrc="https://imgur.com/yNiz4YN.png"/>
<imgsrc="https://imgur.com/gfTmCks.png"/>
<imgsrc="https://imgur.com/4MBiuur.png"/>
Going throguh man pages of `sudoers` it says that we can run this can be ran as any user but not as `root`.
<imgsrc="https://imgur.com/kbZNTkr.png"/>
Now a vulnerability exists in this scenario when a user is allowed to execute command as other users but not as root so when specifiy a user with `-u` and user id with `-1` it's going to consider is a `root` with id `0`
So this was a really an intersting box that we had to dump the git repository then look for important files after that got our intial foothold as `www-data` through that looked for some configuration files ,edit database ,add repository then pushed our changes into it did learned a lot from this ,it was my first vulnhub machine that I rooted !!!