mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-22 14:19:03 +00:00
Minor refactoring (drei stuff)
This commit is contained in:
@@ -16,6 +16,7 @@ import zlib
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import extractErrorMessage
|
||||
from lib.core.common import extractRegexResult
|
||||
from lib.core.common import filterNone
|
||||
from lib.core.common import getPublicTypeMembers
|
||||
from lib.core.common import getSafeExString
|
||||
from lib.core.common import getUnicode
|
||||
@@ -100,7 +101,7 @@ def forgeHeaders(items=None, base=None):
|
||||
|
||||
if ("%s=" % getUnicode(cookie.name)) in getUnicode(headers[HTTP_HEADER.COOKIE]):
|
||||
if conf.loadCookies:
|
||||
conf.httpHeaders = filter(None, ((item if item[0] != HTTP_HEADER.COOKIE else None) for item in conf.httpHeaders))
|
||||
conf.httpHeaders = filterNone((item if item[0] != HTTP_HEADER.COOKIE else None) for item in conf.httpHeaders)
|
||||
elif kb.mergeCookies is None:
|
||||
message = "you provided a HTTP %s header value. " % HTTP_HEADER.COOKIE
|
||||
message += "The target URL provided its own cookies within "
|
||||
|
||||
@@ -32,6 +32,7 @@ from lib.core.common import dataToStdout
|
||||
from lib.core.common import escapeJsonValue
|
||||
from lib.core.common import evaluateCode
|
||||
from lib.core.common import extractRegexResult
|
||||
from lib.core.common import filterNone
|
||||
from lib.core.common import findMultipartPostBoundary
|
||||
from lib.core.common import getCurrentThreadData
|
||||
from lib.core.common import getHeader
|
||||
@@ -600,7 +601,7 @@ class Connect(object):
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
page = page if isinstance(page, unicode) else getUnicode(page)
|
||||
page = getUnicode(page)
|
||||
|
||||
code = ex.code
|
||||
status = getSafeExString(ex)
|
||||
@@ -758,7 +759,7 @@ class Connect(object):
|
||||
page, responseHeaders, code = function(page, responseHeaders, code)
|
||||
except Exception as ex:
|
||||
errMsg = "error occurred while running preprocess "
|
||||
errMsg += "function '%s' ('%s')" % (function.func_name, getSafeExString(ex))
|
||||
errMsg += "function '%s' ('%s')" % (function.__name__, getSafeExString(ex))
|
||||
raise SqlmapGenericException(errMsg)
|
||||
|
||||
threadData.lastPage = page
|
||||
@@ -857,11 +858,11 @@ class Connect(object):
|
||||
payload = function(payload=payload, headers=auxHeaders, delimiter=delimiter, hints=hints)
|
||||
except Exception as ex:
|
||||
errMsg = "error occurred while running tamper "
|
||||
errMsg += "function '%s' ('%s')" % (function.func_name, getSafeExString(ex))
|
||||
errMsg += "function '%s' ('%s')" % (function.__name__, getSafeExString(ex))
|
||||
raise SqlmapGenericException(errMsg)
|
||||
|
||||
if not isinstance(payload, six.string_types):
|
||||
errMsg = "tamper function '%s' returns " % function.func_name
|
||||
errMsg = "tamper function '%s' returns " % function.__name__
|
||||
errMsg += "invalid payload type ('%s')" % type(payload)
|
||||
raise SqlmapValueException(errMsg)
|
||||
|
||||
@@ -1095,7 +1096,7 @@ class Connect(object):
|
||||
else:
|
||||
query = None
|
||||
|
||||
for item in filter(None, (get, post if not kb.postHint else None, query)):
|
||||
for item in filterNone((get, post if not kb.postHint else None, query)):
|
||||
for part in item.split(delimiter):
|
||||
if '=' in part:
|
||||
name, value = part.split('=', 1)
|
||||
|
||||
@@ -9,6 +9,7 @@ import distutils.version
|
||||
import re
|
||||
import socket
|
||||
|
||||
from lib.core.common import filterNone
|
||||
from lib.core.common import getSafeExString
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
@@ -25,7 +26,7 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
_protocols = filter(None, (getattr(ssl, _, None) for _ in ("PROTOCOL_TLSv1_2", "PROTOCOL_TLSv1_1", "PROTOCOL_TLSv1", "PROTOCOL_SSLv3", "PROTOCOL_SSLv23", "PROTOCOL_SSLv2")))
|
||||
_protocols = filterNone(getattr(ssl, _, None) for _ in ("PROTOCOL_TLSv1_2", "PROTOCOL_TLSv1_1", "PROTOCOL_TLSv1", "PROTOCOL_SSLv3", "PROTOCOL_SSLv23", "PROTOCOL_SSLv2"))
|
||||
|
||||
class HTTPSConnection(_http_client.HTTPSConnection):
|
||||
"""
|
||||
|
||||
@@ -17,6 +17,7 @@ from lib.core.common import calculateDeltaSeconds
|
||||
from lib.core.common import cleanQuery
|
||||
from lib.core.common import expandAsteriskForColumns
|
||||
from lib.core.common import extractExpectedValue
|
||||
from lib.core.common import filterNone
|
||||
from lib.core.common import getPublicTypeMembers
|
||||
from lib.core.common import getTechniqueData
|
||||
from lib.core.common import hashDBRetrieve
|
||||
@@ -431,7 +432,7 @@ def getValue(expression, blind=True, union=True, error=True, time=True, fromUser
|
||||
found = (value is not None) or (value is None and expectingNone) or count >= MAX_TECHNIQUES_PER_VALUE
|
||||
|
||||
if found and conf.dnsDomain:
|
||||
_ = "".join(filter(None, (key if isTechniqueAvailable(value) else None for key, value in {'E': PAYLOAD.TECHNIQUE.ERROR, 'Q': PAYLOAD.TECHNIQUE.QUERY, 'U': PAYLOAD.TECHNIQUE.UNION}.items())))
|
||||
_ = "".join(filterNone(key if isTechniqueAvailable(value) else None for key, value in {'E': PAYLOAD.TECHNIQUE.ERROR, 'Q': PAYLOAD.TECHNIQUE.QUERY, 'U': PAYLOAD.TECHNIQUE.UNION}.items()))
|
||||
warnMsg = "option '--dns-domain' will be ignored "
|
||||
warnMsg += "as faster techniques are usable "
|
||||
warnMsg += "(%s) " % _
|
||||
|
||||
Reference in New Issue
Block a user