Skip to content

Commit aa9cc39

Browse files
committed
Implements option --csrf-data (#5199)
1 parent d7ee423 commit aa9cc39

File tree

6 files changed

+13
-2
lines changed

6 files changed

+13
-2
lines changed

lib/core/option.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,10 @@ def _basicOptionValidation():
27332733
errMsg = "option '--csrf-method' requires usage of option '--csrf-token'"
27342734
raise SqlmapSyntaxException(errMsg)
27352735

2736+
if conf.csrfData and not conf.csrfToken:
2737+
errMsg = "option '--csrf-data' requires usage of option '--csrf-token'"
2738+
raise SqlmapSyntaxException(errMsg)
2739+
27362740
if conf.csrfToken and conf.threads > 1:
27372741
errMsg = "option '--csrf-url' is incompatible with option '--threads'"
27382742
raise SqlmapSyntaxException(errMsg)

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"csrfToken": "string",
6565
"csrfUrl": "string",
6666
"csrfMethod": "string",
67+
"csrfData": "string",
6768
"csrfRetries": "integer",
6869
"forceSSL": "boolean",
6970
"chunked": "boolean",

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty.six import unichr as _unichr
2121

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

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ def cmdLineParser(argv=None):
276276
request.add_argument("--csrf-method", dest="csrfMethod",
277277
help="HTTP method to use during anti-CSRF token page visit")
278278

279+
request.add_argument("--csrf-data", dest="csrfData",
280+
help="POST data to send during anti-CSRF token page visit")
281+
279282
request.add_argument("--csrf-retries", dest="csrfRetries", type=int,
280283
help="Retries for anti-CSRF token retrieval (default %d)" % defaults.csrfRetries)
281284

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ def _adjustParameter(paramString, parameter, newValue):
11861186
warnMsg += ". sqlmap is going to retry the request"
11871187
logger.warning(warnMsg)
11881188

1189-
page, headers, code = Connect.getPage(url=conf.csrfUrl or conf.url, data=conf.data if conf.csrfUrl == conf.url else None, method=conf.csrfMethod or (conf.method if conf.csrfUrl == conf.url else None), cookie=conf.parameters.get(PLACE.COOKIE), direct=True, silent=True, ua=conf.parameters.get(PLACE.USER_AGENT), referer=conf.parameters.get(PLACE.REFERER), host=conf.parameters.get(PLACE.HOST))
1189+
page, headers, code = Connect.getPage(url=conf.csrfUrl or conf.url, data=conf.csrfData or (conf.data if conf.csrfUrl == conf.url else None), method=conf.csrfMethod or (conf.method if conf.csrfUrl == conf.url else None), cookie=conf.parameters.get(PLACE.COOKIE), direct=True, silent=True, ua=conf.parameters.get(PLACE.USER_AGENT), referer=conf.parameters.get(PLACE.REFERER), host=conf.parameters.get(PLACE.HOST))
11901190
page = urldecode(page) # for anti-CSRF tokens with special characters in their name (e.g. 'foo:bar=...')
11911191

11921192
match = re.search(r"(?i)<input[^>]+\bname=[\"']?(?P<name>%s)\b[^>]*\bvalue=[\"']?(?P<value>[^>'\"]*)" % conf.csrfToken, page or "", re.I)

sqlmap.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ csrfUrl =
195195
# HTTP method to use during anti-CSRF token page visit.
196196
csrfMethod =
197197

198+
# POST data to send during anti-CSRF token page visit.
199+
csrfData =
200+
198201
# Retries for anti-CSRF token retrieval.
199202
csrfRetries =
200203

0 commit comments

Comments
 (0)