mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-03 05:04:11 +03:00
minor refactoring
This commit is contained in:
parent
3cd8f47686
commit
872a73f631
|
@ -39,6 +39,7 @@ from lib.core.convert import urldecode
|
|||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.core.enums import HTTPHEADER
|
||||
from lib.core.enums import HTTPMETHOD
|
||||
from lib.core.enums import PAYLOAD
|
||||
from lib.core.enums import PLACE
|
||||
|
@ -358,7 +359,7 @@ def start():
|
|||
setCookieAsInjectable = False
|
||||
|
||||
if setCookieAsInjectable:
|
||||
conf.httpHeaders.append(("Cookie", cookieStr))
|
||||
conf.httpHeaders.append((HTTPHEADER.COOKIE, cookieStr))
|
||||
conf.parameters[PLACE.COOKIE] = cookieStr
|
||||
__paramDict = paramToDict(PLACE.COOKIE, cookieStr)
|
||||
|
||||
|
|
|
@ -87,8 +87,11 @@ class MOBILES:
|
|||
|
||||
class HTTPHEADER:
|
||||
ACCEPT = "Accept"
|
||||
ACCEPT_CHARSET = "Accept-Charset"
|
||||
ACCEPT_ENCODING = "Accept-Encoding"
|
||||
ACCEPT_LANGUAGE = "Accept-Language"
|
||||
AUTHORIZATION = "Authorization"
|
||||
CACHE_CONTROL = "Cache-Control"
|
||||
CONNECTION = "Connection"
|
||||
CONTENT_ENCODING = "Content-Encoding"
|
||||
CONTENT_LENGTH = "Content-Length"
|
||||
|
@ -96,7 +99,9 @@ class HTTPHEADER:
|
|||
CONTENT_TYPE = "Content-Type"
|
||||
COOKIE = "Cookie"
|
||||
HOST = "Host"
|
||||
PROXY_AUTHORIZATION = "Proxy-authorization"
|
||||
PRAGMA = "Pragma"
|
||||
PROXY_AUTHORIZATION = "Proxy-Authorization"
|
||||
PROXY_CONNECTION = "Proxy-Connection"
|
||||
RANGE = "Range"
|
||||
REFERER = "Referer"
|
||||
USER_AGENT = "User-Agent"
|
||||
|
|
|
@ -289,11 +289,11 @@ def __feedTargetsDict(reqFile, addedTargetUrls):
|
|||
# Avoid to add a static content length header to
|
||||
# conf.httpHeaders and consider the following lines as
|
||||
# POSTed data
|
||||
if key == "Content-Length":
|
||||
if key == HTTPHEADER.CONTENT_LENGTH:
|
||||
params = True
|
||||
|
||||
# Avoid proxy and connection type related headers
|
||||
elif key not in ( "Proxy-Connection", "Connection" ):
|
||||
elif key not in ( HTTPHEADER.PROXY_CONNECTION, HTTPHEADER.CONNECTION ):
|
||||
conf.httpHeaders.append((str(key), str(value)))
|
||||
|
||||
if conf.scope:
|
||||
|
@ -1080,16 +1080,16 @@ def __setHTTPExtraHeaders():
|
|||
conf.httpHeaders.append((header, value))
|
||||
|
||||
elif not conf.httpHeaders or len(conf.httpHeaders) == 1:
|
||||
conf.httpHeaders.append(("Accept-Language", "en-us,en;q=0.5"))
|
||||
conf.httpHeaders.append((HTTPHEADER.ACCEPT_LANGUAGE, "en-us,en;q=0.5"))
|
||||
if not conf.charset:
|
||||
conf.httpHeaders.append(("Accept-Charset", "ISO-8859-15,utf-8;q=0.7,*;q=0.7"))
|
||||
conf.httpHeaders.append((HTTPHEADER.ACCEPT_CHARSET, "ISO-8859-15,utf-8;q=0.7,*;q=0.7"))
|
||||
else:
|
||||
conf.httpHeaders.append(("Accept-Charset", "%s;q=0.7,*;q=0.1" % conf.charset))
|
||||
conf.httpHeaders.append((HTTPHEADER.ACCEPT_CHARSET, "%s;q=0.7,*;q=0.1" % conf.charset))
|
||||
|
||||
# Invalidating any caching mechanism in between
|
||||
# Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||
conf.httpHeaders.append(("Cache-Control", "no-cache,no-store"))
|
||||
conf.httpHeaders.append(("Pragma", "no-cache"))
|
||||
conf.httpHeaders.append((HTTPHEADER.CACHE_CONTROL, "no-cache,no-store"))
|
||||
conf.httpHeaders.append((HTTPHEADER.PRAGMA, "no-cache"))
|
||||
|
||||
def __defaultHTTPUserAgent():
|
||||
"""
|
||||
|
|
|
@ -26,6 +26,7 @@ from lib.core.common import singleTimeLogMessage
|
|||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.core.enums import HTTPHEADER
|
||||
from lib.core.exception import sqlmapDataException
|
||||
from lib.core.settings import ML
|
||||
from lib.core.settings import META_CHARSET_REGEX
|
||||
|
@ -43,20 +44,20 @@ def forgeHeaders(cookie, ua, referer):
|
|||
headers = {}
|
||||
|
||||
for header, value in conf.httpHeaders:
|
||||
if cookie and header == "Cookie":
|
||||
if cookie and header == HTTPHEADER.COOKIE:
|
||||
headers[header] = cookie
|
||||
elif ua and header == "User-Agent":
|
||||
elif ua and header == HTTPHEADER.USER_AGENT:
|
||||
headers[header] = ua
|
||||
elif referer and header == "Referer":
|
||||
elif referer and header == HTTPHEADER.REFERER:
|
||||
headers[header] = referer
|
||||
else:
|
||||
headers[header] = value
|
||||
|
||||
if kb.redirectSetCookie and not conf.dropSetCookie:
|
||||
if "Cookie" in headers:
|
||||
headers["Cookie"] = "%s; %s" % (headers["Cookie"], kb.redirectSetCookie)
|
||||
if HTTPHEADER.COOKIE in headers:
|
||||
headers[HTTPHEADER.COOKIE] = "%s; %s" % (headers[HTTPHEADER.COOKIE], kb.redirectSetCookie)
|
||||
else:
|
||||
headers["Cookie"] = kb.redirectSetCookie
|
||||
headers[HTTPHEADER.COOKIE] = kb.redirectSetCookie
|
||||
|
||||
return headers
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user