Skip to content

Commit 6b826ef

Browse files
committed
Reintroducing option --cookie-del
1 parent ca44b23 commit 6b826ef

File tree

7 files changed

+17
-7
lines changed

7 files changed

+17
-7
lines changed

lib/core/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,10 @@ def paramToDict(place, parameters=None):
533533

534534
parameters = parameters.replace(", ", ",")
535535
parameters = re.sub(r"&(\w{1,4});", r"%s\g<1>%s" % (PARAMETER_AMP_MARKER, PARAMETER_SEMICOLON_MARKER), parameters)
536-
splitParams = parameters.split(conf.pDel or (DEFAULT_COOKIE_DELIMITER if place == PLACE.COOKIE else DEFAULT_GET_POST_DELIMITER))
536+
if place == PLACE.COOKIE:
537+
splitParams = parameters.split(conf.cDel or DEFAULT_COOKIE_DELIMITER)
538+
else:
539+
splitParams = parameters.split(conf.pDel or DEFAULT_GET_POST_DELIMITER)
537540

538541
for element in splitParams:
539542
element = re.sub(r"%s(.+?)%s" % (PARAMETER_AMP_MARKER, PARAMETER_SEMICOLON_MARKER), r"&\g<1>;", element)

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"data": "string",
2626
"pDel": "string",
2727
"cookie": "string",
28+
"cDel": "string",
2829
"loadCookies": "string",
2930
"dropSetCookie": "boolean",
3031
"agent": "string",

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def cmdLineParser():
8282
request.add_option("--cookie", dest="cookie",
8383
help="HTTP Cookie header")
8484

85+
request.add_option("--cookie-del", dest="cDel",
86+
help="Character used for splitting cookie values")
87+
8588
request.add_option("--load-cookies", dest="loadCookies",
8689
help="File containing cookies in Netscape/wget format")
8790

lib/request/basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def forgeHeaders(items=None):
7373
kb.mergeCookies = not _ or _[0] in ("y", "Y")
7474

7575
if kb.mergeCookies:
76-
_ = lambda x: re.sub("(?i)%s=[^%s]+" % (cookie.name, DEFAULT_COOKIE_DELIMITER), "%s=%s" % (cookie.name, cookie.value), x)
76+
_ = lambda x: re.sub("(?i)%s=[^%s]+" % (cookie.name, conf.cDel or DEFAULT_COOKIE_DELIMITER), "%s=%s" % (cookie.name, cookie.value), x)
7777
headers[HTTP_HEADER.COOKIE] = _(headers[HTTP_HEADER.COOKIE])
7878

7979
if PLACE.COOKIE in conf.parameters:
@@ -82,7 +82,7 @@ def forgeHeaders(items=None):
8282
conf.httpHeaders = [(item[0], item[1] if item[0] != HTTP_HEADER.COOKIE else _(item[1])) for item in conf.httpHeaders]
8383

8484
elif not kb.testMode:
85-
headers[HTTP_HEADER.COOKIE] += "%s %s=%s" % (DEFAULT_COOKIE_DELIMITER, cookie.name, cookie.value)
85+
headers[HTTP_HEADER.COOKIE] += "%s %s=%s" % (conf.cDel or DEFAULT_COOKIE_DELIMITER, cookie.name, cookie.value)
8686

8787
if kb.testMode:
8888
resetCookieJar(conf.cj)

lib/request/connect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def _randomizeParameter(paramString, randomParameter):
752752
evaluateCode("%s=%s" % (name, repr(value)), variables)
753753

754754
if cookie:
755-
for part in cookie.split(conf.pDel or DEFAULT_COOKIE_DELIMITER):
755+
for part in cookie.split(conf.cDel or DEFAULT_COOKIE_DELIMITER):
756756
if '=' in part:
757757
name, value = part.split('=', 1)
758758
value = urldecode(value, convall=True)
@@ -770,7 +770,7 @@ def _randomizeParameter(paramString, randomParameter):
770770
elif re.search(r"\b%s=" % name, (post or "")):
771771
post = re.sub("((\A|\W)%s=)([^%s]+)" % (name, delimiter), "\g<1>%s" % value, post)
772772
elif re.search(r"\b%s=" % name, (cookie or "")):
773-
cookie = re.sub("((\A|\W)%s=)([^%s]+)" % (name, conf.pDel or DEFAULT_COOKIE_DELIMITER), "\g<1>%s" % value, cookie)
773+
cookie = re.sub("((\A|\W)%s=)([^%s]+)" % (name, conf.cDel or DEFAULT_COOKIE_DELIMITER), "\g<1>%s" % value, cookie)
774774
elif post is not None:
775775
post += "%s%s=%s" % (delimiter, name, value)
776776
else:

lib/request/redirecthandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def http_error_302(self, req, fp, code, msg, headers):
112112
if redurl and kb.redirectChoice == REDIRECTION.YES:
113113
req.headers[HTTP_HEADER.HOST] = getHostHeader(redurl)
114114
if headers and HTTP_HEADER.SET_COOKIE in headers:
115-
req.headers[HTTP_HEADER.COOKIE] = headers[HTTP_HEADER.SET_COOKIE].split(DEFAULT_COOKIE_DELIMITER)[0]
115+
req.headers[HTTP_HEADER.COOKIE] = headers[HTTP_HEADER.SET_COOKIE].split(conf.cDel or DEFAULT_COOKIE_DELIMITER)[0]
116116
result = urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
117117
else:
118118
result = fp

sqlmap.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ googleDork =
3636
# Data string to be sent through POST.
3737
data =
3838

39-
# Character used for splitting cookie values
39+
# Character used for splitting parameter values
4040
pDel =
4141

4242
# HTTP Cookie header.
4343
cookie =
4444

45+
# Character used for splitting cookie values
46+
cDel =
47+
4548
# File containing cookies in Netscape/wget format
4649
loadCookies =
4750

0 commit comments

Comments
 (0)