diff --git a/lib/core/option.py b/lib/core/option.py index 02ad9dfe8..0bf43f825 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1407,7 +1407,6 @@ def __setKnowledgeBaseAttributes(flushAll=True): kb.explicitSettings = set() kb.errorIsNone = True kb.forcedDbms = None - kb.headersCount = 0 kb.headersFp = {} kb.heuristicTest = None kb.hintValue = None @@ -1445,6 +1444,7 @@ def __setKnowledgeBaseAttributes(flushAll=True): kb.pageEncoding = DEFAULT_PAGE_ENCODING kb.pageStable = None kb.partRun = None + kb.processResponseCounter = 0 kb.proxyAuthHeader = None kb.queryCounter = 0 kb.redirectSetCookie = None diff --git a/lib/core/settings.py b/lib/core/settings.py index 4098f51db..7a72873bf 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -392,6 +392,9 @@ BIGARRAY_CHUNK_LENGTH = 4096 # Only console display last n table rows TRIM_STDOUT_DUMP_SIZE = 256 +# Parse response headers only first couple of times +PARSE_HEADERS_LIMIT = 3 + # Step used in ORDER BY technique used for finding the right number of columns in UNION query injections ORDER_BY_STEP = 10 diff --git a/lib/parse/headers.py b/lib/parse/headers.py index 07e58de42..c0fbd0809 100644 --- a/lib/parse/headers.py +++ b/lib/parse/headers.py @@ -22,12 +22,6 @@ def headersParser(headers): and the web application technology """ - # It is enough to parse the headers on first four HTTP responses - if kb.headersCount > 3: - return - - kb.headersCount += 1 - topHeaders = { "cookie": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "cookie.xml"), "microsoftsharepointteamservices": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "sharepoint.xml"), diff --git a/lib/request/basic.py b/lib/request/basic.py index 2258acdc9..74315b447 100644 --- a/lib/request/basic.py +++ b/lib/request/basic.py @@ -29,6 +29,7 @@ from lib.core.data import logger from lib.core.exception import sqlmapDataException from lib.core.settings import ML from lib.core.settings import META_CHARSET_REGEX +from lib.core.settings import PARSE_HEADERS_LIMIT from lib.core.settings import UNICODE_ENCODING from lib.parse.headers import headersParser from lib.parse.html import htmlParser @@ -191,8 +192,10 @@ def decodePage(page, contentEncoding, contentType): return page def processResponse(page, responseHeaders): + kb.processResponseCounter += 1 + if not kb.dumpMode: - parseResponse(page, responseHeaders) + parseResponse(page, responseHeaders if kb.processResponseCounter < PARSE_HEADERS_LIMIT else None) if conf.parseErrors: msg = extractErrorMessage(page)