2. Examining the Database - VascoLucas01/SQL-Injection-stuff GitHub Wiki

Introduction

In this section I'll cover several topics:

  • Examining the database in SQL injection attacks
  • Querying the database type and version
  • Listing the contents of the database

At the end, in "EXTRA INFORMATION" section, I provided a cheat-sheet to consult some useful queries to use in order to perform SQLi.

Examining the database in SQL injection attacks

When leveraging SQL injection vulnerabilities, it becomes imperative to acquire specific information about the database. This information encompasses details such as the type and version of the database software, as well as the structure of the database, including its tables and columns.

Querying the database type and version

Various databases offer distinct methods for querying their version. Often, it requires experimentation with different queries to identify the one that successfully reveals both the type and version of the database software.

Below are the queries used to ascertain the database version for some commonly used database types:

imagem

Listing the contents of the database

The majority of database types (excluding Oracle) include a collection of views known as the information schema, which offers valuable insights into the database.

By executing a query on information_schema.tables, you can obtain a list of all the tables present in the database.

imagem

It is also possible to query information_schema.columns.

Equivalent to information schema on Oracle

On Oracle, you can obtain the same information with slightly different queries.

You can list tables by querying all_tables:

imagem

Extra Information

cheat-sheet