Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Web4: SQL Injection - Exploitation Steps

Learn about Sql Injection, including 1. Detection, key uses, practical steps, common issues, and answers to frequently asked questions.

Table of Contents

1. Detection

This guide provides a clear overview of sql injection, including 1. Detection, 2. Collecting Information About the Database Management System. Use it to understand the topic, compare the available options, and make a more informed decision.

2. Collecting Information About the Database Management System

When detecting an application that has SQL injection errors, the next job to do is to collect information about the database management system that the application is using, this information includes the type of database (mysql, mssql, oracle.) and its version.

To determine the type of administration that the application is using, we can evaluate it according to many criteria. Judging by the error message:

2. Collecting Information About the Database Management System - Sql Injection

Error message from MS-SQL – IIS

2. Collecting Information About the Database Management System - Sql Injection

In the case above, the error message says that the web application uses MySQL.

3. Specify the Number of Columns in the Select. Clause

When exploiting SQL injection, we often use one or more subselect clauses, this is done via the union keyword. Union is the keyword used to combine the results of many select clauses, so in each select clause, the number of fields must be equal and equal to the number of fields selected in the original select clause. Consider a specific example:

3. Specify the Number of Columns in the Select. Clause - Sql Injection

Here, in the initial select clause, select 3 fields: id, content and author. Therefore the select clause after the union keyword also needs to have exactly 3 fields. If the number of select fields in the select clause after the union is not equal to the number of fields selected in the first select clause, we will get an error message. So how to know exactly how many fields the first select clause selects. We can do a trial by incrementing the number of columns in the select clause after the union (starting at 1). When no error message appears, that is the number of columns to look for.

Another, faster way to do this is to use 'order by'. In DBMS the keyword 'order by' is used to sort the order of the records obtained in the select clause. After order by can be a column name to specify that the result will be sorted by the value of that column (can be ascending or descending). After order by can also be the ordinal number of that column. If the value after order is greater than the number of columns selected, we will see an error message.

4. Identify Information

After getting the basic information, we will proceed to exploit SQL injection to get the database or perform other behaviors through this vulnerability.

Specify table and column names: we have many ways to do this, one of them is 'guess' because it is fast and in specific cases this is very useful. For example, some common table names such as: user, users, admin, administrator, staff, account, manager. (note the prefix tbl_ is very often used by programmers to name the table).

A more formal way to know the table and column names is to use the information_schema object. This object provides information about the tables, columns, views and procedures. of the database.

Conclusion

Understanding Sql Injection makes it easier to compare options, avoid common mistakes, and apply the information in this guide more effectively. Review the relevant requirements before making changes or choosing a solution.

FAQ

What is Sql Injection?

To determine the type of administration that the application is using, we can evaluate it according to many criteria.

Why is Sql Injection important?

Understanding Sql Injection helps you evaluate features, compatibility, performance, and potential limitations before you choose a product or follow a procedure.

What should you consider when using or choosing Sql Injection?

Consider your specific goal, compatibility requirements, available features, cost, security, and the practical recommendations described in this guide.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.