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

Skip to content

Commit c8d4df6

Browse files
committed
Adding names to parameters in structured POST requests (e.g. JSON)
1 parent 49982bc commit c8d4df6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/core/target.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def _setRequestParams():
9797

9898
if conf.data is not None:
9999
conf.method = HTTPMETHOD.POST if not conf.method or conf.method == HTTPMETHOD.GET else conf.method
100+
hintNames = []
100101

101102
def process(match, repl):
102103
retVal = match.group(0)
@@ -109,7 +110,8 @@ def process(match, repl):
109110
retVal = retVal.replace(_.group(0), match.group(int(_.group(1)) if _.group(1).isdigit() else _.group(1)))
110111
else:
111112
break
112-
113+
if CUSTOM_INJECTION_MARK_CHAR in retVal:
114+
hintNames.append((retVal.split(CUSTOM_INJECTION_MARK_CHAR)[0], match.group("name")))
113115
return retVal
114116

115117
if kb.processUserMarks is None and CUSTOM_INJECTION_MARK_CHAR in conf.data:
@@ -280,7 +282,15 @@ def process(match, repl):
280282
parts = value.split(CUSTOM_INJECTION_MARK_CHAR)
281283

282284
for i in xrange(len(parts) - 1):
283-
conf.paramDict[place]["%s#%d%s" % (("%s " % kb.postHint) if kb.postHint else "", i + 1, CUSTOM_INJECTION_MARK_CHAR)] = "".join("%s%s" % (parts[j], CUSTOM_INJECTION_MARK_CHAR if i == j else "") for j in xrange(len(parts)))
285+
name = None
286+
if kb.postHint:
287+
for ending, _ in hintNames:
288+
if parts[i].endswith(ending):
289+
name = "%s %s" % (kb.postHint, _)
290+
break
291+
if name is None:
292+
name = "%s#%s%s" % (("%s " % kb.postHint) if kb.postHint else "", i + 1, CUSTOM_INJECTION_MARK_CHAR)
293+
conf.paramDict[place][name] = "".join("%s%s" % (parts[j], CUSTOM_INJECTION_MARK_CHAR if i == j else "") for j in xrange(len(parts)))
284294

285295
if place == PLACE.URI and PLACE.GET in conf.paramDict:
286296
del conf.paramDict[PLACE.GET]

0 commit comments

Comments
 (0)