Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96299d3

Browse files
committed
minor refactoring
1 parent cc28f6d commit 96299d3

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

lib/core/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,3 +3207,6 @@ def resetCookieJar(cookieJar):
32073207
errMsg += "cookies file ('%s')" % msg
32083208
raise sqlmapGenericException, errMsg
32093209

3210+
def prioritySortColumns(columns):
3211+
_ = lambda x: x and "id" in x.lower()
3212+
return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)

lib/core/dump.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from lib.core.common import getUnicode
2020
from lib.core.common import normalizeUnicode
2121
from lib.core.common import openFile
22+
from lib.core.common import prioritySortColumns
2223
from lib.core.common import restoreDumpMarkedChars
2324
from lib.core.common import safeCSValue
2425
from lib.core.common import unsafeSQLIdentificatorNaming
@@ -357,9 +358,7 @@ def dbTableValues(self, tableValues):
357358
field = 1
358359
fields = len(tableValues) - 1
359360

360-
columns = tableValues.keys()
361-
_ = lambda x: x and "id" in x.lower()
362-
columns = sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
361+
columns = prioritySortColumns(tableValues.keys())
363362

364363
for column in columns:
365364
if column != "__infos__":

plugins/generic/enumeration.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from lib.core.common import parsePasswordHash
2727
from lib.core.common import parseSqliteTableSchema
2828
from lib.core.common import popValue
29+
from lib.core.common import prioritySortColumns
2930
from lib.core.common import pushValue
3031
from lib.core.common import randomStr
3132
from lib.core.common import readInput
@@ -1608,9 +1609,7 @@ def dumpTable(self, foundData=None):
16081609
else:
16091610
query = rootQuery.inband.query % (colString, conf.db, tbl)
16101611
elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
1611-
_ = lambda x: x and "id" in x.lower()
1612-
orderby = sorted(sorted(colList, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)[0]
1613-
query = rootQuery.inband.query % (colString, conf.db, tbl, orderby)
1612+
query = rootQuery.inband.query % (colString, conf.db, tbl, prioritySortColumns(colList)[0])
16141613
else:
16151614
query = rootQuery.inband.query % (colString, conf.db, tbl)
16161615

0 commit comments

Comments
 (0)