Post

Swsctfjournal5

Topic: The Marketplace

The sysadmin of The Marketplace, Michael, has given you access to an internal server of his, so you can pentest the marketplace platform he and his team has been working on. He said it still has a few bugs he and his team need to iron out.

Can you take advantage of this and will you be able to gain root access on his server?

As always, spawn the machine and run a nmap scan.

alt text

Launch the browser and head to the IP address of the machine. The website is a marketplace platform. I can register and login to the platform.

alt text

Try logging in as admin.

alt text

User not found

alt text

See if sign up works with a new user work.

alt text

Returns a signed up succesfully message.

Now let me log in back with the same credentials.

And we get in.

I tried to create some new listings but realized they block tese type of requests but do not sanitize them. So I added an XSS script to see if it worked.

alt text

alt text

I noticed we can actually send listings to admins.

alt text

From what i saw in the hint box, I went onto PayloadsAlltheThings saw this payload.

alt text

alt text

I started a listener on mhy machine.

alt text

alt text

When i continued to report to admins, i got a response on my listener.

alt text

I copied the cookie and use a cookie editor and changed my current token.

With the admin token, i could go in /admin.

alt text

Upon clicking any one of the users, I saw that I could do a sql injection easily.

I tried appending ‘ at the back of the url.

alt text

I again tried, but this time with a union injection.

?user=-1 union select (user()),2,3,4 — -

alt text

Now to determine the database.

user=-1 union select (select group_concat(SCHEMA_NAME) from INFORMATION_SCHEMA.SCHEMATA),2,3,4 — -

alt text

To get the tables out.

user=-1 union select (select group_concat(TABLE_NAME) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = ‘marketplace’),2,3,4 — -

alt text

I noticed the messages table.

user=-1 union select group_concat(user_to, message_content), null, null, null from messages

alt text

alt text

I got the flag in user.txt by running cat.

Run sudo -l

alt text

Generate netcat reverse shell payload on my machine.

alt text

Inject payload into a script for backup.tar to run.

alt text

Once opened, change the permissions of the files and run it.

alt text

I get a shell on my listener.

alt text

Heading to GTFObins, I found the command to let us break out of the docker and give us a root shell.

alt text

I got in as root.

alt text

This post is licensed under CC BY 4.0 by the author.

Trending Tags