SQL injection attack, querying the database type and version on MySQL and Microsoft writeup

Descripción

This lab contains a SQL injection vulnerability in the product category filter. You can use a UNION attack to retrieve the results from an injected query.

To solve the lab, display the database version string.

SQL injection attack, querying the database type and version on MySQL and Microsoft writeup

Este laboratorio deberemos de resolverlo en cuatro pasos:

Encontrar la petición vulnerable a SQL injection:

Accedemos al laboratorio y capturamos un filtrado de productos con el ‘Logger’ de Burp Suite:

Enviamos esta petición al ‘Repeater’ con Ctrl + R o Click derecho -> Send to Repeater. Ahí podremos trabajar.

Determinar el número de columnas que devuelve la petición

Para ello usaremos la técnica del laboratorio SQL injection UNION attack, determining the number of columns returned by the query. La petición será la siguiente:

GET /filter?category=Pets'+UNION+SELECT+NULL,+NULL# HTTP/2

Nota: En este caso el comentario de línea es ‘#’.

La petición devuelve 2 columnas:

Determinar qué columna devuelve texto

Debido a que queremos obtener la versión (texto), tendremos que realizar un UNION attack con otra columna que devuelva texto. Para ello usaremos el código explicado en el laboratorio SQL injection UNION attack, finding a column containing text. La petición será la siguiente:

GET /filter?category=Pets'+UNION+SELECT+NULL,+'test'# HTTP/2

En este caso la columna que devuelve texto es la segunda.

Obtener la versión de la base de datos

Cambiaremos el código por el siguiente:

GET /filter?category=Pets'+UNION+SELECT+NULL,+@@version# HTTP/2

Obtendremos la siguiente información:

Y completaremos el laboratorio:

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *