Advertisement
Guest User

Untitled

a guest
Nov 16th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. import paramiko
  2. input = raw_input("Please enter the input filename: ")
  3. output = raw_input("Please enter the output filename: ")
  4.  
  5. paramiko.util.log_to_file("filename.log")
  6. ssh = paramiko.SSHClient()
  7. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  8. input_file = open(input, 'r')
  9. output_file = open(output, 'w')
  10. output_file.write('-------------OPEN SSH SERVERS-----------------------\n\n')
  11. for line in input_file.readlines():
  12.     try:
  13.         ssh.connect(line, username='root', password='toor')
  14.         transport = ssh.get_transport()
  15.         transport.set_keepalive(5)
  16.     except paramiko.ssh_exception.AuthenticationException:
  17.         print "no login found " + line
  18.         try:
  19.             stdin, stdout, stderr = ssh.exec_command("whoami", timeout=5)
  20.         except paramiko.ssh_exception.SSHException:
  21.             print "could not exec command"
  22.         for base in stdout.readlines():
  23.             print "found login: " + line
  24.             output_file.write(line)
  25.        
  26. input_file.close()
  27. ssh.close()
  28. output_file.close()
  29. """
  30. Traceback (most recent call last):
  31.  File "par.py", line 22, in <module>
  32.    for base in stdout.readlines():
  33. NameError: name 'stdout' is not defined
  34. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement