Blind SQL Exploit
Upping the ante. A blind SQL exploit for CVE-2024-40502.

OH look a Hospital Management web application. It would be a shameβ¦ if someoneβ¦ Dumped the user databaseβ¦. And thatβs exactly what we gonna do.

Hospital Management Login Page
We know the username and password fields are SQL injectable
We can login into any user account we want by entering {username}'--
That is boring lets dump the user tables using a white box approach
Database Structure

User Table Structure

Proof of Concept
Now when we successfully login with our SQL injection payload, there is nothing rendered in HTML from the database. Sad. That would have made this entire process too trivial though. Blind SQL injection it is!
Lets craft a blind sql injection query using our knowledge of the database structure to 1 by 1 enumerate each character in the first row of the username 'Uname' field. Starting simple with 1 character, it looks something like this:
Enter Burpsuite
Lets Use Burp to speed up our testing phase:

I dropped our payload in the 'ctl00%24ContentPlaceHolder1%24txt_login_username' parameter. Again we are testing the 1st position character of the Username field which we know to be true for the character 'j'. Take a look at the response time 12,062 milli seconds, that looks about right. Just to be sure lets test with a character that will result in false in order to not trigger our delay.

Wow 5 milli seconds, thatβs a substantial difference and thatβs good enough for me.
Now lets do our due dillegnece and ensure our code works for the second string position, all we need to do is alter the substring function in our sql query like so:
I'll spare you the details it worked, can you say wahoo.
Now obviously I'm not gonna sit here like some chump and test each character one by one. We're script kiddies lets live up to our names and script this ish.
Enter Python
Starting out simple for a proof of concept lets automate the first char:
Output:

Our POC script is looking promising. We know the first character in the first user name is 'j' and we can see that reflected in the response time.
Enter Final Exploit
Alright code happened here's a revised script we can use to enumerate the entire database, at least the parts I care about. Username and Password. Boy oh boy running this on IIS express through visual studio was a pain in the ass given how slow it is compared to a real server. I tried beefing up this script with multi threading to speed up the process. I would hope it runs faster testing against a real server. I was able to enumerate the 1st row in about 5 minutes ish. Also don't freak I modded the db a bit to speed up this process for my proof of concept. This still works on more complex credentials. Enuf chit chat here's the good stuff.
(Oh yeah, I added some edgy ascii art and a cool name cause why not)
Output:
(That ascii art lookin pretty cool now huh?)

Last updated