Under Construction
Last updated
Last updated
A company that specializes in web development is creating a new site that is currently under construction. Can you obtain the flag?
Downloaded File:
Zip Password:
Zip Hash:
I ran a quick nmap scan of the instance to see if that would reveal anything else.
Looks like it is a web server running Node.js Express framework.
Run a quick gobuster scan to see if we can locate any other directories.
The only new one it found was the /logout
which just redirects to the /auth
page.
Start with checking out the URL:
Checking out the source code:
Looks like we have a typical log in form. There is also some script language at the bottom which compares hash data to ensure the integrity of the information being loaded.
Trying a test of admin:admin
in the login produces the following:
The URL also has changed with these parameters:
Some interesting information from Wappalyzer:
I grabbed a login attempt with Burpsuite to see if that revealed anything:
Let's try to "Register" a new user with the credentials testaccount:password123
Now I will try to login in with those credentials.
Looks like it took us to the index.html
page we have in the files.
Note: if I try to register the same username it tells me the account already exists. Let's use this to see if we can get an actual username.
I tried a bunch of credentials and found the following already exist:
user:user
The others I tried that didn't work (but are now registered are):
administrator
admin
root
guest
username
Start with the files provided from the zip.
I started with the index.thml
It mainly looks like the beginning of home page for a website which makes sense based on the naming.
Taking a look at it by opening the file in browser shows something similar
Let's take a look at the auth.html
file. This just looks like the source code to the URL we were given. This makes sense as the names match up.
Let's check it out on a browser. Looks a bit rougher and it also looks like it displays some of the backend code.
It's possible this is vulnerable to XSS due to the query.error
value is not properly sanitized before being included in the HTML response.
We could try to plugin a quick test script to the URL to see if it does an alert:
Unfortunately, it looks like it is getting sanitized on the server side and is being returned as a string. It actually looks like this may not be the final code utilized for the site which means that it may have been corrected.
Next, we are going to look at the package.json
. This is a package file for Node.js which includes metadata as well as dependencies to run Node.js.
I'm next looking at the index.js
. This is a Node.js script that creates a web application using the express framework. Nothing to note that I can tell.
DBHelper.js
, is a Node.js module that exports several functions for working with a SQLite database.
This is used to get usernames, check usernames, and create new usernames.
It may be possible that this is vulnerable to SQLI.
I can try inputting the following into the username field to see if it is vulnerable.
This doesn't seem to work though so it's probably being filtered on the server's side.
JWTHelper.js
, is a Node.js module using two functions to sign and decode json web token.
AuthMiddleware.js
, This is a middleware function for a Node.js web application that verifies the authenticity of a JSON Web Token (JWT) stored in a cookie, and adds the decoded payload data to the req
object for later use.
I had to look at a walkthrough for this one. It looks like this has to do with the JWT web tokens.
This web app is vulnerable to JWT Confusion or CVE-2015-9235.
I first start by logging into web page with the credentials user:user
(I validated these credentials exist above) and capture the response on Burpsuite. I could also just look this up in the developer's tools of the browser.
Above is the session cookie. We can tell it is a JWT token because it starts with ey
and is separated into three sections with a .
.
We can use a tool called jwt.io to analyze the JWT.
It looks like it is actually able to get a Public Key from this.
I reformatted the public key and removed all of the /n
in it.
Let's create a new file called key
and plug it in there.
With that I'm going to try to use a tool called RsaCtfTool to gain a private key from it.
I don't think I need to do this as my computer took a really long time to try to decrypt this.
How these tokens work is that when a user goes to get information from the page, it is encrypted using a private key and the token is sent to the user. This token then needs to be verified and we need to ensure the token is verified. We can use the same web app to do this by plugging the formatted public key into the box for it. It will then show that it is verified.
I can take the formatted public key and plug it back into the web application to see If I can verify the token.
This will be a two-part attack.
We need to first get the web server to verify the JWT.
From our previous exploration, we can then do a SQLI on the login page. This is why this did not work originally.
We can use this tool to modify the JWT. In the directory that you download the tool run the following:
This will analyze the JWT similar to the web app but can also modify it as well.
Let's start by using BurpSuite to capture a packet after signing in (Has the JWT) and send it to the Repeater.
We'll use this to try multiple attempts on the SQLI.
I had to use another guide as the previous one got me a little lost.
I then used the jwt_tool.py
to create a payload of the JWT with the SQLI.
This did not work but does show the SQLI was uploaded and returned values.
I need to do some work on learning SQLI. I wish I could say I fully understood the route to get to the SQLI command but I don't. I will look for a lab to brush up on this.
Long story short, I was able to get the following SQLI payload to work.
Using this we will plug it into the JWT_Tool to create a JWT token with the payload and submit it through burpsuite.
Now take that JWT and plug it into the Burpsuite repeater. Send the request and check the response. You'll see that is has now returned the Flag.
The flag is:
Conclusion: I need to work on SQLI as that is really the only part I got lost on.