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

Skip to content

Commit 30fba84

Browse files
committed
Implements #3916
1 parent 617c336 commit 30fba84

6 files changed

Lines changed: 15 additions & 4 deletions

File tree

lib/core/option.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,10 @@ def _basicOptionValidation():
24902490
errMsg = "option '--csrf-url' requires usage of option '--csrf-token'"
24912491
raise SqlmapSyntaxException(errMsg)
24922492

2493+
if conf.csrfMethod and not conf.csrfToken:
2494+
errMsg = "option '--csrf-method' requires usage of option '--csrf-token'"
2495+
raise SqlmapSyntaxException(errMsg)
2496+
24932497
if conf.csrfToken and conf.threads > 1:
24942498
errMsg = "option '--csrf-url' is incompatible with option '--threads'"
24952499
raise SqlmapSyntaxException(errMsg)

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"skipUrlEncode": "boolean",
6262
"csrfToken": "string",
6363
"csrfUrl": "string",
64+
"csrfMethod": "string",
6465
"forceSSL": "boolean",
6566
"chunked": "boolean",
6667
"hpp": "boolean",

lib/core/settings.py

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

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.9.7"
21+
VERSION = "1.3.9.8"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
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
@@ -245,6 +245,9 @@ def cmdLineParser(argv=None):
245245
request.add_argument("--csrf-url", dest="csrfUrl",
246246
help="URL address to visit for extraction of anti-CSRF token")
247247

248+
request.add_argument("--csrf-method", dest="csrfMethod",
249+
help="HTTP method to use during anti-CSRF token page visit")
250+
248251
request.add_argument("--force-ssl", dest="forceSSL", action="store_true",
249252
help="Force usage of SSL/HTTPS")
250253

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ def _adjustParameter(paramString, parameter, newValue):
10391039
return retVal
10401040

10411041
token = AttribDict()
1042-
page, headers, code = Connect.getPage(url=conf.csrfUrl or conf.url, data=conf.data if conf.csrfUrl == conf.url else None, method=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))
1042+
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))
10431043
page = urldecode(page) # for anti-CSRF tokens with special characters in their name (e.g. 'foo:bar=...')
10441044

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

sqlmap.conf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,19 @@ safeReqFile =
180180
# Default: 0
181181
safeFreq = 0
182182

183-
# Skip URL encoding of payload data
183+
# Skip URL encoding of payload data.
184184
# Valid: True or False
185185
skipUrlEncode = False
186186

187-
# Parameter used to hold anti-CSRF token
187+
# Parameter used to hold anti-CSRF token.
188188
csrfToken =
189189

190190
# URL address to visit to extract anti-CSRF token
191191
csrfUrl =
192192

193+
# HTTP method to use during anti-CSRF token page visit.
194+
csrfMethod =
195+
193196
# Force usage of SSL/HTTPS
194197
# Valid: True or False
195198
forceSSL = False

0 commit comments

Comments
 (0)