def telnet_test_login(ip,password,username,port): crack=0 tn = telnetlib.Telnet(ip,port=port,timeout=5) tn.read_until("login: "******"\r") #等一会再 接受数据 time.sleep(4) msg=tn.read_some() tn.close() #判断msg是不是login fail 或者error if msg.strip()=='': lock.acquire() print "%s telnet's %s:%s login fail " %(ip,username,password) lock.release() if re.search("(.*?)fail",msg,re.I): lock.acquire() print "%s telnet's %s:%s login fail " %(ip,username,password) lock.release() else: if re.search("(.*?)incorrect",msg,re.I): lock.acquire() print "%s telnet's %s:%s login fail " %(ip,username,password) lock.release() else: lock.acquire() printGreen("%s telnet has weaken password!!-------%s:%s\r\n" %(ip,username,password)) result.append("%s telnet has weaken password!!-------%s:%s\r\n" %(ip,username,password)) lock.release() crack=1 return crack
def mysql(): while True: ip,port=sp.get() flag=0 usernames=file2list('mysql_user.txt') passwords=file2list('mysql_pass.txt') for username in usernames: #test mysql is allow connect try: db=MySQLdb.connect(ip,username,password,port=port) except Exception, e: #print e if e[0]==1130: lock.acquire() printRed("%s not allow to connect\r\n" %(ip)) lock.release() break if mysql_connect(ip,username,username,port)==1: lock.acquire() printGreen("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username)) result.append("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username)) lock.release() break if mysql_connect(ip,username,username+'123',port)==1: lock.acquire() printGreen("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123')) result.append("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123')) lock.release() break if mysql_connect(ip,username,username+'123456',port)==1: lock.acquire() printGreen("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123456')) result.append("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123456')) lock.release() break if mysql_connect(ip,username,'',port)==1: lock.acquire() printGreen("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,'')) result.append("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,'')) lock.release() break for password in passwords: if mysql_connect(ip,username,password,port)==1: lock.acquire() printGreen("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,password)) result.append("%s mysql at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,password)) lock.release() flag=1 break if flag==1: flag=0 break sp.task_done()
def telnet(): while True: ip,port=sp.get() flag=0 try: #弱口令爆破 for username in usernames: if telnet_test_login(ip,username,username,port)==1: break if telnet_test_login(ip,username+'123',username,port)==1: break if telnet_test_login(ip,username+'123456',username,port)==1: break for password in passwords: tn = telnetlib.Telnet(ip,port=port,timeout=5) tn.read_until("login: "******"\r") #等一会再 接受数据 time.sleep(4) msg=tn.read_some() tn.close() if msg.strip()=='': lock.acquire() print "%s telnet's %s:%s login fail " %(ip,username,password) lock.release() #判断msg是不是login fail 或者error if re.search("(.*?)fail",msg,re.I): lock.acquire() print "%s telnet's %s:%s login fail " %(ip,username,password) lock.release() else: if re.search("(.*?)incorrect",msg,re.I): lock.acquire() print "%s telnet's %s:%s login fail " %(ip,username,password) lock.release() else: lock.acquire() printGreen("%s telnet has weaken password!!-------%s:%s\r\n" %(ip,username,password)) result.append("%s telnet has weaken password!!-------%s:%s\r\n" %(ip,username,password)) lock.release() flag=1 break if flag == 1: flag=0 break except Exception,e: printPink(e) sp.task_done()
def ssh(): while True: ip,port=sp.get() flag=0 usernames=file2list('ssh_user.txt') passwords=file2list('ssh_pass.txt') for username in usernames: if ssh_connect(ip,username,username,port)==1: lock.acquire() printGreen("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username)) result.append("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username)) lock.release() break if ssh_connect(ip,username,username+'123',port)==1: lock.acquire() printGreen("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123')) result.append("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123')) lock.release() break if ssh_connect(ip,username,username+'123456',port)==1: lock.acquire() printGreen("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123456')) result.append("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,username+'123456')) lock.release() break if ssh_connect(ip,username,'',port)==1: lock.acquire() printGreen("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,'')) result.append("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,'')) lock.release() break for password in passwords: if ssh_connect(ip,username,password,port)==1: lock.acquire() printGreen("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,password)) result.append("%s ssh service at %s has weaken password!!-------%s:%s\r\n" %(ip,port,username,password)) lock.release() flag=1 break if flag==1: flag=0 break sp.task_done()
def telnet_test_login(ip, password, username, port): crack = 0 tn = telnetlib.Telnet(ip, port=port, timeout=5) tn.read_until("login: "******"\r") #等一会再 接受数据 time.sleep(4) msg = tn.read_some() tn.close() #判断msg是不是login fail 或者error if msg.strip() == '': lock.acquire() print "%s telnet's %s:%s login fail " % (ip, username, password) lock.release() if re.search("(.*?)fail", msg, re.I): lock.acquire() print "%s telnet's %s:%s login fail " % (ip, username, password) lock.release() else: if re.search("(.*?)incorrect", msg, re.I): lock.acquire() print "%s telnet's %s:%s login fail " % (ip, username, password) lock.release() else: lock.acquire() printGreen("%s telnet has weaken password!!-------%s:%s\r\n" % (ip, username, password)) result.append("%s telnet has weaken password!!-------%s:%s\r\n" % (ip, username, password)) lock.release() crack = 1 return crack
def ssh(): while True: ip, port = sp.get() flag = 0 usernames = file2list('ssh_user.txt') passwords = file2list('ssh_pass.txt') for username in usernames: for password in passwords: if ssh_connect(ip, username, password, port) == 1: lock.acquire() printGreen( "%s ssh service at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, password)) result.append( "%s ssh service at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, password)) lock.release() flag = 1 break if flag == 1: flag = 0 break sp.task_done()
def telnet(): while True: ip, port = sp.get() flag = 0 try: #弱口令爆破 for username in usernames: if telnet_test_login(ip, username, username, port) == 1: break if telnet_test_login(ip, username + '123', username, port) == 1: break if telnet_test_login(ip, username + '123456', username, port) == 1: break for password in passwords: tn = telnetlib.Telnet(ip, port=port, timeout=5) tn.read_until("login: "******"\r") #等一会再 接受数据 time.sleep(4) msg = tn.read_some() tn.close() if msg.strip() == '': lock.acquire() print "%s telnet's %s:%s login fail " % (ip, username, password) lock.release() #判断msg是不是login fail 或者error if re.search("(.*?)fail", msg, re.I): lock.acquire() print "%s telnet's %s:%s login fail " % (ip, username, password) lock.release() else: if re.search("(.*?)incorrect", msg, re.I): lock.acquire() print "%s telnet's %s:%s login fail " % ( ip, username, password) lock.release() else: lock.acquire() printGreen( "%s telnet has weaken password!!-------%s:%s\r\n" % (ip, username, password)) result.append( "%s telnet has weaken password!!-------%s:%s\r\n" % (ip, username, password)) lock.release() flag = 1 break if flag == 1: flag = 0 break except Exception, e: printPink(e) sp.task_done()
def smb(): while True: ip, port = sp.get() flag = 0 usernames = file2list('smb_user.txt') passwords = file2list('smb_pass.txt') for username in usernames: if smb_connect(ip, username, username) == 1: lock.acquire() printGreen( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username)) result.append( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username)) lock.release() break if smb_connect(ip, username, username + '123') == 1: lock.acquire() printGreen( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123')) result.append( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123')) lock.release() break if smb_connect(ip, username, username + '123456') == 1: lock.acquire() printGreen( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123456')) result.append( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123456')) lock.release() break if smb_connect(ip, username, '') == 1: lock.acquire() printGreen( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, username, '')) result.append( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, '')) lock.release() break for password in passwords: if smb_connect(ip, username, password) == 1: lock.acquire() printGreen( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, password)) result.append( "%s smb at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, password)) lock.release() flag = 1 break if flag == 1: flag = 0 break sp.task_done()
def mysql(): while True: ip, port = sp.get() flag = 0 usernames = file2list('mysql_user.txt') passwords = file2list('mysql_pass.txt') for username in usernames: #test mysql is allow connect try: db = MySQLdb.connect(ip, username, password, port=port) except Exception, e: #print e if e[0] == 1130: lock.acquire() printRed("%s not allow to connect\r\n" % (ip)) lock.release() break if mysql_connect(ip, username, username, port) == 1: lock.acquire() printGreen( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username)) result.append( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username)) lock.release() break if mysql_connect(ip, username, username + '123', port) == 1: lock.acquire() printGreen( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123')) result.append( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123')) lock.release() break if mysql_connect(ip, username, username + '123456', port) == 1: lock.acquire() printGreen( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123456')) result.append( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, username + '123456')) lock.release() break if mysql_connect(ip, username, '', port) == 1: lock.acquire() printGreen( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, '')) result.append( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, '')) lock.release() break for password in passwords: if mysql_connect(ip, username, password, port) == 1: lock.acquire() printGreen( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, password)) result.append( "%s mysql at %s has weaken password!!-------%s:%s\r\n" % (ip, port, username, password)) lock.release() flag = 1 break if flag == 1: flag = 0 break sp.task_done()