Example #1
0
	def getDescOfEachNoSystemTable(self):
		'''
		returns a String for print
		'''
		outputString = ""
		logging.debug("Getting all no system tables accessible with the current user")
		tablesAccessible = self.__execQuery__(query=self.REQ_GET_ALL_NO_SYSTEM_TABLES, ld=['owner', 'table_name'])
		if isinstance(tablesAccessible,Exception):
			logging.warning("Impossible to execute the request '{0}': {1}".format(self.REQ_GET_ALL_NO_SYSTEM_TABLES, tablesAccessible.generateInfoAboutError(self.REQ_GET_ALL_NO_SYSTEM_TABLES)))
			return ""
		else:
			nbTables = len(tablesAccessible)
			colNb = nbTables
			if colNb>0 : 
				pbar,currentColNum = self.getStandardBarStarted(colNb), 0
			for aTable in tablesAccessible:
				if colNb>0:
					currentColNum += 1
					pbar.update(currentColNum)
				request = self.REQ_GET_COLUMNS_FOR_TABLE.format(aTabl<e['table_name'], aTable['owner'])
				columnsAndTypes = self.__execQuery__(query=request, ld=['column_name', 'data_type'])
				if isinstance(columnsAndTypes,Exception):
					logging.warning("Impossible to execute the request '{0}': {1}".format(request, columnsAndTypes.generateInfoAboutError(request)))
				outputString += "\n[+] {0}.{1} ({2}/{3})\n".format(aTable['owner'], aTable['table_name'], currentColNum, colNb)
				resultsToTable = [('column_name', 'data_type')]
				for aLine in columnsAndTypes:
					resultsToTable.append((aLine['column_name'], aLine['data_type']))
				table = Texttable(max_width=getScreenSize()[0])
				table.set_deco(Texttable.HEADER)
				table.add_rows(resultsToTable)
				outputString += table.draw()
				outputString += '\n'
			if colNb>0 : pbar.finish()
		return outputString
Example #2
0
    def getDescOfEachNoSystemTable(self):
        '''
		returns a String for print
		'''
        outputString = ""
        logging.debug(
            "Getting all no system tables accessible with the current user")
        tablesAccessible = self.__execQuery__(
            query=self.REQ_GET_ALL_NO_SYSTEM_TABLES,
            ld=['owner', 'table_name'])
        if isinstance(tablesAccessible, Exception):
            logging.warning(
                "Impossible to execute the request '{0}': {1}".format(
                    self.REQ_GET_ALL_NO_SYSTEM_TABLES,
                    tablesAccessible.generateInfoAboutError(
                        self.REQ_GET_ALL_NO_SYSTEM_TABLES)))
            return ""
        else:
            nbTables = len(tablesAccessible)
            colNb = nbTables
            if colNb > 0:
                pbar, currentColNum = self.getStandardBarStarted(colNb), 0
            for aTable in tablesAccessible:
                if colNb > 0:
                    currentColNum += 1
                    pbar.update(currentColNum)
                request = self.REQ_GET_COLUMNS_FOR_TABLE.format(
                    aTabl < e['table_name'], aTable['owner'])
                columnsAndTypes = self.__execQuery__(
                    query=request, ld=['column_name', 'data_type'])
                if isinstance(columnsAndTypes, Exception):
                    logging.warning(
                        "Impossible to execute the request '{0}': {1}".format(
                            request,
                            columnsAndTypes.generateInfoAboutError(request)))
                outputString += "\n[+] {0}.{1} ({2}/{3})\n".format(
                    aTable['owner'], aTable['table_name'], currentColNum,
                    colNb)
                resultsToTable = [('column_name', 'data_type')]
                for aLine in columnsAndTypes:
                    resultsToTable.append(
                        (aLine['column_name'], aLine['data_type']))
                table = Texttable(max_width=getScreenSize()[0])
                table.set_deco(Texttable.HEADER)
                table.add_rows(resultsToTable)
                outputString += table.draw()
                outputString += '\n'
            if colNb > 0: pbar.finish()
        return outputString
Example #3
0
	def printJobs(self):
		'''
		Print jobs
		'''
		columns = [("job_id","job_name","job_desc","step_name","subsystem","command","job_owner","proxy_id","proxy_account","enabled","server","date_created","last_run_date")]
		data = self.getJobs()
		data = columns + data
		if isinstance(data, Exception):
			logging.error("Impossible to print jobs: '{1}'".format(data))
			return data
		table = Texttable(max_width=getScreenSize()[0])
		table.set_deco(Texttable.HEADER)
		table.add_rows(data)
		print(table.draw())
		return True
Example #4
0
	def printScanPortResults(self,results):
		'''
		resultats is a list of list
		print resultat of scan port
		'''
		cleanList = []
		results.insert(0,["PORT","PROTOCOL","STATE",'ERROR'])
		table = Texttable(max_width=getScreenSize()[0])
		table.set_deco(Texttable.HEADER)
		if self.args['verbose']<2 :
			for l in results:
				if areEquals(l[2],'close')==False: cleanList.append(l)
			results = cleanList

		table.add_rows(results)
		self.args['print'].goodNews("Scan report for {0}:\n{1}".format(self.args['scan-ports'][0],table.draw()))
Example #5
0
File: Http.py Project: unbaiat/odat
    def printScanPortResults(self, results):
        """
		resultats is a list of list
		print resultat of scan port
		"""
        cleanList = []
        results.insert(0, ["PORT", "PROTOCOL", "STATE", "ERROR"])
        table = Texttable(max_width=getScreenSize()[0])
        table.set_deco(Texttable.HEADER)
        if self.args["verbose"] < 2:
            for l in results:
                if areEquals(l[2], "close") == False:
                    cleanList.append(l)
            results = cleanList

        table.add_rows(results)
        self.args["print"].goodNews("Scan report for {0}:\n{1}".format(self.args["scan-ports"][0], table.draw()))
Example #6
0
	def getInfoIntable(self,listOfDicos, columns, showEmptyColumns, withoutExample=False):
		'''
		columns: list which contains column names for the output
		returns a String for print
		'''
		isStringValueInColumn = False
		resultsToTable = [columns]
		colNb = len(listOfDicos)
		if colNb>0 : pbar,currentColNum = self.getStandardBarStarted(colNb), 0
		for e in listOfDicos :
			isStringValueInColumn = False
			if colNb>0 : currentColNum += 1
			if colNb>0 : pbar.update(currentColNum)
			l = []
			l.append(e['owner'])
			l.append(e['table_name'])
			l.append(e['column_name'])
			if withoutExample == True:
				l.append(self.DEFAULT_VALUE_UNKNOWN)
				resultsToTable.append(l)
			else:
				logging.debug("Search a not null value in the column '{0}' of the table '{1}'.'{2}' ({3}/{4})".format(e['column_name'], e['owner'], e['table_name'],currentColNum,colNb))
				req_value_in_column = self.REQ_VALUE_IN_COLUMN.format(e['column_name'],e['owner'],e['table_name'])
				aValue = self.__execQuery__(query=req_value_in_column, ld=['value'])
				if isinstance(aValue,Exception):
					logging.warning("Impossible to execute the request '{0}' in column names: {1}".format(req_value_in_column, aValue.generateInfoAboutError(req_value_in_column)))
					l.append(self.DEFAULT_VALUE_UNKNOWN)
				elif aValue == [] : l.append(self.DEFAULT_VALUE_EMPTY_COLUMN)
				else :
					value = aValue[0]['value']
					if type(value) is str: 
						isStringValueInColumn = True
						if len(value) > self.EXEMPLE_VALUE_LEN_MAX:
							value = value[0:self.EXEMPLE_VALUE_LEN_MAX] + ' ' +self.TRUNCATED_MESSAGE_EXEMPLE
						l.append(value)
					else: l.append(self.DEFAULT_VALUE_EMPTY_COLUMN)
				if isStringValueInColumn == True :
					resultsToTable.append(l)
				elif showEmptyColumns==True :
					resultsToTable.append(l)
		if colNb>0 : pbar.finish()
		table = Texttable(max_width=getScreenSize()[0])
		table.set_deco(Texttable.HEADER)
		table.add_rows(resultsToTable)
		return table.draw()
Example #7
0
	def getInfoIntable(self,listOfDicos, columns, showEmptyColumns):
		'''
		columns: list which contains column names for the output
		returns a String for print
		'''
		isStringValueInColumn = False
		resultsToTable = [columns]
		colNb = len(listOfDicos)
		if colNb>0 : pbar,currentColNum = self.getStandardBarStarted(colNb), 0
		for e in listOfDicos :
			isStringValueInColumn = False
			if colNb>0 : currentColNum += 1
			if colNb>0 : pbar.update(currentColNum)
			l = []
			l.append(e['owner'])
			l.append(e['table_name'])
			l.append(e['column_name'])
			logging.debug("Search a not null value in the column '{0}' of the table '{1}'.'{2}' ({3}/{4})".format(e['column_name'], e['owner'], e['table_name'],currentColNum,colNb))
			req_value_in_column = self.REQ_VALUE_IN_COLUMN.format(e['column_name'],e['owner'],e['table_name'])
			aValue = self.__execQuery__(query=req_value_in_column, ld=['value'])
			if isinstance(aValue,Exception):
				logging.warning("Impossible to execute the request '{0}' in column names: {1}".format(req_value_in_column, aValue.generateInfoAboutError(req_value_in_column)))
				l.append(self.DEFAULT_VALUE_UNKNOWN)
			elif aValue == [] : l.append(self.DEFAULT_VALUE_EMPTY_COLUMN)
			else :
				value = aValue[0]['value']
				if type(value) is str: 
					isStringValueInColumn = True
					if len(value) > self.EXEMPLE_VALUE_LEN_MAX:
						value = value[0:self.EXEMPLE_VALUE_LEN_MAX] + ' ' +self.TRUNCATED_MESSAGE_EXEMPLE
					l.append(value)
				else: l.append(self.DEFAULT_VALUE_EMPTY_COLUMN)
			if isStringValueInColumn == True :
				resultsToTable.append(l)
			elif showEmptyColumns==True :
				resultsToTable.append(l)
		if colNb>0 : pbar.finish()
		table = Texttable(max_width=getScreenSize()[0])
		table.set_deco(Texttable.HEADER)
		table.add_rows(resultsToTable)
		return table.draw()