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

Skip to content

Commit b355249

Browse files
committed
Minor preparation for an Issue #48
1 parent 3e9f1fe commit b355249

6 files changed

Lines changed: 16 additions & 13 deletions

File tree

lib/controller/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def genCmpPayload():
460460
# Feed with the boundaries details only the first time a
461461
# test has been successful
462462
if injection.place is None or injection.parameter is None:
463-
if place in (PLACE.UA, PLACE.REFERER, PLACE.HOST):
463+
if place in (PLACE.USER_AGENT, PLACE.REFERER, PLACE.HOST):
464464
injection.parameter = place
465465
else:
466466
injection.parameter = parameter

lib/controller/controller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def start():
378378
for place in parameters:
379379
# Test User-Agent and Referer headers only if
380380
# --level >= 3
381-
skip = (place == PLACE.UA and conf.level < 3)
381+
skip = (place == PLACE.USER_AGENT and conf.level < 3)
382382
skip |= (place == PLACE.REFERER and conf.level < 3)
383383

384384
# Test Host header only if
@@ -388,11 +388,11 @@ def start():
388388
# Test Cookie header only if --level >= 2
389389
skip |= (place == PLACE.COOKIE and conf.level < 2)
390390

391-
skip |= (place == PLACE.UA and intersect(USER_AGENT_ALIASES, conf.skip, True) not in ([], None))
391+
skip |= (place == PLACE.USER_AGENT and intersect(USER_AGENT_ALIASES, conf.skip, True) not in ([], None))
392392
skip |= (place == PLACE.REFERER and intersect(REFERER_ALIASES, conf.skip, True) not in ([], None))
393393
skip |= (place == PLACE.COOKIE and intersect(PLACE.COOKIE, conf.skip, True) not in ([], None))
394394

395-
skip &= not (place == PLACE.UA and intersect(USER_AGENT_ALIASES, conf.testParameter, True))
395+
skip &= not (place == PLACE.USER_AGENT and intersect(USER_AGENT_ALIASES, conf.testParameter, True))
396396
skip &= not (place == PLACE.REFERER and intersect(REFERER_ALIASES, conf.testParameter, True))
397397
skip &= not (place == PLACE.HOST and intersect(HOST_ALIASES, conf.testParameter, True))
398398

lib/core/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def payload(self, place=None, parameter=None, value=None, newValue=None, where=N
118118
retVal = ET.tostring(root)
119119
elif place in (PLACE.URI, PLACE.CUSTOM_POST):
120120
retVal = paramString.replace("%s%s" % (origValue, CUSTOM_INJECTION_MARK_CHAR), self.addPayloadDelimiters(newValue))
121-
elif place in (PLACE.UA, PLACE.REFERER, PLACE.HOST):
121+
elif place in (PLACE.USER_AGENT, PLACE.REFERER, PLACE.HOST):
122122
retVal = paramString.replace(origValue, self.addPayloadDelimiters(newValue))
123123
else:
124124
retVal = paramString.replace("%s=%s" % (parameter, origValue),

lib/core/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class PLACE:
6161
SOAP = "SOAP"
6262
URI = "URI"
6363
COOKIE = "Cookie"
64-
UA = "User-Agent"
64+
USER_AGENT = "User-Agent"
6565
REFERER = "Referer"
6666
HOST = "Host"
6767
CUSTOM_POST = "(custom) POST"

lib/core/target.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from lib.core.data import paths
2727
from lib.core.dump import dumper
2828
from lib.core.enums import HASHDB_KEYS
29+
from lib.core.enums import HTTPHEADER
2930
from lib.core.enums import HTTPMETHOD
3031
from lib.core.enums import PLACE
3132
from lib.core.exception import sqlmapFilePathException
@@ -158,16 +159,18 @@ def __setRequestParams():
158159
# Url encoding of the header values should be avoided
159160
# Reference: http://stackoverflow.com/questions/5085904/is-ok-to-urlencode-the-value-in-headerlocation-value
160161

161-
if httpHeader == PLACE.UA:
162-
conf.parameters[PLACE.UA] = urldecode(headerValue)
162+
httpHeader = "-".join(_.capitalize() for _ in (httpHeader or "").split("-"))
163+
164+
if httpHeader == HTTPHEADER.USER_AGENT:
165+
conf.parameters[PLACE.USER_AGENT] = urldecode(headerValue)
163166

164167
condition = any((not conf.testParameter, intersect(conf.testParameter, USER_AGENT_ALIASES)))
165168

166169
if condition:
167-
conf.paramDict[PLACE.UA] = {PLACE.UA: headerValue}
170+
conf.paramDict[PLACE.USER_AGENT] = {PLACE.USER_AGENT: headerValue}
168171
testableParameters = True
169172

170-
elif httpHeader == PLACE.REFERER:
173+
elif httpHeader == HTTPHEADER.REFERER:
171174
conf.parameters[PLACE.REFERER] = urldecode(headerValue)
172175

173176
condition = any((not conf.testParameter, intersect(conf.testParameter, REFERER_ALIASES)))
@@ -176,7 +179,7 @@ def __setRequestParams():
176179
conf.paramDict[PLACE.REFERER] = {PLACE.REFERER: headerValue}
177180
testableParameters = True
178181

179-
elif httpHeader == PLACE.HOST:
182+
elif httpHeader == HTTPHEADER.HOST:
180183
conf.parameters[PLACE.HOST] = urldecode(headerValue)
181184

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

lib/request/connect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ def queryPage(value=None, place=None, content=False, getRatioValue=False, silent
595595
if PLACE.COOKIE in conf.parameters:
596596
cookie = conf.parameters[PLACE.COOKIE] if place != PLACE.COOKIE or not value else value
597597

598-
if PLACE.UA in conf.parameters:
599-
ua = conf.parameters[PLACE.UA] if place != PLACE.UA or not value else value
598+
if PLACE.USER_AGENT in conf.parameters:
599+
ua = conf.parameters[PLACE.USER_AGENT] if place != PLACE.USER_AGENT or not value else value
600600

601601
if PLACE.REFERER in conf.parameters:
602602
referer = conf.parameters[PLACE.REFERER] if place != PLACE.REFERER or not value else value

0 commit comments

Comments
 (0)