@@ -513,22 +513,24 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
513513 query = rootQuery .inband .query % (unsafeSQLIdentificatorNaming (tbl ), unsafeSQLIdentificatorNaming (conf .db ))
514514 query += condQuery
515515 elif Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
516- query = rootQuery .inband .query % unsafeSQLIdentificatorNaming (tbl .upper ())
516+ query = rootQuery .inband .query % ( unsafeSQLIdentificatorNaming (tbl .upper ()), unsafeSQLIdentificatorNaming ( conf . db . upper () ))
517517 query += condQuery
518518 elif Backend .isDbms (DBMS .MSSQL ):
519519 query = rootQuery .inband .query % (conf .db , conf .db , conf .db , conf .db ,
520520 conf .db , conf .db , conf .db , unsafeSQLIdentificatorNaming (tbl ).split ("." )[- 1 ])
521521 query += condQuery .replace ("[DB]" , conf .db )
522- elif Backend .isDbms ( DBMS .SQLITE ):
522+ elif Backend .getIdentifiedDbms () in ( DBMS .SQLITE , DBMS . FIREBIRD ):
523523 query = rootQuery .inband .query % tbl
524524
525525 values = inject .getValue (query , blind = False , time = False )
526526
527527 if Backend .isDbms (DBMS .MSSQL ) and isNoneValue (values ):
528528 index , values = 1 , []
529+
529530 while True :
530531 query = rootQuery .inband .query2 % (conf .db , tbl , index )
531532 value = unArrayizeValue (inject .getValue (query , blind = False , time = False ))
533+
532534 if isNoneValue (value ) or value == " " :
533535 break
534536 else :
@@ -591,7 +593,7 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
591593 query += condQuery
592594
593595 elif Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
594- query = rootQuery .blind .count % unsafeSQLIdentificatorNaming (tbl .upper ())
596+ query = rootQuery .blind .count % ( unsafeSQLIdentificatorNaming (tbl .upper ()), unsafeSQLIdentificatorNaming ( conf . db . upper () ))
595597 query += condQuery
596598
597599 elif Backend .isDbms (DBMS .MSSQL ):
@@ -639,7 +641,7 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
639641 query += condQuery
640642 field = None
641643 elif Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
642- query = rootQuery .blind .query % unsafeSQLIdentificatorNaming (tbl .upper ())
644+ query = rootQuery .blind .query % ( unsafeSQLIdentificatorNaming (tbl .upper ()), unsafeSQLIdentificatorNaming ( conf . db . upper () ))
643645 query += condQuery
644646 field = None
645647 elif Backend .isDbms (DBMS .MSSQL ):
@@ -659,7 +661,7 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None):
659661 if Backend .getIdentifiedDbms () in (DBMS .MYSQL , DBMS .PGSQL ):
660662 query = rootQuery .blind .query2 % (unsafeSQLIdentificatorNaming (tbl ), column , unsafeSQLIdentificatorNaming (conf .db ))
661663 elif Backend .getIdentifiedDbms () in (DBMS .ORACLE , DBMS .DB2 ):
662- query = rootQuery .blind .query2 % (unsafeSQLIdentificatorNaming (tbl .upper ()), column )
664+ query = rootQuery .blind .query2 % (unsafeSQLIdentificatorNaming (tbl .upper ()), column , unsafeSQLIdentificatorNaming ( conf . db . upper ()) )
663665 elif Backend .isDbms (DBMS .MSSQL ):
664666 query = rootQuery .blind .query2 % (conf .db , conf .db , conf .db , conf .db , column , conf .db ,
665667 conf .db , conf .db , unsafeSQLIdentificatorNaming (tbl ).split ("." )[- 1 ])
@@ -736,7 +738,11 @@ def _tableGetCount(self, db, table):
736738 db = db .upper ()
737739 table = table .upper ()
738740
739- query = "SELECT %s FROM %s.%s" % (queries [Backend .getIdentifiedDbms ()].count .query % '*' , safeSQLIdentificatorNaming (db ), safeSQLIdentificatorNaming (table , True ))
741+ if Backend .getIdentifiedDbms () in (DBMS .SQLITE , DBMS .ACCESS , DBMS .FIREBIRD ):
742+ query = "SELECT %s FROM %s" % (queries [Backend .getIdentifiedDbms ()].count .query % '*' , safeSQLIdentificatorNaming (table , True ))
743+ else :
744+ query = "SELECT %s FROM %s.%s" % (queries [Backend .getIdentifiedDbms ()].count .query % '*' , safeSQLIdentificatorNaming (db ), safeSQLIdentificatorNaming (table , True ))
745+
740746 count = inject .getValue (query , expected = EXPECTED .INT , charsetType = CHARSET_TYPE .DIGITS )
741747
742748 if isNumPosStrValue (count ):
@@ -759,7 +765,7 @@ def getCount(self):
759765 if not conf .db :
760766 conf .db , conf .tbl = conf .tbl .split ("." )
761767
762- if conf .tbl is not None and conf .db is None :
768+ if conf .tbl is not None and conf .db is None and Backend . getIdentifiedDbms () not in ( DBMS . SQLITE , DBMS . ACCESS , DBMS . FIREBIRD ) :
763769 warnMsg = "missing database parameter. sqlmap is going to "
764770 warnMsg += "use the current database to retrieve the "
765771 warnMsg += "number of entries for table '%s'" % unsafeSQLIdentificatorNaming (conf .tbl )
0 commit comments