Skip to content

Commit f1a3c81

Browse files
committed
Bug fix for handling of custom headers
1 parent 277a4fa commit f1a3c81

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

lib/core/option.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ def _setSafeVisit():
10711071
key, value = line.split(':', 1)
10721072
value = value.strip()
10731073
kb.safeReq.headers[key] = value
1074-
if key == HTTP_HEADER.HOST:
1074+
if key.upper() == HTTP_HEADER.HOST.upper():
10751075
if not value.startswith("http"):
10761076
scheme = "http"
10771077
if value.endswith(":443"):
@@ -1303,7 +1303,7 @@ def _setHTTPUserAgent():
13031303
_ = True
13041304

13051305
for header, _ in conf.httpHeaders:
1306-
if header == HTTP_HEADER.USER_AGENT:
1306+
if header.upper() == HTTP_HEADER.USER_AGENT.upper():
13071307
_ = False
13081308
break
13091309

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.11.16"
22+
VERSION = "1.2.11.17"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/core/target.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def process(match, repl):
346346
# Url encoding of the header values should be avoided
347347
# Reference: http://stackoverflow.com/questions/5085904/is-ok-to-urlencode-the-value-in-headerlocation-value
348348

349-
if httpHeader.title() == HTTP_HEADER.USER_AGENT:
349+
if httpHeader.upper() == HTTP_HEADER.USER_AGENT.upper():
350350
conf.parameters[PLACE.USER_AGENT] = urldecode(headerValue)
351351

352352
condition = any((not conf.testParameter, intersect(conf.testParameter, USER_AGENT_ALIASES, True)))
@@ -355,7 +355,7 @@ def process(match, repl):
355355
conf.paramDict[PLACE.USER_AGENT] = {PLACE.USER_AGENT: headerValue}
356356
testableParameters = True
357357

358-
elif httpHeader.title() == HTTP_HEADER.REFERER:
358+
elif httpHeader.upper() == HTTP_HEADER.REFERER.upper():
359359
conf.parameters[PLACE.REFERER] = urldecode(headerValue)
360360

361361
condition = any((not conf.testParameter, intersect(conf.testParameter, REFERER_ALIASES, True)))
@@ -364,7 +364,7 @@ def process(match, repl):
364364
conf.paramDict[PLACE.REFERER] = {PLACE.REFERER: headerValue}
365365
testableParameters = True
366366

367-
elif httpHeader.title() == HTTP_HEADER.HOST:
367+
elif httpHeader.upper() == HTTP_HEADER.HOST.upper():
368368
conf.parameters[PLACE.HOST] = urldecode(headerValue)
369369

370370
condition = any((not conf.testParameter, intersect(conf.testParameter, HOST_ALIASES, True)))

lib/request/connect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,10 @@ def queryPage(value=None, place=None, content=False, getRatioValue=False, silent
866866
value = agent.replacePayload(value, payload)
867867
else:
868868
# GET, POST, URI and Cookie payload needs to be thoroughly URL encoded
869-
if (place in (PLACE.GET, PLACE.URI, PLACE.COOKIE) or place == PLACE.CUSTOM_HEADER and value.split(',')[0] == HTTP_HEADER.COOKIE) and not conf.skipUrlEncode or place in (PLACE.POST, PLACE.CUSTOM_POST) and postUrlEncode:
869+
if (place in (PLACE.GET, PLACE.URI, PLACE.COOKIE) or place == PLACE.CUSTOM_HEADER and value.split(',')[0].upper() == HTTP_HEADER.COOKIE.upper()) and not conf.skipUrlEncode or place in (PLACE.POST, PLACE.CUSTOM_POST) and postUrlEncode:
870870
skip = False
871871

872-
if place == PLACE.COOKIE or place == PLACE.CUSTOM_HEADER and value.split(',')[0] == HTTP_HEADER.COOKIE:
872+
if place == PLACE.COOKIE or place == PLACE.CUSTOM_HEADER and value.split(',')[0].upper() == HTTP_HEADER.COOKIE.upper():
873873
if kb.cookieEncodeChoice is None:
874874
msg = "do you want to URL encode cookie values (implementation specific)? %s" % ("[Y/n]" if not conf.url.endswith(".aspx") else "[y/N]") # Reference: https://support.microsoft.com/en-us/kb/313282
875875
kb.cookieEncodeChoice = readInput(msg, default='Y' if not conf.url.endswith(".aspx") else 'N', boolean=True)

txt/checksum.md5

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ cada93357a7321655927fc9625b3bfec lib/core/exception.py
4242
1e5532ede194ac9c083891c2f02bca93 lib/core/__init__.py
4343
458a194764805cd8312c14ecd4be4d1e lib/core/log.py
4444
7d6edc552e08c30f4f4d49fa93b746f1 lib/core/optiondict.py
45-
d6dace6468ed5d2bbd500b0a244a9650 lib/core/option.py
45+
c6a8223fbc1dad784d4ae6377e737a97 lib/core/option.py
4646
c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4747
6783160150b4711d02c56ee2beadffdb lib/core/profiling.py
4848
6f654e1715571eff68a0f8af3d62dcf8 lib/core/readlineng.py
4949
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
5050
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5151
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
52-
342e732d0772891804c7609578176997 lib/core/settings.py
52+
3f8cf314028234cb8c60c66a915da2e2 lib/core/settings.py
5353
a971ce157d04de96ba6e710d3d38a9a8 lib/core/shell.py
5454
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
55-
721198b5be72c8015a02acb116532a1f lib/core/target.py
55+
52642badbbca4c31a2fcdd754d67a983 lib/core/target.py
5656
72d499ca8d792e90a1ebfb2ad2341a51 lib/core/testing.py
5757
cd0067d1798e45f422ce44b98baf57db lib/core/threads.py
5858
c40758411bb0bd68764d78e0bb72bd0f lib/core/unescaper.py
@@ -71,7 +71,7 @@ f6b5957bf2103c3999891e4f45180bce lib/parse/payloads.py
7171
30eed3a92a04ed2c29770e1b10d39dc0 lib/request/basicauthhandler.py
7272
2b81435f5a7519298c15c724e3194a0d lib/request/basic.py
7373
859b6ad583e0ffba154f17ee179b5b89 lib/request/comparison.py
74-
d21e3452240ae3e59dfeb05fabc9ea14 lib/request/connect.py
74+
0113525b321d0d35cf973a9cff34850a lib/request/connect.py
7575
dd4598675027fae99f2e2475b05986da lib/request/direct.py
7676
2044fce3f4ffa268fcfaaf63241b1e64 lib/request/dns.py
7777
98535d0efca5551e712fcc4b34a3f772 lib/request/httpshandler.py

0 commit comments

Comments
 (0)