|
17 | 17 | from lib.core.common import getConsoleWidth |
18 | 18 | from lib.core.common import getFileItems |
19 | 19 | from lib.core.common import getUnicode |
| 20 | +from lib.core.common import isNumPosStrValue |
20 | 21 | from lib.core.common import parsePasswordHash |
21 | 22 | from lib.core.common import popValue |
22 | 23 | from lib.core.common import pushValue |
@@ -159,7 +160,7 @@ def getUsers(self): |
159 | 160 | query = rootQuery.blind.count |
160 | 161 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
161 | 162 |
|
162 | | - if not count.isdigit() or not len(count) or count == "0": |
| 163 | + if not isNumPosStrValue(count): |
163 | 164 | errMsg = "unable to retrieve the number of database users" |
164 | 165 | raise sqlmapNoneDataException, errMsg |
165 | 166 |
|
@@ -268,7 +269,7 @@ def getPasswordHashes(self): |
268 | 269 | query = rootQuery.blind.count % user |
269 | 270 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
270 | 271 |
|
271 | | - if not count.isdigit() or not len(count) or count == "0": |
| 272 | + if not isNumPosStrValue(count): |
272 | 273 | warnMsg = "unable to retrieve the number of password " |
273 | 274 | warnMsg += "hashes for user '%s'" % user |
274 | 275 | logger.warn(warnMsg) |
@@ -547,8 +548,8 @@ def getPrivileges(self, query2=False): |
547 | 548 | query = rootQuery.blind.count % queryUser |
548 | 549 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
549 | 550 |
|
550 | | - if not count.isdigit() or not len(count) or count == "0": |
551 | | - if not count.isdigit() and kb.dbms == DBMS.ORACLE and not query2: |
| 551 | + if not isNumPosStrValue(count): |
| 552 | + if not (isinstance(count, basestring) and count.isdigit()) and kb.dbms == DBMS.ORACLE and not query2: |
552 | 553 | infoMsg = "trying with table USER_SYS_PRIVS" |
553 | 554 | logger.info(infoMsg) |
554 | 555 |
|
@@ -686,7 +687,7 @@ def getDbs(self): |
686 | 687 | query = rootQuery.blind.count |
687 | 688 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
688 | 689 |
|
689 | | - if not count.isdigit() or not len(count) or count == "0": |
| 690 | + if not isNumPosStrValue(count): |
690 | 691 | errMsg = "unable to retrieve the number of databases" |
691 | 692 | raise sqlmapNoneDataException, errMsg |
692 | 693 |
|
@@ -811,7 +812,7 @@ def getTables(self): |
811 | 812 | query = rootQuery.blind.count % db |
812 | 813 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
813 | 814 |
|
814 | | - if not count.isdigit() or not len(count) or count == "0": |
| 815 | + if not isNumPosStrValue(count): |
815 | 816 | warnMsg = "unable to retrieve the number of " |
816 | 817 | warnMsg += "tables for database '%s'" % db |
817 | 818 | logger.warn(warnMsg) |
@@ -982,7 +983,7 @@ def getColumns(self, onlyColNames=False): |
982 | 983 |
|
983 | 984 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
984 | 985 |
|
985 | | - if not count.isdigit() or not len(count) or count == "0": |
| 986 | + if not isNumPosStrValue(count): |
986 | 987 | errMsg = "unable to retrieve the number of columns " |
987 | 988 | errMsg += "for table '%s' " % conf.tbl |
988 | 989 | errMsg += "on database '%s'" % conf.db |
@@ -1165,7 +1166,7 @@ def dumpTable(self): |
1165 | 1166 | query = rootQuery.blind.count % (conf.db, conf.tbl) |
1166 | 1167 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
1167 | 1168 |
|
1168 | | - if not count.isdigit() or not len(count) or count == "0": |
| 1169 | + if not isNumPosStrValue(count): |
1169 | 1170 | warnMsg = "unable to retrieve the number of " |
1170 | 1171 | if conf.col: |
1171 | 1172 | warnMsg += "columns '%s' " % colString |
@@ -1400,7 +1401,7 @@ def searchDb(self): |
1400 | 1401 | query += exclDbsQuery |
1401 | 1402 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
1402 | 1403 |
|
1403 | | - if not count.isdigit() or not len(count) or count == "0": |
| 1404 | + if not isNumPosStrValue(count): |
1404 | 1405 | warnMsg = "no database" |
1405 | 1406 | if dbConsider == "1": |
1406 | 1407 | warnMsg += "s like" |
@@ -1485,7 +1486,7 @@ def searchTable(self): |
1485 | 1486 | query += exclDbsQuery |
1486 | 1487 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
1487 | 1488 |
|
1488 | | - if not count.isdigit() or not len(count) or count == "0": |
| 1489 | + if not isNumPosStrValue(count): |
1489 | 1490 | warnMsg = "no databases have table" |
1490 | 1491 | if tblConsider == "1": |
1491 | 1492 | warnMsg += "s like" |
@@ -1522,7 +1523,7 @@ def searchTable(self): |
1522 | 1523 | query += " AND %s" % tblQuery |
1523 | 1524 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
1524 | 1525 |
|
1525 | | - if not count.isdigit() or not len(count) or count == "0": |
| 1526 | + if not isNumPosStrValue(count): |
1526 | 1527 | warnMsg = "no table" |
1527 | 1528 | if tblConsider == "1": |
1528 | 1529 | warnMsg += "s like" |
@@ -1624,7 +1625,7 @@ def searchColumn(self): |
1624 | 1625 | query += exclDbsQuery |
1625 | 1626 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
1626 | 1627 |
|
1627 | | - if not count.isdigit() or not len(count) or count == "0": |
| 1628 | + if not isNumPosStrValue(count): |
1628 | 1629 | warnMsg = "no databases have tables containing column" |
1629 | 1630 | if colConsider == "1": |
1630 | 1631 | warnMsg += "s like" |
@@ -1664,7 +1665,7 @@ def searchColumn(self): |
1664 | 1665 | query += " AND %s" % colQuery |
1665 | 1666 | count = inject.getValue(query, inband=False, expected="int", charsetType=2) |
1666 | 1667 |
|
1667 | | - if not count.isdigit() or not len(count) or count == "0": |
| 1668 | + if not isNumPosStrValue(count): |
1668 | 1669 | warnMsg = "no tables contain column" |
1669 | 1670 | if colConsider == "1": |
1670 | 1671 | warnMsg += "s like" |
|
0 commit comments