Skip to content

Commit b3f4c6d

Browse files
authored
Make asterisk work with --csrf-token option (sqlmapproject#4305)
1 parent cec65f3 commit b3f4c6d

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/core/target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def process(match, repl):
400400
raise SqlmapGenericException(errMsg)
401401

402402
if conf.csrfToken:
403-
if not any(re.search(conf.csrfToken, ' '.join(_), re.I) for _ in (conf.paramDict.get(PLACE.GET, {}), conf.paramDict.get(PLACE.POST, {}), conf.paramDict.get(PLACE.COOKIE, {}))) and not re.search(r"\b%s\b" % conf.csrfToken, conf.data or "") and conf.csrfToken not in set(_[0].lower() for _ in conf.httpHeaders) and conf.csrfToken not in conf.paramDict.get(PLACE.COOKIE, {}):
403+
if not any(re.search(conf.csrfToken, ' '.join(_), re.I) for _ in (conf.paramDict.get(PLACE.GET, {}), conf.paramDict.get(PLACE.POST, {}), conf.paramDict.get(PLACE.COOKIE, {}))) and not re.search(r"\b%s\b" % conf.csrfToken, conf.data or "") and conf.csrfToken not in set(_[0].lower() for _ in conf.httpHeaders) and conf.csrfToken not in conf.paramDict.get(PLACE.COOKIE, {}) and not all(re.search(conf.csrfToken, _, re.I) for _ in conf.paramDict.get(PLACE.URI, {}).values()):
404404
errMsg = "anti-CSRF token parameter '%s' not " % conf.csrfToken._original
405405
errMsg += "found in provided GET, POST, Cookie or header values"
406406
raise SqlmapGenericException(errMsg)

lib/request/connect.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,11 +1125,13 @@ def _adjustParameter(paramString, parameter, newValue):
11251125
if token:
11261126
token.value = token.value.strip("'\"")
11271127

1128-
for candidate in (PLACE.GET, PLACE.POST):
1128+
for candidate in (PLACE.GET, PLACE.POST, PLACE.CUSTOM_POST, PLACE.URI):
11291129
if candidate in conf.parameters:
1130-
if candidate == PLACE.GET and get:
1130+
if candidate == PLACE.URI and uri:
1131+
uri = _adjustParameter(uri, token.name, token.value)
1132+
elif candidate == PLACE.GET and get:
11311133
get = _adjustParameter(get, token.name, token.value)
1132-
elif candidate == PLACE.POST and post:
1134+
elif candidate in [PLACE.POST, PLACE.CUSTOM_POST] and post:
11331135
post = _adjustParameter(post, token.name, token.value)
11341136

11351137
for i in xrange(len(conf.httpHeaders)):

0 commit comments

Comments
 (0)