|
8 | 8 | from lib.core.agent import agent |
9 | 9 | from lib.core.common import arrayizeValue |
10 | 10 | from lib.core.common import Backend |
| 11 | +from lib.core.common import extractRegexResult |
11 | 12 | from lib.core.common import filterPairValues |
12 | 13 | from lib.core.common import flattenValue |
13 | 14 | from lib.core.common import getLimitRange |
|
19 | 20 | from lib.core.common import parseSqliteTableSchema |
20 | 21 | from lib.core.common import popValue |
21 | 22 | from lib.core.common import pushValue |
| 23 | +from lib.core.common import randomStr |
22 | 24 | from lib.core.common import readInput |
23 | 25 | from lib.core.common import safeSQLIdentificatorNaming |
24 | 26 | from lib.core.common import singleTimeWarnMessage |
|
41 | 43 | from lib.request import inject |
42 | 44 | from lib.techniques.brute.use import columnExists |
43 | 45 | from lib.techniques.brute.use import tableExists |
| 46 | +from lib.techniques.union.use import unionUse |
44 | 47 |
|
45 | 48 | class Databases: |
46 | 49 | """ |
@@ -539,7 +542,22 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None, dumpMod |
539 | 542 | infoMsg += "in database '%s'" % unsafeSQLIdentificatorNaming(conf.db) |
540 | 543 | logger.info(infoMsg) |
541 | 544 |
|
542 | | - values = inject.getValue(query, blind=False, time=False) |
| 545 | + values = None |
| 546 | + if Backend.isDbms(DBMS.MSSQL) and isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION): |
| 547 | + expression = query |
| 548 | + kb.dumpColumns = [] |
| 549 | + kb.rowXmlMode = True |
| 550 | + |
| 551 | + for column in extractRegexResult(r"SELECT (?P<result>.+?) FROM", query).split(','): |
| 552 | + kb.dumpColumns.append(randomStr().lower()) |
| 553 | + expression = expression.replace(column, "%s AS %s" % (column, kb.dumpColumns[-1]), 1) |
| 554 | + |
| 555 | + values = unionUse(expression) |
| 556 | + kb.rowXmlMode = False |
| 557 | + kb.dumpColumns = None |
| 558 | + |
| 559 | + if values is None: |
| 560 | + values = inject.getValue(query, blind=False, time=False) |
543 | 561 |
|
544 | 562 | if Backend.isDbms(DBMS.MSSQL) and isNoneValue(values): |
545 | 563 | index, values = 1, [] |
|
0 commit comments