minor bug fix

This commit is contained in:
Miroslav Stampar 2011-08-09 14:20:25 +00:00
parent 2ad267132a
commit 41ae9bc7ff
4 changed files with 57 additions and 52 deletions

View File

@ -84,6 +84,9 @@ Pierre Chifflier <pollux@debian.org> and Mark Hymers <ftpmaster@debian.org>
Chris Clements <cclements@flatearth.net> Chris Clements <cclements@flatearth.net>
for reporting a couple of bugs for reporting a couple of bugs
John Cobb <johnc@nobytes.com>
for reporting a minor bug
Andreas Constantinides <megahz@megahz.org> Andreas Constantinides <megahz@megahz.org>
for reporting a minor bug for reporting a minor bug

View File

@ -2915,3 +2915,11 @@ def safeCSValue(value):
retVal = '"%s"' % retVal.replace('"', '""') retVal = '"%s"' % retVal.replace('"', '""')
return retVal return retVal
def filterPairValues(values):
retVal = []
if not isNoneValue(values) and hasattr(values, '__iter__'):
retVal = filter(lambda x: isinstance(x, (tuple, list, set)) and len(x) == 2, values)
return retVal

View File

@ -8,6 +8,7 @@ See the file 'doc/COPYING' for copying permission
""" """
from lib.core.common import Backend from lib.core.common import Backend
from lib.core.common import filterPairValues
from lib.core.common import isTechniqueAvailable from lib.core.common import isTechniqueAvailable
from lib.core.common import randomStr from lib.core.common import randomStr
from lib.core.common import safeSQLIdentificatorNaming from lib.core.common import safeSQLIdentificatorNaming
@ -232,7 +233,7 @@ class Enumeration(GenericEnumeration):
table = {} table = {}
columns = {} columns = {}
for name, type_ in zip(retVal[0]["%s.name" % randStr], retVal[0]["%s.usertype" % randStr]): for name, type_ in filterPairValues(zip(retVal[0]["%s.name" % randStr], retVal[0]["%s.usertype" % randStr])):
columns[name] = sybaseTypes.get(type_, type_) columns[name] = sybaseTypes.get(type_, type_)
table[safeSQLIdentificatorNaming(tbl)] = columns table[safeSQLIdentificatorNaming(tbl)] = columns

View File

@ -16,10 +16,10 @@ from lib.core.common import Backend
from lib.core.common import BigArray from lib.core.common import BigArray
from lib.core.common import clearConsoleLine from lib.core.common import clearConsoleLine
from lib.core.common import dataToStdout from lib.core.common import dataToStdout
from lib.core.common import filterPairValues
from lib.core.common import getRange from lib.core.common import getRange
from lib.core.common import getCompiledRegex from lib.core.common import getCompiledRegex
from lib.core.common import getFileItems from lib.core.common import getFileItems
from lib.core.common import Backend
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import isNoneValue from lib.core.common import isNoneValue
from lib.core.common import isNumPosStrValue from lib.core.common import isNumPosStrValue
@ -272,7 +272,7 @@ class Enumeration:
retVal = self.__pivotDumpTable("(%s) AS %s" % (query, randStr), ['%s.name' % randStr,'%s.password' % randStr], blind=False) retVal = self.__pivotDumpTable("(%s) AS %s" % (query, randStr), ['%s.name' % randStr,'%s.password' % randStr], blind=False)
if retVal: if retVal:
for user, password in zip(retVal[0]["%s.name" % randStr], retVal[0]["%s.password" % randStr]): for user, password in filterPairValues(zip(retVal[0]["%s.name" % randStr], retVal[0]["%s.password" % randStr])):
# password = "0x%s" % strToHex(password) # password = "0x%s" % strToHex(password)
if not kb.data.cachedUsersPasswords.has_key(user): if not kb.data.cachedUsersPasswords.has_key(user):
kb.data.cachedUsersPasswords[user] = [password] kb.data.cachedUsersPasswords[user] = [password]
@ -283,8 +283,7 @@ class Enumeration:
else: else:
value = inject.getValue(query, blind=False) value = inject.getValue(query, blind=False)
if not isNoneValue(value): for user, password in filterPairValues(value):
for user, password in value:
if not user or user == " ": if not user or user == " ":
continue continue
@ -315,7 +314,7 @@ class Enumeration:
retVal = self.__pivotDumpTable("(%s) AS %s" % (query, randStr), ['%s.name' % randStr,'%s.password' % randStr], blind=True) retVal = self.__pivotDumpTable("(%s) AS %s" % (query, randStr), ['%s.name' % randStr,'%s.password' % randStr], blind=True)
if retVal: if retVal:
for user, password in zip(retVal[0]["%s.name" % randStr], retVal[0]["%s.password" % randStr]): for user, password in filterPairValues(zip(retVal[0]["%s.name" % randStr], retVal[0]["%s.password" % randStr])):
password = "0x%s" % strToHex(password) password = "0x%s" % strToHex(password)
if not kb.data.cachedUsersPasswords.has_key(user): if not kb.data.cachedUsersPasswords.has_key(user):
@ -895,7 +894,7 @@ class Enumeration:
if len(value) > 0 and not isinstance(value[0], (list, tuple)): if len(value) > 0 and not isinstance(value[0], (list, tuple)):
value = zip([conf.db for i in xrange(len(value))], value) value = zip([conf.db for i in xrange(len(value))], value)
for db, table in value: for db, table in filterPairValues(value):
db = safeSQLIdentificatorNaming(db) db = safeSQLIdentificatorNaming(db)
table = safeSQLIdentificatorNaming(table, True) table = safeSQLIdentificatorNaming(table, True)
@ -2031,9 +2030,7 @@ class Enumeration:
query += exclDbsQuery query += exclDbsQuery
values = inject.getValue(query, blind=False) values = inject.getValue(query, blind=False)
if not any([isNoneValue(values), isinstance(values, basestring)]): for foundDb, foundTbl in filterPairValues(values):
values = filter(lambda x: isinstance(x, (tuple, list, set)) and len(x) == 2, values)
for foundDb, foundTbl in values:
foundDb = safeSQLIdentificatorNaming(foundDb) foundDb = safeSQLIdentificatorNaming(foundDb)
foundTbl = safeSQLIdentificatorNaming(foundTbl, True) foundTbl = safeSQLIdentificatorNaming(foundTbl, True)
@ -2197,11 +2194,7 @@ class Enumeration:
query += exclDbsQuery query += exclDbsQuery
values = inject.getValue(query, blind=False) values = inject.getValue(query, blind=False)
if not isNoneValue(values): for foundDb, foundTbl in filterPairValues(values):
if isinstance(values, basestring):
values = [ values ]
for foundDb, foundTbl in values:
foundDb = safeSQLIdentificatorNaming(foundDb) foundDb = safeSQLIdentificatorNaming(foundDb)
foundTbl = safeSQLIdentificatorNaming(foundTbl, True) foundTbl = safeSQLIdentificatorNaming(foundTbl, True)