mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-08 05:31:32 +00:00
If it works, don't touch. I touched
This commit is contained in:
@@ -138,7 +138,7 @@ class Agent(object):
|
||||
value = origValue
|
||||
elif where == PAYLOAD.WHERE.NEGATIVE:
|
||||
if conf.invalidLogical:
|
||||
match = re.search(r'\A[^ ]+', newValue)
|
||||
match = re.search(r"\A[^ ]+", newValue)
|
||||
newValue = newValue[len(match.group() if match else ""):]
|
||||
_ = randomInt(2)
|
||||
value = "%s%s AND %s=%s" % (origValue, match.group() if match else "", _, _ + 1)
|
||||
@@ -756,13 +756,13 @@ class Agent(object):
|
||||
if fromTable and query.endswith(fromTable):
|
||||
query = query[:-len(fromTable)]
|
||||
|
||||
topNumRegex = re.search("\ATOP\s+([\d]+)\s+", query, re.I)
|
||||
topNumRegex = re.search(r"\ATOP\s+([\d]+)\s+", query, re.I)
|
||||
if topNumRegex:
|
||||
topNum = topNumRegex.group(1)
|
||||
query = query[len("TOP %s " % topNum):]
|
||||
unionQuery += "TOP %s " % topNum
|
||||
|
||||
intoRegExp = re.search("(\s+INTO (DUMP|OUT)FILE\s+\'(.+?)\')", query, re.I)
|
||||
intoRegExp = re.search(r"(\s+INTO (DUMP|OUT)FILE\s+'(.+?)')", query, re.I)
|
||||
|
||||
if intoRegExp:
|
||||
intoRegExp = intoRegExp.group(1)
|
||||
@@ -810,7 +810,7 @@ class Agent(object):
|
||||
stopLimit = None
|
||||
limitCond = True
|
||||
|
||||
topLimit = re.search("TOP\s+([\d]+)\s+", expression, re.I)
|
||||
topLimit = re.search(r"TOP\s+([\d]+)\s+", expression, re.I)
|
||||
|
||||
limitRegExp = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query, expression, re.I)
|
||||
|
||||
@@ -958,7 +958,7 @@ class Agent(object):
|
||||
orderBy = limitedQuery[limitedQuery.index(" ORDER BY "):]
|
||||
limitedQuery = limitedQuery[:limitedQuery.index(" ORDER BY ")]
|
||||
|
||||
notDistincts = re.findall("DISTINCT[\(\s+](.+?)\)*\s+", limitedQuery, re.I)
|
||||
notDistincts = re.findall(r"DISTINCT[\(\s+](.+?)\)*\s+", limitedQuery, re.I)
|
||||
|
||||
for notDistinct in notDistincts:
|
||||
limitedQuery = limitedQuery.replace("DISTINCT(%s)" % notDistinct, notDistinct)
|
||||
@@ -975,7 +975,7 @@ class Agent(object):
|
||||
limitedQuery = limitedQuery.replace(" (SELECT TOP %s" % startTopNums, " (SELECT TOP %d" % num)
|
||||
forgeNotIn = False
|
||||
else:
|
||||
topNum = re.search("TOP\s+([\d]+)\s+", limitedQuery, re.I).group(1)
|
||||
topNum = re.search(r"TOP\s+([\d]+)\s+", limitedQuery, re.I).group(1)
|
||||
limitedQuery = limitedQuery.replace("TOP %s " % topNum, "")
|
||||
|
||||
if forgeNotIn:
|
||||
@@ -991,7 +991,7 @@ class Agent(object):
|
||||
limitedQuery += "NOT IN (%s" % (limitStr % num)
|
||||
limitedQuery += "%s %s ORDER BY %s) ORDER BY %s" % (self.nullAndCastField(uniqueField or field), fromFrom, uniqueField or "1", uniqueField or "1")
|
||||
else:
|
||||
match = re.search(" ORDER BY (\w+)\Z", query)
|
||||
match = re.search(r" ORDER BY (\w+)\Z", query)
|
||||
field = match.group(1) if match else field
|
||||
|
||||
if " WHERE " in limitedQuery:
|
||||
@@ -1071,7 +1071,7 @@ class Agent(object):
|
||||
"""
|
||||
|
||||
_ = re.escape(PAYLOAD_DELIMITER)
|
||||
return extractRegexResult("(?s)%s(?P<result>.*?)%s" % (_, _), value)
|
||||
return extractRegexResult(r"(?s)%s(?P<result>.*?)%s" % (_, _), value)
|
||||
|
||||
def replacePayload(self, value, payload):
|
||||
"""
|
||||
@@ -1079,7 +1079,7 @@ class Agent(object):
|
||||
"""
|
||||
|
||||
_ = re.escape(PAYLOAD_DELIMITER)
|
||||
return re.sub("(?s)(%s.*?%s)" % (_, _), ("%s%s%s" % (PAYLOAD_DELIMITER, getUnicode(payload), PAYLOAD_DELIMITER)).replace("\\", r"\\"), value) if value else value
|
||||
return re.sub(r"(?s)(%s.*?%s)" % (_, _), ("%s%s%s" % (PAYLOAD_DELIMITER, getUnicode(payload), PAYLOAD_DELIMITER)).replace("\\", r"\\"), value) if value else value
|
||||
|
||||
def runAsDBMSUser(self, query):
|
||||
if conf.dbmsCred and "Ad Hoc Distributed Queries" not in query:
|
||||
|
||||
@@ -1208,7 +1208,7 @@ def cleanQuery(query):
|
||||
|
||||
for sqlStatements in SQL_STATEMENTS.values():
|
||||
for sqlStatement in sqlStatements:
|
||||
queryMatch = re.search("(?i)\b(%s)\b" % sqlStatement.replace("(", "").replace(")", "").strip(), query)
|
||||
queryMatch = re.search(r"(?i)\b(%s)\b" % sqlStatement.replace("(", "").replace(")", "").strip(), query)
|
||||
|
||||
if queryMatch and "sys_exec" not in query:
|
||||
retVal = retVal.replace(queryMatch.group(1), sqlStatement.upper())
|
||||
@@ -1387,13 +1387,12 @@ def parseTargetUrl():
|
||||
|
||||
originalUrl = conf.url
|
||||
|
||||
if re.search("\[.+\]", conf.url) and not socket.has_ipv6:
|
||||
if re.search(r"\[.+\]", conf.url) and not socket.has_ipv6:
|
||||
errMsg = "IPv6 addressing is not supported "
|
||||
errMsg += "on this platform"
|
||||
raise SqlmapGenericException(errMsg)
|
||||
|
||||
if not re.search("^http[s]*://", conf.url, re.I) and \
|
||||
not re.search("^ws[s]*://", conf.url, re.I):
|
||||
if not re.search(r"^http[s]*://", conf.url, re.I) and not re.search(r"^ws[s]*://", conf.url, re.I):
|
||||
if ":443/" in conf.url:
|
||||
conf.url = "https://" + conf.url
|
||||
else:
|
||||
@@ -1410,7 +1409,7 @@ def parseTargetUrl():
|
||||
errMsg += "in the hostname part"
|
||||
raise SqlmapGenericException(errMsg)
|
||||
|
||||
hostnamePort = urlSplit.netloc.split(":") if not re.search("\[.+\]", urlSplit.netloc) else filter(None, (re.search("\[.+\]", urlSplit.netloc).group(0), re.search("\](:(?P<port>\d+))?", urlSplit.netloc).group("port")))
|
||||
hostnamePort = urlSplit.netloc.split(":") if not re.search(r"\[.+\]", urlSplit.netloc) else filter(None, (re.search("\[.+\]", urlSplit.netloc).group(0), re.search(r"\](:(?P<port>\d+))?", urlSplit.netloc).group("port")))
|
||||
|
||||
conf.scheme = (urlSplit.scheme.strip().lower() or "http") if not conf.forceSSL else "https"
|
||||
conf.path = urlSplit.path.strip()
|
||||
@@ -1426,7 +1425,7 @@ def parseTargetUrl():
|
||||
except UnicodeError:
|
||||
_ = None
|
||||
|
||||
if any((_ is None, re.search(r'\s', conf.hostname), '..' in conf.hostname, conf.hostname.startswith('.'), '\n' in originalUrl)):
|
||||
if any((_ is None, re.search(r"\s", conf.hostname), '..' in conf.hostname, conf.hostname.startswith('.'), '\n' in originalUrl)):
|
||||
errMsg = "invalid target URL ('%s')" % originalUrl
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
@@ -1559,7 +1558,7 @@ def parseUnionPage(page):
|
||||
data = BigArray()
|
||||
keys = set()
|
||||
|
||||
for match in re.finditer("%s(.*?)%s" % (kb.chars.start, kb.chars.stop), page, re.DOTALL | re.IGNORECASE):
|
||||
for match in re.finditer(r"%s(.*?)%s" % (kb.chars.start, kb.chars.stop), page, re.DOTALL | re.IGNORECASE):
|
||||
entry = match.group(1)
|
||||
|
||||
if kb.chars.start in entry:
|
||||
@@ -1885,7 +1884,7 @@ def isWindowsDriveLetterPath(filepath):
|
||||
False
|
||||
"""
|
||||
|
||||
return re.search("\A[\w]\:", filepath) is not None
|
||||
return re.search(r"\A[\w]\:", filepath) is not None
|
||||
|
||||
def posixToNtSlashes(filepath):
|
||||
"""
|
||||
@@ -2579,7 +2578,7 @@ def urlencode(value, safe="%&=-_", convall=False, limit=False, spaceplus=False):
|
||||
# encoded (when not representing URL encoded char)
|
||||
# except in cases when tampering scripts are used
|
||||
if all('%' in _ for _ in (safe, value)) and not kb.tamperFunctions:
|
||||
value = re.sub("%(?![0-9a-fA-F]{2})", "%25", value)
|
||||
value = re.sub(r"%(?![0-9a-fA-F]{2})", "%25", value)
|
||||
|
||||
while True:
|
||||
result = urllib.quote(utf8encode(value), safe)
|
||||
@@ -3277,7 +3276,7 @@ def unhandledExceptionMessage():
|
||||
errMsg += "sqlmap version: %s\n" % VERSION_STRING[VERSION_STRING.find('/') + 1:]
|
||||
errMsg += "Python version: %s\n" % PYVERSION
|
||||
errMsg += "Operating system: %s\n" % PLATFORM
|
||||
errMsg += "Command line: %s\n" % re.sub(r".+?\bsqlmap.py\b", "sqlmap.py", getUnicode(" ".join(sys.argv), encoding=sys.stdin.encoding))
|
||||
errMsg += "Command line: %s\n" % re.sub(r".+?\bsqlmap\.py\b", "sqlmap.py", getUnicode(" ".join(sys.argv), encoding=sys.stdin.encoding))
|
||||
errMsg += "Technique: %s\n" % (enumValueToNameLookup(PAYLOAD.TECHNIQUE, kb.technique) if kb.get("technique") else ("DIRECT" if conf.get("direct") else None))
|
||||
errMsg += "Back-end DBMS:"
|
||||
|
||||
@@ -3376,7 +3375,7 @@ def maskSensitiveData(msg):
|
||||
retVal = getUnicode(msg)
|
||||
|
||||
for item in filter(None, (conf.get(_) for _ in SENSITIVE_OPTIONS)):
|
||||
regex = SENSITIVE_DATA_REGEX % re.sub("(\W)", r"\\\1", getUnicode(item))
|
||||
regex = SENSITIVE_DATA_REGEX % re.sub(r"(\W)", r"\\\1", getUnicode(item))
|
||||
while extractRegexResult(regex, retVal):
|
||||
value = extractRegexResult(regex, retVal)
|
||||
retVal = retVal.replace(value, '*' * len(value))
|
||||
@@ -3777,7 +3776,7 @@ def randomizeParameterValue(value):
|
||||
|
||||
value = re.sub(r"%[0-9a-fA-F]{2}", "", value)
|
||||
|
||||
for match in re.finditer('[A-Z]+', value):
|
||||
for match in re.finditer(r"[A-Z]+", value):
|
||||
while True:
|
||||
original = match.group()
|
||||
candidate = randomStr(len(match.group())).upper()
|
||||
@@ -3786,7 +3785,7 @@ def randomizeParameterValue(value):
|
||||
|
||||
retVal = retVal.replace(original, candidate)
|
||||
|
||||
for match in re.finditer('[a-z]+', value):
|
||||
for match in re.finditer(r"[a-z]+", value):
|
||||
while True:
|
||||
original = match.group()
|
||||
candidate = randomStr(len(match.group())).lower()
|
||||
@@ -3795,7 +3794,7 @@ def randomizeParameterValue(value):
|
||||
|
||||
retVal = retVal.replace(original, candidate)
|
||||
|
||||
for match in re.finditer('[0-9]+', value):
|
||||
for match in re.finditer(r"[0-9]+", value):
|
||||
while True:
|
||||
original = match.group()
|
||||
candidate = str(randomInt(len(match.group())))
|
||||
@@ -4034,7 +4033,7 @@ def getHostHeader(url):
|
||||
if url:
|
||||
retVal = urlparse.urlparse(url).netloc
|
||||
|
||||
if re.search("http(s)?://\[.+\]", url, re.I):
|
||||
if re.search(r"http(s)?://\[.+\]", url, re.I):
|
||||
retVal = extractRegexResult("http(s)?://\[(?P<result>.+)\]", url)
|
||||
elif any(retVal.endswith(':%d' % _) for _ in (80, 443)):
|
||||
retVal = retVal.split(':')[0]
|
||||
|
||||
@@ -434,7 +434,7 @@ def _setMultipleTargets():
|
||||
files.sort()
|
||||
|
||||
for reqFile in files:
|
||||
if not re.search("([\d]+)\-request", reqFile):
|
||||
if not re.search(r"([\d]+)\-request", reqFile):
|
||||
continue
|
||||
|
||||
_feedTargetsDict(os.path.join(conf.logFile, reqFile), addedTargetUrls)
|
||||
@@ -666,7 +666,7 @@ def _setDBMSAuthentication():
|
||||
debugMsg = "setting the DBMS authentication credentials"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
match = re.search("^(.+?):(.*?)$", conf.dbmsCred)
|
||||
match = re.search(r"^(.+?):(.*?)$", conf.dbmsCred)
|
||||
|
||||
if not match:
|
||||
errMsg = "DBMS authentication credentials value must be in format "
|
||||
@@ -861,7 +861,7 @@ def _setDBMS():
|
||||
logger.debug(debugMsg)
|
||||
|
||||
conf.dbms = conf.dbms.lower()
|
||||
regex = re.search("%s ([\d\.]+)" % ("(%s)" % "|".join([alias for alias in SUPPORTED_DBMS])), conf.dbms, re.I)
|
||||
regex = re.search(r"%s ([\d\.]+)" % ("(%s)" % "|".join([alias for alias in SUPPORTED_DBMS])), conf.dbms, re.I)
|
||||
|
||||
if regex:
|
||||
conf.dbms = regex.group(1)
|
||||
@@ -1148,7 +1148,7 @@ def _setHTTPHandlers():
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
if conf.proxyCred:
|
||||
_ = re.search("^(.*?):(.*?)$", conf.proxyCred)
|
||||
_ = re.search(r"\A(.*?):(.*?)\Z", conf.proxyCred)
|
||||
if not _:
|
||||
errMsg = "proxy authentication credentials "
|
||||
errMsg += "value must be in format username:password"
|
||||
@@ -1256,7 +1256,7 @@ def _setSafeVisit():
|
||||
errMsg = "invalid format of a safe request file"
|
||||
raise SqlmapSyntaxException, errMsg
|
||||
else:
|
||||
if not re.search("^http[s]*://", conf.safeUrl):
|
||||
if not re.search(r"\Ahttp[s]*://", conf.safeUrl):
|
||||
if ":443/" in conf.safeUrl:
|
||||
conf.safeUrl = "https://" + conf.safeUrl
|
||||
else:
|
||||
|
||||
@@ -597,7 +597,7 @@ MAX_TOTAL_REDIRECTIONS = 10
|
||||
MAX_DNS_LABEL = 63
|
||||
|
||||
# Alphabet used for prefix and suffix strings of name resolution requests in DNS technique (excluding hexadecimal chars for not mixing with inner content)
|
||||
DNS_BOUNDARIES_ALPHABET = re.sub("[a-fA-F]", "", string.ascii_letters)
|
||||
DNS_BOUNDARIES_ALPHABET = re.sub(r"[a-fA-F]", "", string.ascii_letters)
|
||||
|
||||
# Alphabet used for heuristic checks
|
||||
HEURISTIC_CHECK_ALPHABET = ('"', '\'', ')', '(', ',', '.')
|
||||
|
||||
Reference in New Issue
Block a user