Skip to content

Commit 17350fb

Browse files
committed
Proper fix for sqlmapproject#1146 (/ has been escaped with \/ in output)
1 parent 22484c8 commit 17350fb

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/core/target.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,11 @@ def process(match, repl):
318318

319319
# Perform checks on header values
320320
if conf.httpHeaders:
321-
for httpHeader, headerValue in conf.httpHeaders:
321+
for httpHeader, headerValue in list(conf.httpHeaders):
322322
# Url encoding of the header values should be avoided
323323
# Reference: http://stackoverflow.com/questions/5085904/is-ok-to-urlencode-the-value-in-headerlocation-value
324324

325-
httpHeader = httpHeader.title()
326-
327-
if httpHeader == HTTP_HEADER.USER_AGENT:
325+
if httpHeader.title() == HTTP_HEADER.USER_AGENT:
328326
conf.parameters[PLACE.USER_AGENT] = urldecode(headerValue)
329327

330328
condition = any((not conf.testParameter, intersect(conf.testParameter, USER_AGENT_ALIASES, True)))
@@ -333,7 +331,7 @@ def process(match, repl):
333331
conf.paramDict[PLACE.USER_AGENT] = {PLACE.USER_AGENT: headerValue}
334332
testableParameters = True
335333

336-
elif httpHeader == HTTP_HEADER.REFERER:
334+
elif httpHeader.title() == HTTP_HEADER.REFERER:
337335
conf.parameters[PLACE.REFERER] = urldecode(headerValue)
338336

339337
condition = any((not conf.testParameter, intersect(conf.testParameter, REFERER_ALIASES, True)))
@@ -342,7 +340,7 @@ def process(match, repl):
342340
conf.paramDict[PLACE.REFERER] = {PLACE.REFERER: headerValue}
343341
testableParameters = True
344342

345-
elif httpHeader == HTTP_HEADER.HOST:
343+
elif httpHeader.title() == HTTP_HEADER.HOST:
346344
conf.parameters[PLACE.HOST] = urldecode(headerValue)
347345

348346
condition = any((not conf.testParameter, intersect(conf.testParameter, HOST_ALIASES, True)))
@@ -351,6 +349,15 @@ def process(match, repl):
351349
conf.paramDict[PLACE.HOST] = {PLACE.HOST: headerValue}
352350
testableParameters = True
353351

352+
else:
353+
condition = intersect(conf.testParameter, [httpHeader], True)
354+
355+
if condition:
356+
conf.parameters[PLACE.CUSTOM_HEADER] = str(conf.httpHeaders)
357+
conf.paramDict[PLACE.CUSTOM_HEADER] = {httpHeader: "%s,%s%s" % (httpHeader, headerValue, CUSTOM_INJECTION_MARK_CHAR)}
358+
conf.httpHeaders = [(header, value.replace(CUSTOM_INJECTION_MARK_CHAR, "")) for header, value in conf.httpHeaders]
359+
testableParameters = True
360+
354361
if not conf.parameters:
355362
errMsg = "you did not provide any GET, POST and Cookie "
356363
errMsg += "parameter, neither an User-Agent, Referer or Host header value"

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ class _(dict):
659659
if conn and getattr(conn, "redurl", None):
660660
_ = urlparse.urlsplit(conn.redurl)
661661
_ = ("%s%s" % (_.path or "/", ("?%s" % _.query) if _.query else ""))
662-
requestMsg = re.sub("(\n[A-Z]+ ).+?( HTTP/\d)", "\g<1>%s\g<2>" % re.escape(getUnicode(_)), requestMsg, 1)
662+
requestMsg = re.sub("(\n[A-Z]+ ).+?( HTTP/\d)", "\g<1>%s\g<2>" % getUnicode(_).replace("\\", "\\\\"), requestMsg, 1)
663663

664664
if kb.resendPostOnRedirect is False:
665665
requestMsg = re.sub("(\[#\d+\]:\n)POST ", "\g<1>GET ", requestMsg)

0 commit comments

Comments
 (0)