ssh pi by python


use python to scan raspberry pi

#-*- coding: utf-8 -*-
#!/usr/bin/python
import paramiko
import threading

def ssh2(ip,username,passwd,cmd):
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(ip,22,username,passwd,timeout=5)
        for m in cmd:
            stdin, stdout, stderr = ssh.exec_command(m)
#           stdin.write("Y")   #简单交互,输入 ‘Y’
            out = stdout.readlines()
            #屏幕输出
            for o in out:
                print o,
        print '%s\tOK\n'%(ip)
        ssh.close()
    except :
        pass
        #print '%s\tError\n'%(ip)


if __name__=='__main__':
    cmd = ['echo hello!']#你要执行的命令列表
    username = ""  #用户名
    passwd = ""    #密码
    threads = []   #多线程
    print "Begin......"
    for i in range(1,254):
        ip = '10.43.11.'+str(i)
        a=threading.Thread(target=ssh2,args=(ip,username,passwd,cmd))
        a.start()

文章作者: xyzz
文章链接: http://www.xyzzpwn.top
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 xyzz !
 上一篇
static web static web
Because my teacher tell me to build a static web server for defend the attack.I think i should do this things: it can d
2018-06-23
下一篇 
rsa-of-ctf-2 rsa-of-ctf-2
8.gcd(n1,n2)Sometimes,n1 n2 are too big to factor.you can try gcd(n1,n2) def gcd(a, b): if a < b: a, b =
2018-06-03
  目录