def check_server( host, user, passwd ):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() )
try:
ssh.connect( host, port=22, username=user, password=passwd, timeout=10 )
printq.put( "[+] Login success: {}:{}@{}".format( user, passwd, host ) )
( stdin, stdout, stderr ) = ssh.exec_command( "id" )
result = " ".join( [ line.rstrip( "\n" ) for line in stdout.readlines() ] ).rstrip( "\n" )
if "uid=0" in result:
status = "root privs"
printq.put( "[+] Login success: {}:{}@{} - {}".format( user, passwd, host, status ) )
else:
printq.put( "[+] Login success: {}:{}@{}".format( user, passwd, host ) )
except paramiko.AuthenticationException:
printq.put( "[!] Login failed: {}:{}@{}".format( user, passwd, host ) )
except socket.error:
printq.put( "[!] Socket Error... skipping: {}:{}@{}".format( user, passwd, host ) )
except paramiko.ssh_exception.SSHException:
printq.put( "[!] Socket Error... skipping: {}:{}@{}".format( user, passwd, host ) )
except Exception as ERROR:
printq.put( "[!] Error - {}... skipping: {}:{}@{}".format( ERROR, user, passwd, host ) )
ssh.close()
评论列表
文章目录