githubEdit

Redis Pentesting

Redis is the In-Memory NoSQL Database. A default port is 6379.

Enumeration

nmap --script redis-info -p 6379 <target-ip>
nmap --script redis-brute -p 6379 <target-ip>

msf> use auxiliary/scanner/redis/redis_server

Check Config File

If we have access to target system, find the configuration file then we may be able to get passwords.

find / -name "redis.conf" 2>/dev/null
grep -i pass /path/to/redis.conf

If we get the line with password written as below,

requirepass "password"

We can set the password in a redis client.

> auth "password"

Connect

redis-cli -h <target-ip> -p 6379
# with password
redis-cli -h <target-ip> -p 6379 -a password

# using socket
redis-cli -s /path/to/redis.sock

After connecting and execute the first arbitrary command, we may got the following output.

If so, we need to authenticate to communicate with the redis server.

Commands (Non-RESP Format)

Non-RESP (REdis Serialization Protocol) is such like the other protocol's command. Commands are separated with spaces.

Investigation

Get Key Value

Set Key Value

Insert Values

Commands (RESP Format)

RESP (REdis Serialization Protocol) is The syntax is…

  • *<num> The number of arguments.

  • $<num> The string length of the argument.

Below is the command same as set name "john".

GET/SET Key Value Commands with Nginx Misconfiguration

We can connect to redis socket using curl command.

NTLM Hash Disclosure

In local machine, start SMB server.

Now execute the following command in Redis client.

We might get a NTLM hash in the incoming connection to the SMB server. We can see the SMB server logs in terminal. If the NTLM hash found, crack it.

Port Forwarding Redis Server to Local Machine

In local machine,

In target machine,

Last updated