|
5 | 5 | See the file 'doc/COPYING' for copying permission |
6 | 6 | """ |
7 | 7 |
|
| 8 | +import re |
| 9 | + |
8 | 10 | from extra.safe2bin.safe2bin import safechardecode |
9 | 11 | from lib.core.agent import agent |
10 | 12 | from lib.core.bigarray import BigArray |
@@ -60,36 +62,50 @@ def pivotDumpTable(table, colList, count=None, blind=True): |
60 | 62 |
|
61 | 63 | colList = filter(None, sorted(colList, key=lambda x: len(x) if x else MAX_INT)) |
62 | 64 |
|
63 | | - for column in colList: |
64 | | - infoMsg = "fetching number of distinct " |
65 | | - infoMsg += "values for column '%s'" % column |
66 | | - logger.info(infoMsg) |
67 | | - |
68 | | - query = dumpNode.count2 % (column, table) |
69 | | - value = inject.getValue(query, blind=blind, union=not blind, error=not blind, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) |
70 | | - |
71 | | - if isNumPosStrValue(value): |
72 | | - validColumnList = True |
73 | | - |
74 | | - if value == count: |
75 | | - infoMsg = "using column '%s' as a pivot " % column |
76 | | - infoMsg += "for retrieving row data" |
77 | | - logger.info(infoMsg) |
| 65 | + if conf.pivotColumn: |
| 66 | + if any(re.search(r"(.+\.)?%s" % conf.pivotColumn, _, re.I) for _ in colList): |
| 67 | + infoMsg = "using column '%s' as a pivot " % conf.pivotColumn |
| 68 | + infoMsg += "for retrieving row data" |
| 69 | + logger.info(infoMsg) |
78 | 70 |
|
79 | | - validPivotValue = True |
80 | | - |
81 | | - colList.remove(column) |
82 | | - colList.insert(0, column) |
83 | | - break |
84 | | - |
85 | | - if not validColumnList: |
86 | | - errMsg = "all column name(s) provided are non-existent" |
87 | | - raise SqlmapNoneDataException(errMsg) |
| 71 | + validPivotValue = True |
| 72 | + colList.remove(conf.pivotColumn) |
| 73 | + colList.insert(0, conf.pivotColumn) |
| 74 | + else: |
| 75 | + warnMsg = "column '%s' not " % conf.pivotColumn |
| 76 | + warnMsg += "found in table '%s'" % table |
| 77 | + logger.warn(warnMsg) |
88 | 78 |
|
89 | 79 | if not validPivotValue: |
90 | | - warnMsg = "no proper pivot column provided (with unique values)." |
91 | | - warnMsg += " It won't be possible to retrieve all rows" |
92 | | - logger.warn(warnMsg) |
| 80 | + for column in colList: |
| 81 | + infoMsg = "fetching number of distinct " |
| 82 | + infoMsg += "values for column '%s'" % column |
| 83 | + logger.info(infoMsg) |
| 84 | + |
| 85 | + query = dumpNode.count2 % (column, table) |
| 86 | + value = inject.getValue(query, blind=blind, union=not blind, error=not blind, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) |
| 87 | + |
| 88 | + if isNumPosStrValue(value): |
| 89 | + validColumnList = True |
| 90 | + |
| 91 | + if value == count: |
| 92 | + infoMsg = "using column '%s' as a pivot " % column |
| 93 | + infoMsg += "for retrieving row data" |
| 94 | + logger.info(infoMsg) |
| 95 | + |
| 96 | + validPivotValue = True |
| 97 | + colList.remove(column) |
| 98 | + colList.insert(0, column) |
| 99 | + break |
| 100 | + |
| 101 | + if not validColumnList: |
| 102 | + errMsg = "all column name(s) provided are non-existent" |
| 103 | + raise SqlmapNoneDataException(errMsg) |
| 104 | + |
| 105 | + if not validPivotValue: |
| 106 | + warnMsg = "no proper pivot column provided (with unique values)." |
| 107 | + warnMsg += " It won't be possible to retrieve all rows" |
| 108 | + logger.warn(warnMsg) |
93 | 109 |
|
94 | 110 | pivotValue = " " |
95 | 111 | breakRetrieval = False |
|
0 commit comments