Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34aed7c

Browse files
committed
Bug fix (now it's possible to use multiple parsed requests without mixing associated headers)
1 parent 2f18df3 commit 34aed7c

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

lib/controller/controller.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def start():
251251
return True
252252

253253
if conf.url and not any((conf.forms, conf.crawlDepth)):
254-
kb.targets.add((conf.url, conf.method, conf.data, conf.cookie))
254+
kb.targets.add((conf.url, conf.method, conf.data, conf.cookie, None))
255255

256256
if conf.configFile and not kb.targets:
257257
errMsg = "you did not edit the configuration file properly, set "
@@ -264,13 +264,16 @@ def start():
264264
logger.info(infoMsg)
265265

266266
hostCount = 0
267+
initialHeaders = list(conf.httpHeaders)
267268

268-
for targetUrl, targetMethod, targetData, targetCookie in kb.targets:
269+
for targetUrl, targetMethod, targetData, targetCookie, targetHeaders in kb.targets:
269270
try:
270271
conf.url = targetUrl
271272
conf.method = targetMethod
272273
conf.data = targetData
273274
conf.cookie = targetCookie
275+
conf.httpHeaders = list(initialHeaders)
276+
conf.httpHeaders.extend(targetHeaders or [])
274277

275278
initTargetEnv()
276279
parseTargetUrl()

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3391,7 +3391,7 @@ def geturl(self):
33913391
logger.debug(debugMsg)
33923392
continue
33933393

3394-
target = (url, method, data, conf.cookie)
3394+
target = (url, method, data, conf.cookie, None)
33953395
retVal.add(target)
33963396
else:
33973397
errMsg = "there were no forms found at the given target URL"

lib/core/option.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def _parseBurpLog(content):
271271
params = False
272272
newline = None
273273
lines = request.split('\n')
274+
headers = []
274275

275276
for index in xrange(len(lines)):
276277
line = lines[index]
@@ -320,14 +321,14 @@ def _parseBurpLog(content):
320321
port = filterStringValue(splitValue[1], "[0-9]")
321322

322323
# Avoid to add a static content length header to
323-
# conf.httpHeaders and consider the following lines as
324+
# headers and consider the following lines as
324325
# POSTed data
325326
if key.upper() == HTTP_HEADER.CONTENT_LENGTH.upper():
326327
params = True
327328

328329
# Avoid proxy and connection type related headers
329330
elif key not in (HTTP_HEADER.PROXY_CONNECTION, HTTP_HEADER.CONNECTION):
330-
conf.httpHeaders.append((getUnicode(key), getUnicode(value)))
331+
headers.append((getUnicode(key), getUnicode(value)))
331332

332333
if CUSTOM_INJECTION_MARK_CHAR in re.sub(PROBLEMATIC_CUSTOM_INJECTION_PATTERNS, "", value or ""):
333334
params = True
@@ -355,7 +356,7 @@ def _parseBurpLog(content):
355356

356357
if not(conf.scope and not re.search(conf.scope, url, re.I)):
357358
if not kb.targets or url not in addedTargetUrls:
358-
kb.targets.add((url, method, data, cookie))
359+
kb.targets.add((url, method, data, cookie, tuple(headers)))
359360
addedTargetUrls.add(url)
360361

361362
fp = openFile(reqFile, "rb")

lib/utils/crawler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ def crawlThread():
143143
logger.warn(warnMsg)
144144
else:
145145
for url in threadData.shared.value:
146-
kb.targets.add((url, None, None, None))
146+
kb.targets.add((url, None, None, None, None))

0 commit comments

Comments
 (0)