# 6379 - Redis

## ¿Qué es y cómo funciona?

Redis es un motor de base de datos en memoria, basado en el almacenamiento en tablas de hashes pero que opcionalmente puede ser usada como una base de datos durable o persistente. Está escrito en ANSI C por Salvatore Sanfilippo, quien es patrocinado por Redis Labs

## Enumeración

```
nc -vn <IP> <port> # conectarnos mediante netcat
redis-cli -h <IP> # mediante el cliente de redis
```

### Comandos redis-cli

#### Autenticar nos

Por defecto en redis se puede acceder sin credenciales pero obviamente habrá veces que tendremos credenciales, se haría con el comando de abajo pero el espacio es un + `AUTH user+password` .&#x20;

Normalmente la password la podríamos encontrar en el archivo redis.conf como "requirepass" y el usuario por defecto es `default`. Y el usuario puede estar en la variable "masteruser"

```
AUTH <username> <password>
```

#### Comandos autenticados

```
SELECT 0
[ ... Indicate the database ... ]
KEYS * 
[ ... Get Keys ... ]
GET <KEY>
[ ... Get Key ... ]
```

**Ejemplo**

En este caso el SELECT 0 tiene 4 keys en la bbdd 0 pero podría ser que fuera la 1 en otra ocasión, por defecto redis utiliza la 0.

![](/files/kCcaxiIeJzZ06eRGNIDR)

#### Type

Depende del tipo de KEY se tiene que poner TYPE para saber si son un key, una lista o un hash, hay diferentes maneras de abrir dependiendo de el tipo.

```
TYPE <KEY>
[ ... Type of the Key ... ]
LRANGE <KEY> 0 -1
[ ... Get list items ... ]
HGET <KEY> <FIELD>
[ ... Get hash item ... ]
```

**Ejemplo**

Para listar las KEYS.

![](/files/07P0s3T7NQYODWPdYtJl)

Eso sale por que es una lista, y no se puede ver con GET, sino con `lrange <key> 0 -1`

<figure><img src="/files/J7GIjZhcvdRXjduvUQb9" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://j4ckie0x17.gitbook.io/notes-pentesting/enumeracion-de-servicios/6379-redis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
