Skip to content

Commit 38c3410

Browse files
committed
Update regarding #4142 (--auth-type bearer)
1 parent 40e4422 commit 38c3410

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

lib/core/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ class CONTENT_STATUS(object):
402402
class AUTH_TYPE(object):
403403
BASIC = "basic"
404404
DIGEST = "digest"
405+
BEARER = "bearer"
405406
NTLM = "ntlm"
406407
PKI = "pki"
407408

lib/core/option.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ def _setAuthCred():
13101310

13111311
def _setHTTPAuthentication():
13121312
"""
1313-
Check and set the HTTP(s) authentication method (Basic, Digest, NTLM or PKI),
1313+
Check and set the HTTP(s) authentication method (Basic, Digest, Bearer, NTLM or PKI),
13141314
username and password for first three methods, or PEM private key file for
13151315
PKI authentication
13161316
"""
@@ -1333,9 +1333,9 @@ def _setHTTPAuthentication():
13331333
errMsg += "but did not provide the type (e.g. --auth-type=\"basic\")"
13341334
raise SqlmapSyntaxException(errMsg)
13351335

1336-
elif (conf.authType or "").lower() not in (AUTH_TYPE.BASIC, AUTH_TYPE.DIGEST, AUTH_TYPE.NTLM, AUTH_TYPE.PKI):
1336+
elif (conf.authType or "").lower() not in (AUTH_TYPE.BASIC, AUTH_TYPE.DIGEST, AUTH_TYPE.BEARER, AUTH_TYPE.NTLM, AUTH_TYPE.PKI):
13371337
errMsg = "HTTP authentication type value must be "
1338-
errMsg += "Basic, Digest, NTLM or PKI"
1338+
errMsg += "Basic, Digest, Bearer, NTLM or PKI"
13391339
raise SqlmapSyntaxException(errMsg)
13401340

13411341
if not conf.authFile:
@@ -1348,6 +1348,9 @@ def _setHTTPAuthentication():
13481348
regExp = "^(.*?):(.*?)$"
13491349
errMsg = "HTTP %s authentication credentials " % authType
13501350
errMsg += "value must be in format 'username:password'"
1351+
elif authType == AUTH_TYPE.BEARER:
1352+
conf.httpHeaders.append((HTTP_HEADER.AUTHORIZATION, "Bearer %s" % conf.authCred.strip()))
1353+
return
13511354
elif authType == AUTH_TYPE.NTLM:
13521355
regExp = "^(.*\\\\.*):(.*?)$"
13531356
errMsg = "HTTP NTLM authentication credentials value must "

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.5.3.12"
21+
VERSION = "1.5.3.13"
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def cmdLineParser(argv=None):
193193
help="Extra headers (e.g. \"Accept-Language: fr\\nETag: 123\")")
194194

195195
request.add_argument("--auth-type", dest="authType",
196-
help="HTTP authentication type (Basic, Digest, NTLM or PKI)")
196+
help="HTTP authentication type (Basic, Digest, Bearer, ...)")
197197

198198
request.add_argument("--auth-cred", dest="authCred",
199199
help="HTTP authentication credentials (name:password)")
@@ -976,6 +976,8 @@ def _format_action_invocation(self, action):
976976
argv[i] = ""
977977
elif argv[i].startswith("--data-raw"):
978978
argv[i] = argv[i].replace("--data-raw", "--data", 1)
979+
elif argv[i].startswith("--auth-creds"):
980+
argv[i] = argv[i].replace("--auth-creds", "--auth-cred", 1)
979981
elif argv[i].startswith("--drop-cookie"):
980982
argv[i] = argv[i].replace("--drop-cookie", "--drop-set-cookie", 1)
981983
elif any(argv[i].startswith(_) for _ in ("--tamper", "--ignore-code", "--skip")):

sqlmap.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ headers = Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
8787
Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
8888

8989
# HTTP Authentication type. Useful only if the target URL requires
90-
# HTTP Basic, Digest or NTLM authentication and you have such data.
91-
# Valid: Basic, Digest, NTLM or PKI
90+
# HTTP Basic, Digest, Bearer or NTLM authentication and you have such data.
91+
# Valid: Basic, Digest, Bearer, NTLM or PKI
9292
authType =
9393

9494
# HTTP authentication credentials. Useful only if the target URL requires
95-
# HTTP Basic, Digest or NTLM authentication and you have such data.
95+
# HTTP Basic, Digest, Token or NTLM authentication and you have such data.
9696
# Syntax: username:password
9797
authCred =
9898

0 commit comments

Comments
 (0)