Exemple #1
0
    def __getAccounts__(self):
        '''
		return list containing accounts
		'''
        accounts = []
        logging.info('Loading accounts stored in the {0} file...'.format(
            self.accountsFile))
        f = open(self.accountsFile)
        for l in f:
            lsplit = cleanString(l).split(self.credSeparator)
            if isinstance(lsplit, list):
                if len(lsplit) == 2:
                    accounts.append([lsplit[0], lsplit[1]])
                elif len(lsplit) > 2:
                    tempPasswd = ""
                    for i in range(len(lsplit)):
                        if i != 0: tempPasswd += lsplit[i]
                    accounts.append([lsplit[0], tempPasswd])
                else:
                    logging.warning(
                        "The account '{0}' not contains '{1}' or it contains more than one '{1}'. This account will not be tested"
                        .format(lsplit[0], self.credSeparator))
        f.close()
        logging.debug("Accounts loaded")
        return sorted(accounts, key=lambda x: x[0])
Exemple #2
0
	def __getPasswords__(self):
		'''
		Returns  list containing usernames
		'''
		passwords = []
		logging.info('Loading usernames stored in the {0} file...'.format(self.passwordsFile))
		f = open(self.passwordsFile)
		for l in f:
			l = cleanString(l)
			passwords.append(l)
		f.close()
		logging.debug("Passwords loaded")
		return passwords
Exemple #3
0
	def __getUsernames__(self):
		'''
		Returns  list containing usernames
		'''
		usernames = []
		logging.info('Loading usernames stored in the {0} file...'.format(self.usernamesFile))
		f = open(self.usernamesFile)
		for l in f:
			l = cleanString(l)
			usernames.append(l)
		f.close()
		logging.debug("Usernames loaded")
		return usernames
Exemple #4
0
	def getCompleteVersion (self):
		'''
		return complete version
		'''
		logging.debug("Getting the database version installed on the {0} server".format(self.host))
		if self.completeVersion == None :
			data = self.executeRequest("SELECT @@version",['version'])
			if isinstance(data,Exception): return data
			elif len(data) == 1 :
				version = cleanString(data[0]['version'])
				logging.debug("The version is : {0}".format(version))
				return version
			else : return ""
		else : self.completeVersion 
Exemple #5
0
def getHostsFromFile(filename):
	'''
	Return a list of hosts : [['1.1.1.1',1433],['1.1.1.2',1433], etc]
	'''
	hosts, lines = [], None
	logging.debug("Trying to read hosts from {0}".format(filename))
	f = open(filename)
	lines = f.readlines()
	logging.info("Reading hosts from {0}".format(filename))
	for aHost in lines:
		aHostSplitted = cleanString(aHost).split(':')
		if len(aHostSplitted) == 1:
			hosts.append([aHostSplitted[0],1433])
		elif len(aHostSplitted) == 2:
			hosts.append([aHostSplitted[0],aHostSplitted[1]])
		else:
			logging.warning("Impossible to read this host: {0}".format(aHostSplitted))
	f.close()
	logging.debug("Hosts stored in {0}: {1}".format(filename, hosts))
	return hosts