2020from lib .core .common import getRange
2121from lib .core .common import getCompiledRegex
2222from lib .core .common import getUnicode
23+ from lib .core .common import isInferenceAvailable
2324from lib .core .common import isNoneValue
2425from lib .core .common import isNumPosStrValue
2526from lib .core .common import isTechniqueAvailable
@@ -176,7 +177,7 @@ def getUsers(self):
176177 condition = ( Backend .isDbms (DBMS .MSSQL ) and Backend .isVersionWithin (("2005" , "2008" )) )
177178 condition |= ( Backend .isDbms (DBMS .MYSQL ) and not kb .data .has_information_schema )
178179
179- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
180+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
180181 if condition :
181182 query = rootQuery .inband .query2
182183 else :
@@ -186,7 +187,7 @@ def getUsers(self):
186187 if not isNoneValue (value ):
187188 kb .data .cachedUsers = arrayizeValue (value )
188189
189- if not kb .data .cachedUsers and not conf .direct :
190+ if not kb .data .cachedUsers and isInferenceAvailable () and not conf .direct :
190191 infoMsg = "fetching number of database users"
191192 logger .info (infoMsg )
192193
@@ -252,7 +253,7 @@ def getPasswordHashes(self):
252253
253254 users = filter (None , users )
254255
255- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
256+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
256257 if Backend .isDbms (DBMS .MSSQL ) and Backend .isVersionWithin (("2005" , "2008" )):
257258 query = rootQuery .inband .query2
258259 else :
@@ -293,7 +294,7 @@ def getPasswordHashes(self):
293294 else :
294295 kb .data .cachedUsersPasswords [user ].append (password )
295296
296- if not kb .data .cachedUsersPasswords and not conf .direct :
297+ if not kb .data .cachedUsersPasswords and isInferenceAvailable () and not conf .direct :
297298 if not len (users ):
298299 users = self .getUsers ()
299300
@@ -452,7 +453,7 @@ def getPrivileges(self, query2=False):
452453 # Set containing the list of DBMS administrators
453454 areAdmins = set ()
454455
455- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
456+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
456457 if Backend .isDbms (DBMS .MYSQL ) and not kb .data .has_information_schema :
457458 query = rootQuery .inband .query2
458459 condition = rootQuery .inband .condition2
@@ -537,7 +538,7 @@ def getPrivileges(self, query2=False):
537538 else :
538539 kb .data .cachedUsersPrivileges [user ] = list (privileges )
539540
540- if not kb .data .cachedUsersPrivileges and not conf .direct :
541+ if not kb .data .cachedUsersPrivileges and isInferenceAvailable () and not conf .direct :
541542 if Backend .isDbms (DBMS .MYSQL ) and kb .data .has_information_schema :
542543 conditionChar = " LIKE "
543544 else :
@@ -736,7 +737,7 @@ def getDbs(self):
736737
737738 rootQuery = queries [Backend .getIdentifiedDbms ()].dbs
738739
739- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
740+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
740741 if Backend .isDbms (DBMS .MYSQL ) and not kb .data .has_information_schema :
741742 query = rootQuery .inband .query2
742743 else :
@@ -746,7 +747,7 @@ def getDbs(self):
746747 if not isNoneValue (value ):
747748 kb .data .cachedDbs = arrayizeValue (value )
748749
749- if not kb .data .cachedDbs and not conf .direct :
750+ if not kb .data .cachedDbs and isInferenceAvailable () and not conf .direct :
750751 infoMsg = "fetching number of databases"
751752 logger .info (infoMsg )
752753
@@ -870,7 +871,7 @@ def getTables(self, bruteForce=None):
870871
871872 rootQuery = queries [Backend .getIdentifiedDbms ()].tables
872873
873- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
874+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
874875 query = rootQuery .inband .query
875876 condition = rootQuery .inband .condition if 'condition' in rootQuery .inband else None
876877
@@ -904,7 +905,7 @@ def getTables(self, bruteForce=None):
904905 else :
905906 kb .data .cachedTables [db ].append (table )
906907
907- if not kb .data .cachedTables and not conf .direct :
908+ if not kb .data .cachedTables and isInferenceAvailable () and not conf .direct :
908909 for db in dbs :
909910 if conf .excludeSysDbs and db in self .excludeDbsList :
910911 infoMsg = "skipping system database '%s'" % db
@@ -1087,7 +1088,7 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
10871088 rootQuery = queries [Backend .getIdentifiedDbms ()].columns
10881089 condition = rootQuery .blind .condition if 'condition' in rootQuery .blind else None
10891090
1090- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
1091+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
10911092 for tbl in tblList :
10921093 if conf .db is not None and len (kb .data .cachedColumns ) > 0 \
10931094 and conf .db in kb .data .cachedColumns and tbl in \
@@ -1156,7 +1157,7 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
11561157 table [safeSQLIdentificatorNaming (tbl , True )] = columns
11571158 kb .data .cachedColumns [safeSQLIdentificatorNaming (conf .db )] = table
11581159
1159- if not kb .data .cachedColumns and not conf .direct :
1160+ if not kb .data .cachedColumns and isInferenceAvailable () and not conf .direct :
11601161 for tbl in tblList :
11611162 if conf .db is not None and len (kb .data .cachedColumns ) > 0 \
11621163 and conf .db in kb .data .cachedColumns and tbl in \
@@ -1565,7 +1566,8 @@ def dumpTable(self, foundData=None):
15651566 or not kb .data .cachedColumns [safeSQLIdentificatorNaming (conf .db )][safeSQLIdentificatorNaming (tbl , True )]:
15661567 warnMsg = "unable to enumerate the columns for table "
15671568 warnMsg += "'%s' on database" % unsafeSQLIdentificatorNaming (tbl )
1568- warnMsg += " '%s', skipping" % unsafeSQLIdentificatorNaming (conf .db )
1569+ warnMsg += " '%s'" % unsafeSQLIdentificatorNaming (conf .db )
1570+ warnMsg += ", skipping" if len (tblList ) > 1 else ""
15691571 logger .warn (warnMsg )
15701572
15711573 continue
@@ -1660,7 +1662,7 @@ def dumpTable(self, foundData=None):
16601662
16611663 index += 1
16621664
1663- if not kb .data .dumpedTable and not conf .direct :
1665+ if not kb .data .dumpedTable and isInferenceAvailable () and not conf .direct :
16641666 infoMsg = "fetching number of "
16651667 if conf .col :
16661668 infoMsg += "column(s) '%s' " % colString
@@ -1924,7 +1926,7 @@ def searchDb(self):
19241926 dbQuery = "%s%s" % (dbCond , dbCondParam )
19251927 dbQuery = dbQuery % unsafeSQLIdentificatorNaming (db )
19261928
1927- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
1929+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
19281930 if Backend .isDbms (DBMS .MYSQL ) and not kb .data .has_information_schema :
19291931 query = rootQuery .inband .query2
19301932 else :
@@ -2044,7 +2046,7 @@ def searchTable(self):
20442046 tblQuery = "%s%s" % (tblCond , tblCondParam )
20452047 tblQuery = tblQuery % tbl
20462048
2047- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
2049+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
20482050 query = rootQuery .inband .query
20492051 query += tblQuery
20502052 query += whereDbsQuery
@@ -2213,7 +2215,7 @@ def searchColumn(self):
22132215 colQuery = "%s%s" % (colCond , colCondParam )
22142216 colQuery = colQuery % unsafeSQLIdentificatorNaming (column )
22152217
2216- if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ) or isTechniqueAvailable ( PAYLOAD .TECHNIQUE .ERROR ) or conf .direct :
2218+ if any ( isTechniqueAvailable (_ ) for _ in ( PAYLOAD .TECHNIQUE .UNION , PAYLOAD .TECHNIQUE .ERROR ) ) or conf .direct :
22172219 if not all ((conf .db , conf .tbl )):
22182220 query = rootQuery .inband .query
22192221 query += colQuery
0 commit comments