revert of some HTTP headers handling

This commit is contained in:
Miroslav Stampar 2010-11-08 13:26:45 +00:00
parent 0c8918bf07
commit fda8752dca
5 changed files with 12 additions and 14 deletions

View File

@ -377,7 +377,7 @@ def checkNullConnection():
infoMsg = "NULL connection is supported with HEAD header"
logger.info(infoMsg)
else:
page, headers = Request.getPage(auxHeaders={NULLCONNECTION.RANGE: "bytes=-1"})
page, headers = Request.getPage(auxHeaders={"Range": "bytes=-1"})
if page and len(page) == 1 and 'Content-Range' in headers:
kb.nullConnection = NULLCONNECTION.RANGE

View File

@ -195,7 +195,7 @@ def start():
setCookieAsInjectable = False
if setCookieAsInjectable:
conf.httpHeaders.append((PLACE.COOKIE, cookieStr))
conf.httpHeaders.append(("Cookie", cookieStr))
conf.parameters[PLACE.COOKIE] = cookieStr
__paramDict = paramToDict(PLACE.COOKIE, cookieStr)

View File

@ -43,7 +43,6 @@ from lib.core.data import paths
from lib.core.data import queries
from lib.core.datatype import advancedDict
from lib.core.enums import HTTPMETHOD
from lib.core.enums import PLACE
from lib.core.enums import PRIORITY
from lib.core.exception import sqlmapFilePathException
from lib.core.exception import sqlmapGenericException
@ -848,19 +847,19 @@ def __setHTTPUserAgent():
debugMsg = "setting the HTTP User-Agent header"
logger.debug(debugMsg)
conf.httpHeaders.append((PLACE.UA, conf.agent))
conf.httpHeaders.append(("User-Agent", conf.agent))
return
if not conf.userAgentsFile:
addDefaultUserAgent = True
for header, _ in conf.httpHeaders:
if header == PLACE.UA:
if header == "User-Agent":
addDefaultUserAgent = False
break
if addDefaultUserAgent:
conf.httpHeaders.append((PLACE.UA, __defaultHTTPUserAgent()))
conf.httpHeaders.append(("User-Agent", __defaultHTTPUserAgent()))
return
@ -876,7 +875,7 @@ def __setHTTPUserAgent():
warnMsg += "file '%s'" % conf.userAgentsFile
logger.warn(warnMsg)
conf.httpHeaders.append((PLACE.UA, __defaultHTTPUserAgent()))
conf.httpHeaders.append(("User-Agent", __defaultHTTPUserAgent()))
return
@ -888,7 +887,7 @@ def __setHTTPUserAgent():
__userAgent = kb.userAgents[randomRange(stop=__count)]
__userAgent = sanitizeStr(__userAgent)
conf.httpHeaders.append((PLACE.UA, __userAgent))
conf.httpHeaders.append(("User-Agent", __userAgent))
logMsg = "fetched random HTTP User-Agent header from "
logMsg += "file '%s': %s" % (conf.userAgentsFile, __userAgent)
@ -915,7 +914,7 @@ def __setHTTPCookies():
logger.debug(debugMsg)
conf.httpHeaders.append(("Connection", "Keep-Alive"))
conf.httpHeaders.append((PLACE.COOKIE, conf.cookie))
conf.httpHeaders.append(("Cookie", conf.cookie))
def __setHTTPTimeout():
"""

View File

@ -21,7 +21,6 @@ from lib.core.common import posixToNtSlashes
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.enums import PLACE
from lib.parse.headers import headersParser
from lib.parse.html import htmlParser
@ -34,9 +33,9 @@ def forgeHeaders(cookie, ua):
headers = {}
for header, value in conf.httpHeaders:
if cookie and header == PLACE.COOKIE:
if cookie and header == "Cookie":
headers[header] = cookie
elif ua and header == PLACE.UA:
elif ua and header == "User-Agent":
headers[header] = ua
else:
headers[header] = value

View File

@ -166,7 +166,7 @@ class Connect:
requestHeaders += "\n".join(["%s: %s" % (header, value) for header, value in req.header_items()])
if not req.has_header(PLACE.COOKIE) and cookieStr:
if not req.has_header("Cookie") and cookieStr:
requestHeaders += "\n%s" % cookieStr[:-2]
if not req.has_header("Connection"):
@ -370,7 +370,7 @@ class Connect:
if not auxHeaders:
auxHeaders = {}
auxHeaders[NULLCONNECTION.RANGE] = "bytes=-1"
auxHeaders["Range"] = "bytes=-1"
_, headers = Connect.getPage(url=uri, get=get, post=post, cookie=cookie, ua=ua, silent=silent, method=method, auxHeaders=auxHeaders, raise404=raise404)