Lab: SQL injection attack, listing the database contents on non-Oracle databases

Joel O.Joel O.
3 min read

In this educational guide, we will explore the practical application of Burp Suite to identify and exploit SQL injection vulnerabilities, highlighting the importance of robust security practices.

Step 1: Intercepting and Modifying Requests with Burp Suite

Burp Suite serves as a powerful ally in identifying and mitigating security risks. Start by configuring your browser to route traffic through Burp Proxy, enabling the interception of HTTP requests. Navigate to the target web application, and as you interact with it, Burp Suite will capture the relevant requests in the proxy.

Identify the request responsible for setting the product category filter, and use Burp Suite to intercept and modify this specific request.

Step 2: Determining the Number of Columns

Inject the following payload into the category parameter to determine the number of columns returned by the query and identify which columns contain text data:

plaintextCopy code'+UNION+SELECT+'abc','def'--

Inspect the application's response to verify that the query is returning two columns, both of which contain text. This step confirms the existence of a potential SQL injection vulnerability in the product category filter.

Step 3: Retrieving the List of Tables in the Database

Now that we have identified a potential vulnerability, proceed to retrieve the list of tables in the database using the following payload:

plaintextCopy code'+UNION+SELECT+table_name,+NULL+FROM+information_schema.tables--

Inspect the response to obtain a list of tables in the database. Locate the table that likely contains user credentials.

Step 4: Retrieving Details of Columns in the User Credentials Table

Once the user credentials table is identified, use the following payload to retrieve details of the columns in that table (replace 'users_abcdef' with the actual table name):

plaintextCopy code'+UNION+SELECT+column_name,+NULL+FROM+information_schema.columns+WHERE+table_name='users_abcdef'--

Inspect the response to find the names of columns containing usernames and passwords.

Step 5: Retrieving Usernames and Passwords

With knowledge of the table and column names, use the following payload to retrieve usernames and passwords for all users (replace 'users_abcdef', 'username_abcdef', and 'password_abcdef' with the actual table and column names):

plaintextCopy code'+UNION+SELECT+username_abcdef,+password_abcdef+FROM+users_abcdef--

Inspect the response to retrieve the usernames and hashed passwords for all users.

Step 6: Finding the Administrator's Password

Identify the administrator user and retrieve their hashed password. Utilize secure password-cracking techniques or rainbow tables to obtain the plaintext password.

Step 7: Logging in as Administrator

Use the obtained password to log in as the administrator, emphasizing the critical importance of promptly addressing and patching SQL injection vulnerabilities to protect user data and prevent unauthorized access.

Conclusion

By actively engaging with Burp Suite and understanding the mechanics of SQL injection, security professionals and developers can enhance the security posture of web applications. Regular security assessments, coupled with secure coding practices, are essential in safeguarding sensitive information and maintaining the trust of users in an increasingly connected world.

Reference:

https://portswigger.net/web-security/sql-injection

https://portswigger.net/web-security/sql-injection/examining-the-database/lab-listing-database-contents-non-oracle

7
Subscribe to my newsletter

Read articles from Joel O. directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Joel O.
Joel O.

A passionate cybersecurity enthusiast and cloud aficionado. I am on a mission to unravel the complexities of the ever-evolving cyber landscape and guide you through the vast expanse of cloud technology. As a cybersecurity professional, I bring a wealth of experience in securing digital ecosystems and defending against cyber threats. My journey in the cloud realm has been both thrilling and enlightening, and I am here to share my insights, discoveries, and practical tips with you. In these virtual pages, expect a fusion of in-depth cybersecurity analyses and explorations into the limitless possibilities of cloud computing and cybersecurity. Whether you're a seasoned cybersecurity professional, a cloud enthusiast, or someone just stepping into the digital frontier, there's something here for you.