-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidateCredent.py
More file actions
88 lines (59 loc) · 2.59 KB
/
validateCredent.py
File metadata and controls
88 lines (59 loc) · 2.59 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'''
Created on May 2, 2017
@author: sp977u
'''
from PySide import QtCore,QtGui
import sys
from service_network.device_wheels import devicelogin
import time
class validateCredent(QtCore.QObject,QtCore.QRunnable) :
validate_signl = QtCore.Signal(str,str) #dev type , cred test
def __init__(self,IPList,usr,pw):
QtCore.QObject.__init__(self)
QtCore.QRunnable.__init__(self)
self.IPList = IPList
self.usr = usr
self.pw = pw
def run(self):
#def checkCredentials(self,IPList,usr,pw):
trialcount = 0
Devtype = 'NF'
badUsernamePass = 0
job_done = "No"
credtestpass = "Fail"
scan = devicelogin.Login()
'''for item in range(len(IPList)):
ip = str(IPList[item])
ip = ip.strip('[').strip(']').strip("'")
IPList[item] = ip'''
try :
for ipadd in self.IPList:
print(ipadd)
Devtype = scan.ScreeningDevice(ipadd, self.usr, self.pw)
#loc = loc + 1
trialcount = trialcount + 1
if "SSH is not enabled" in Devtype or "SSH negotiation or logical error" in Devtype or "un known Error" in Devtype or "Device is not reachable" in Devtype :
continue
if "Invalid username or Password" in Devtype :
badUsernamePass += 1
if badUsernamePass >= 2 :
Devtype = "Invalid username or Password"
break
continue
if "cisco ASA" in Devtype or "cisco" in Devtype or "juniper" in Devtype or "Cisco_Wireless" in Devtype:
#print("Credentials check passed...!")
credtestpass = "Passed"
job_done = "Yes"
self.validate_signl.emit(Devtype,credtestpass)
break
#if loc >= len(IPList):
# break
if credtestpass == "Fail" :
self.validate_signl.emit(Devtype,credtestpass)
except Exception as ex:
print(ex)
credtestpass = "Fail"
self.validate_signl.emit(Devtype,credtestpass)
# return 0
#return Devtype, credtestpass
# log this