Objective 6: Badge Manipulation

Objective 6 we need to bypass the authentication mechanism associated with the room near Pepper Minstix. A sample employee badge is available. What is the access control number revealed by the door authentication panel?

If we have already completed the Yule Log Analysis Cranberry Pi terminal challenge by Pepper Minstix, then we get this hint.
“All of the Kringle Castle employees have these cool cards with QR codes on them that give us access to restricted areas.
Unfortunately, the badge-scan-o-Matic said my account was disabled when I tried scanning my badge.
I needed access, so I tried scanning several QR codes I made from my phone, but the scanner kept saying “User Not Found”.
I researched a SQL database error from scanning a QR code with special characters in it and found it may contain an injection vulnerability.
I was going to try some variations I found on OWASP but decided to stop, so I don’t tick-off Alabaster.”

Also, this hint link.
As well as this link to create a QR code.

So, we need to unlock this door, and we have already had a sample of an employee badge. Of a very umm, sexy? Elif it seems.

When we try to access the door, we see with this screen.

Let’s see what happens when we try to use the sample badge, and it only takes .png files!

So let’s open it in the paint (or you can use anything else) and save it as a .png file. Now we get.

“Authorized User Account Has Been Disabled!” Dammm!
What if we use the Finger.

Nope, now we get “QR Code Not Found. Only QR Code and White Space may be visible!”

If we were to run inspector mode within Firefox as we upload the same file again, we see a new record “upload”, and in the Params, we can look at some data… I guess it’s time for Burp Suite!

Also, this is what we get if we use the finger method.

However, before we can use Burp Suite, we need to find a way on how to better access the Badge Scan-O-Matic 4000.
Within Firefox inspector mode we can see there is a direct URL (Just like in Objective 3 De Bruijn Sequences)

Ah, so much better!

So, from the hints, it’s all aiming towards an SQLI (SQL injection), and the URL doesn’t give much here, “https://scanomatic.kringlecastle.com/index.html?challenge=qrcode” So, it has to be something with the Badge Scan-O-Matic 4000!
Sending the .png again but with Burp Suite open, we can see this.

Let’s tidy this up, as we don’t need the PNG data here.

Much better! Now, we need to get a successful SQLI working………
Right, so the Scan-O-Matic 4000, accepts QR codes in PNG and reads them… There is no SQLI within the URL itself, so it’s within the Scan-O-Matic 4000 itself, And we get a link on creating our barcodes… I wonder what would happen if I was to make one with just the (‘) inside of it, and then uploaded it.

Moreover, we have a successful SQLI!

 "{"data":"EXCEPTION AT (LINE 96 \"user_info = query(\"SELECT first_name,last_name,enabled FROM employees WHERE authorized = 1 AND uid = '{}' LIMIT 1\".format(uid))\"): (1064, u\"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '''' LIMIT 1' at line 1\")","request":false}" 

Let’s look at this “error” more clearly “SELECT first_name,last_name,enabled FROM employees WHERE authorized = 1 AND uid = ‘{}’ LIMIT 1” The injection point is here (AND uid = ‘{}’).
So the server will normally run this SQL query “SELECT first_name,last_name,enabled FROM employees WHERE authorized = 1 AND uid = ‘{}’ LIMIT 1”
let’s change this and inject (‘ OR enabled#) Then the server runs the query like this “SELECT first_name,last_name,enabled FROM employees WHERE authorized = 1 AND uid = ‘ OR enabled#’ LIMIT 1”
Why will this work? Well in most common programming languages the # is read as a comment, and the server/computer not run anything after the #. It’s mainly for users to read what others have done, or what needs to get done.
So now the server reads it as “SELECT first_name,last_name,enabled FROM employees WHERE authorized = 1 AND uid = ” OR enabled”(Like the # and anything after that won’t be read by the computer).
Which will now authorized “authorized = 1” and enabled the user “uid = ” OR enabled)

Now we know what to do, we need to create another QR code PNG and get our answer!

Moreover, We got our Control number 19880715!

 ({"data":"User Access Granted - Control number 19880715","request":true,"success":{"hash":"ff60055a84873cd7d75ce86cfaebd971ab90c86ff72d976ede0f5f04795e99eb","resourceId":"false"})) 

Another one down!

Also, look whom we find here!

Leave a Comment

Your email address will not be published. Required fields are marked *