For the complete documentation index, see llms.txt. This page is also available as Markdown.

Pentesting Redis

redis port 6379

  • https://book.hacktricks.xyz/pentesting/6379-pentesting-redis

  • Enumeration

nmap --script redis-info -sV -p 6379 <IP>
msf> use auxiliary/scanner/redis/redis_server
  • Manual Enumeration

  • Redis is a text based protocol, you can just send the command in a socket and the returned values will be readable. Also remember that Redis can run using ssl/tls (but this is very weird).

  • In a regular Redis instance you can just connect using nc or you could also use redis-cli

nc -vn 10.10.10.10 6379
redis-cli -h 10.10.10.10 # sudo apt-get install redis-tools
  • Run the info first, it will either dump the redis instance or say -NOAUTH Authentication required.

  • Username / Password are stored in the redis.conf file by default

grep ^[^#] redis.conf
config set requirepass p@ss$12E45.
masteruser
  • Get Connected

nc 10.10.63.208 6379
info
<server reply>
redis-cli -h 10.10.63.208
10.10.63.208:6379> info
NOAUTH Authentication required.
10.10.63.208:6379> AUTH B65Hx562.....
OK

If NOAUTH Authentication required appears and you recover requirepass from /etc/redis/redis.conf, authenticate with the password only:

Do not include a username on older Redis instances that expect single-argument AUTH, or authentication may fail with:

  • Authenticated Enumeration

  • Dumping Database

  • Inside Redis the databases are numbers starting from 0. You can find if anyone is used in the output of the command info inside the "Keyspace" chunk:

  • alt text

  • Use the TYPE command to check the type of value a key is mapping to:

  • redis RCE

  • https://github.com/Ridter/redis-rce

Unauthenticated Redis RCE

Redis exposed without authentication can be abused with the redis-rce rogue replication flow to load a command-execution module. This worked against observed Redis 4.0.14 and 5.0.9 instances.

Detection

Confirm No Auth

Observed useful output:

INFO keyspace, SCAN 0, and KEYS * may show no stored keys while the instance is still exploitable.

Load Module With redis-rce

Get the tooling and module:

If building the module fails, the working notes used the precompiled exp.so from:

Run the rogue replication exploit first. The -P port is the rogue server port used by the exploit, not necessarily the reverse shell port.

Wait for the interactive prompt before starting the reverse shell listener:

Then start the listener in another terminal:

Back in redis-rce.py, choose reverse shell and send it to the listener port:

Successful module load indicators:

Successful shell:

On some targets the shell may land as the Redis service user instead of root:

Authenticated Redis RCE

If Redis requires auth but you recovered requirepass, pass it to redis-rce.py with -a:

Choose reverse shell when prompted and catch the callback:

Successful shell context may be the Redis service user:

Last updated