Skip to content

Commit 7244e8e

Browse files
committed
Minor patches
1 parent e7268ff commit 7244e8e

File tree

5 files changed

+38
-38
lines changed

5 files changed

+38
-38
lines changed

lib/core/common.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,32 +1676,32 @@ def getCharset(charsetType=None):
16761676

16771677
# Binary
16781678
elif charsetType == CHARSET_TYPE.BINARY:
1679-
asciiTbl.extend([0, 1])
1679+
asciiTbl.extend((0, 1))
16801680
asciiTbl.extend(xrange(47, 50))
16811681

16821682
# Digits
16831683
elif charsetType == CHARSET_TYPE.DIGITS:
1684-
asciiTbl.extend([0, 9])
1684+
asciiTbl.extend((0, 9))
16851685
asciiTbl.extend(xrange(47, 58))
16861686

16871687
# Hexadecimal
16881688
elif charsetType == CHARSET_TYPE.HEXADECIMAL:
1689-
asciiTbl.extend([0, 1])
1689+
asciiTbl.extend((0, 1))
16901690
asciiTbl.extend(xrange(47, 58))
16911691
asciiTbl.extend(xrange(64, 71))
1692-
asciiTbl.extend([87, 88]) # X
1692+
asciiTbl.extend((87, 88)) # X
16931693
asciiTbl.extend(xrange(96, 103))
1694-
asciiTbl.extend([119, 120]) # x
1694+
asciiTbl.extend((119, 120)) # x
16951695

16961696
# Characters
16971697
elif charsetType == CHARSET_TYPE.ALPHA:
1698-
asciiTbl.extend([0, 1])
1698+
asciiTbl.extend((0, 1))
16991699
asciiTbl.extend(xrange(64, 91))
17001700
asciiTbl.extend(xrange(96, 123))
17011701

17021702
# Characters and digits
17031703
elif charsetType == CHARSET_TYPE.ALPHANUM:
1704-
asciiTbl.extend([0, 1])
1704+
asciiTbl.extend((0, 1))
17051705
asciiTbl.extend(xrange(47, 58))
17061706
asciiTbl.extend(xrange(64, 91))
17071707
asciiTbl.extend(xrange(96, 123))
@@ -3455,7 +3455,7 @@ def removeReflectiveValues(content, payload, suppressWarning=False):
34553455
retVal = content
34563456

34573457
try:
3458-
if all([content, payload]) and isinstance(content, unicode) and kb.reflectiveMechanism and not kb.heuristicMode:
3458+
if all((content, payload)) and isinstance(content, unicode) and kb.reflectiveMechanism and not kb.heuristicMode:
34593459
def _(value):
34603460
while 2 * REFLECTED_REPLACEMENT_REGEX in value:
34613461
value = value.replace(2 * REFLECTED_REPLACEMENT_REGEX, REFLECTED_REPLACEMENT_REGEX)
@@ -3880,6 +3880,8 @@ def isAdminFromPrivileges(privileges):
38803880
Inspects privileges to see if those are coming from an admin user
38813881
"""
38823882

3883+
privileges = privileges or []
3884+
38833885
# In PostgreSQL the usesuper privilege means that the
38843886
# user is DBA
38853887
retVal = (Backend.isDbms(DBMS.PGSQL) and "super" in privileges)
@@ -3930,18 +3932,20 @@ def geturl(self):
39303932
except (UnicodeError, ValueError):
39313933
pass
39323934
except ParseError:
3933-
if "<html" in (content or ""):
3935+
if re.search(r"(?i)<!DOCTYPE html|<html", content or ""):
39343936
warnMsg = "badly formed HTML at the given URL ('%s'). Going to filter it" % url
39353937
logger.warning(warnMsg)
39363938
filtered = _("".join(re.findall(FORM_SEARCH_REGEX, content)), url)
3937-
try:
3938-
forms = ParseResponse(filtered, backwards_compat=False)
3939-
except ParseError:
3940-
errMsg = "no success"
3941-
if raise_:
3942-
raise SqlmapGenericException(errMsg)
3943-
else:
3944-
logger.debug(errMsg)
3939+
3940+
if filtered and filtered != content:
3941+
try:
3942+
forms = ParseResponse(filtered, backwards_compat=False)
3943+
except ParseError:
3944+
errMsg = "no success"
3945+
if raise_:
3946+
raise SqlmapGenericException(errMsg)
3947+
else:
3948+
logger.debug(errMsg)
39453949

39463950
if forms:
39473951
for form in forms:
@@ -4337,7 +4341,7 @@ def getRequestHeader(request, name):
43374341

43384342
if request and name:
43394343
_ = name.upper()
4340-
retVal = max([value if _ == key.upper() else None for key, value in request.header_items()])
4344+
retVal = max(value if _ == key.upper() else None for key, value in request.header_items())
43414345

43424346
return retVal
43434347

lib/core/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.1.12.0"
22+
VERSION = "1.1.12.1"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -85,7 +85,7 @@
8585
PERMISSION_DENIED_REGEX = r"(command|permission|access)\s*(was|is)?\s*denied"
8686

8787
# Regular expression used for recognition of generic maximum connection messages
88-
MAX_CONNECTIONS_REGEX = r"max.+connections"
88+
MAX_CONNECTIONS_REGEX = r"\bmax.+?\bconnection"
8989

9090
# Maximum consecutive connection errors before asking the user if he wants to continue
9191
MAX_CONSECUTIVE_CONNECTION_ERRORS = 15

lib/techniques/union/test.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _orderByTest(cols):
115115

116116
if not isNullValue(kb.uChar):
117117
for regex in (kb.uChar, r'>\s*%s\s*<' % kb.uChar):
118-
contains = [(count, re.search(regex, _ or "", re.IGNORECASE) is not None) for count, _ in pages.items()]
118+
contains = ((count, re.search(regex, _ or "", re.IGNORECASE) is not None) for count, _ in pages.items())
119119
if len(filter(lambda _: _[1], contains)) == 1:
120120
retVal = filter(lambda _: _[1], contains)[0][0]
121121
break
@@ -178,7 +178,7 @@ def _unionPosition(comment, place, parameter, prefix, suffix, count, where=PAYLO
178178
for position in positions:
179179
# Prepare expression with delimiters
180180
randQuery = randomStr(charCount)
181-
phrase = "%s%s%s".lower() % (kb.chars.start, randQuery, kb.chars.stop)
181+
phrase = ("%s%s%s" % (kb.chars.start, randQuery, kb.chars.stop)).lower()
182182
randQueryProcessed = agent.concatQuery("\'%s\'" % randQuery)
183183
randQueryUnescaped = unescaper.escape(randQueryProcessed)
184184

@@ -188,9 +188,7 @@ def _unionPosition(comment, place, parameter, prefix, suffix, count, where=PAYLO
188188

189189
# Perform the request
190190
page, headers, _ = Request.queryPage(payload, place=place, content=True, raise404=False)
191-
content = "%s%s".lower() % (removeReflectiveValues(page, payload) or "", \
192-
removeReflectiveValues(listToStrValue(headers.headers if headers else None), \
193-
payload, True) or "")
191+
content = ("%s%s" % (removeReflectiveValues(page, payload) or "", removeReflectiveValues(listToStrValue(headers.headers if headers else None), payload, True) or "")).lower()
194192

195193
if content and phrase in content:
196194
validPayload = payload
@@ -200,7 +198,7 @@ def _unionPosition(comment, place, parameter, prefix, suffix, count, where=PAYLO
200198
if where == PAYLOAD.WHERE.ORIGINAL:
201199
# Prepare expression with delimiters
202200
randQuery2 = randomStr(charCount)
203-
phrase2 = "%s%s%s".lower() % (kb.chars.start, randQuery2, kb.chars.stop)
201+
phrase2 = ("%s%s%s" % (kb.chars.start, randQuery2, kb.chars.stop)).lower()
204202
randQueryProcessed2 = agent.concatQuery("\'%s\'" % randQuery2)
205203
randQueryUnescaped2 = unescaper.escape(randQueryProcessed2)
206204

@@ -210,7 +208,7 @@ def _unionPosition(comment, place, parameter, prefix, suffix, count, where=PAYLO
210208

211209
# Perform the request
212210
page, headers, _ = Request.queryPage(payload, place=place, content=True, raise404=False)
213-
content = "%s%s".lower() % (page or "", listToStrValue(headers.headers if headers else None) or "")
211+
content = ("%s%s" % (page or "", listToStrValue(headers.headers if headers else None) or "")).lower()
214212

215213
if not all(_ in content for _ in (phrase, phrase2)):
216214
vector = (position, count, comment, prefix, suffix, kb.uChar, where, kb.unionDuplicates, True)
@@ -223,9 +221,7 @@ def _unionPosition(comment, place, parameter, prefix, suffix, count, where=PAYLO
223221

224222
# Perform the request
225223
page, headers, _ = Request.queryPage(payload, place=place, content=True, raise404=False)
226-
content = "%s%s".lower() % (removeReflectiveValues(page, payload) or "", \
227-
removeReflectiveValues(listToStrValue(headers.headers if headers else None), \
228-
payload, True) or "")
224+
content = ("%s%s" % (removeReflectiveValues(page, payload) or "", removeReflectiveValues(listToStrValue(headers.headers if headers else None), payload, True) or "")).lower()
229225
if content.count(phrase) > 0 and content.count(phrase) < LIMITED_ROWS_TEST_NUMBER:
230226
warnMsg = "output with limited number of rows detected. Switching to partial mode"
231227
logger.warn(warnMsg)
@@ -277,7 +273,7 @@ def _unionTestByCharBruteforce(comment, place, parameter, value, prefix, suffix)
277273
if count:
278274
validPayload, vector = _unionConfirm(comment, place, parameter, prefix, suffix, count)
279275

280-
if not all([validPayload, vector]) and not all([conf.uChar, conf.dbms]):
276+
if not all((validPayload, vector)) and not all((conf.uChar, conf.dbms)):
281277
warnMsg = "if UNION based SQL injection is not detected, "
282278
warnMsg += "please consider "
283279

@@ -298,7 +294,7 @@ def _unionTestByCharBruteforce(comment, place, parameter, value, prefix, suffix)
298294
warnMsg += "forcing the "
299295
warnMsg += "back-end DBMS (e.g. '--dbms=mysql') "
300296

301-
if not all([validPayload, vector]) and not warnMsg.endswith("consider "):
297+
if not all((validPayload, vector)) and not warnMsg.endswith("consider "):
302298
singleTimeWarnMessage(warnMsg)
303299

304300
return validPayload, vector

lib/utils/purge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def purge(directory):
3131
dirpaths = []
3232

3333
for rootpath, directories, filenames in os.walk(directory):
34-
dirpaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in directories])
35-
filepaths.extend([os.path.abspath(os.path.join(rootpath, _)) for _ in filenames])
34+
dirpaths.extend(os.path.abspath(os.path.join(rootpath, _)) for _ in directories)
35+
filepaths.extend(os.path.abspath(os.path.join(rootpath, _)) for _ in filenames)
3636

3737
logger.debug("changing file attributes")
3838
for filepath in filepaths:

txt/checksum.md5

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ d2cdb9e832e18a81e936ca3348144b16 lib/controller/handler.py
2727
5fb9aaf874daa47ea2b672a22740e56b lib/controller/__init__.py
2828
fd69e56ce20a5a49ce10a7a745022378 lib/core/agent.py
2929
8d9d771f7e67582c56a96a8d0ccbe4fc lib/core/bigarray.py
30-
27d55009305e6409dc17f9c58cb87065 lib/core/common.py
30+
d5559313c496c8358640c9646f485a3c lib/core/common.py
3131
54326d3a690f8b26fe5a5da1a589b369 lib/core/convert.py
3232
90b1b08368ac8a859300e6fa6a8c796e lib/core/data.py
3333
1c14bdbf47b8dba31f73da9ad731a54a lib/core/datatype.py
@@ -46,7 +46,7 @@ e1c000db9be27f973569b1a430629037 lib/core/option.py
4646
760d9df2a27ded29109b390ab202e72d lib/core/replication.py
4747
a2466b62e67f8b31736bac4dac590e51 lib/core/revision.py
4848
02d4762140a72fd44668d3dab5eabda9 lib/core/session.py
49-
3f8a858155092e17d146cd6021057338 lib/core/settings.py
49+
0b215c469175a858a36a8858b22c475e lib/core/settings.py
5050
35bffbad762eb9e03db9e93b1c991103 lib/core/shell.py
5151
a59ec28371ae067a6fdd8f810edbee3d lib/core/subprocessng.py
5252
d5a04d672a18f78deb2839c3745ff83c lib/core/target.py
@@ -96,7 +96,7 @@ ca47f20b11f58ce60a0ddfcfca242d3f lib/techniques/blind/inference.py
9696
5953b814b91e6a03d26f319203b48d01 lib/techniques/error/use.py
9797
5fb9aaf874daa47ea2b672a22740e56b lib/techniques/__init__.py
9898
5fb9aaf874daa47ea2b672a22740e56b lib/techniques/union/__init__.py
99-
fcc3a6ac3b5f7aad86686e5f9adc7a43 lib/techniques/union/test.py
99+
882bed15db948bd0487d24ff072a1593 lib/techniques/union/test.py
100100
505682f95cb23573dd60bf6d0063a632 lib/techniques/union/use.py
101101
452cb280aa51a4ddf38d94534a6e8d5f lib/utils/api.py
102102
48c3f8216b64825c50f5304cb4dadd95 lib/utils/brute.py
@@ -110,7 +110,7 @@ f20ae1aa6a8d1d5373ace1f7ed3476a7 lib/utils/htmlentities.py
110110
5fb9aaf874daa47ea2b672a22740e56b lib/utils/__init__.py
111111
06cd61b634ca6142281da699a504cc85 lib/utils/pivotdumptable.py
112112
56c922696bd3d05d7be96e73b0650c4e lib/utils/progress.py
113-
a861c303293e2e6665b02a57f67fc050 lib/utils/purge.py
113+
77ae65dba6d0fc69dfb96f800537308d lib/utils/purge.py
114114
760290393e35e5f53f15ba46e09d59dd lib/utils/search.py
115115
b6898e77038842c853932a6662c011be lib/utils/sqlalchemy.py
116116
36b95bc7fa2cf4f005a86e516a8cba68 lib/utils/timeout.py

0 commit comments

Comments
 (0)