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

Skip to content

Commit 2f43c3e

Browse files
committed
Minor fix (digest live test case) and some refactoring
1 parent 65306f1 commit 2f43c3e

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

lib/core/enums.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,8 @@ class CONTENT_TYPE:
308308
class CONTENT_STATUS:
309309
IN_PROGRESS = 0
310310
COMPLETE = 1
311+
312+
class AUTH_TYPE:
313+
BASIC = "basic"
314+
DIGEST = "digest"
315+
NTLM = "ntlm"

lib/core/option.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
from lib.core.dicts import DBMS_DICT
6565
from lib.core.dicts import DUMP_REPLACEMENTS
6666
from lib.core.enums import ADJUST_TIME_DELAY
67+
from lib.core.enums import AUTH_TYPE
6768
from lib.core.enums import CUSTOM_LOGGING
6869
from lib.core.enums import DUMP_FORMAT
6970
from lib.core.enums import HTTPHEADER
@@ -1098,15 +1099,15 @@ def _setHTTPAuthentication():
10981099

10991100
aTypeLower = conf.aType.lower()
11001101

1101-
if aTypeLower not in ("basic", "digest", "ntlm"):
1102+
if aTypeLower not in (AUTH_TYPE.BASIC, AUTH_TYPE.DIGEST, AUTH_TYPE.NTLM):
11021103
errMsg = "HTTP authentication type value must be "
11031104
errMsg += "Basic, Digest or NTLM"
11041105
raise SqlmapSyntaxException(errMsg)
1105-
elif aTypeLower in ("basic", "digest"):
1106+
elif aTypeLower in (AUTH_TYPE.BASIC, AUTH_TYPE.DIGEST):
11061107
regExp = "^(.*?):(.*?)$"
11071108
errMsg = "HTTP %s authentication credentials " % aTypeLower
11081109
errMsg += "value must be in format username:password"
1109-
elif aTypeLower == "ntlm":
1110+
elif aTypeLower == AUTH_TYPE.NTLM:
11101111
regExp = "^(.*\\\\.*):(.*?)$"
11111112
errMsg = "HTTP NTLM authentication credentials value must "
11121113
errMsg += "be in format DOMAIN\username:password"
@@ -1123,13 +1124,13 @@ def _setHTTPAuthentication():
11231124

11241125
_setAuthCred()
11251126

1126-
if aTypeLower == "basic":
1127+
if aTypeLower == AUTH_TYPE.BASIC:
11271128
authHandler = SmartHTTPBasicAuthHandler(kb.passwordMgr)
11281129

1129-
elif aTypeLower == "digest":
1130+
elif aTypeLower == AUTH_TYPE.DIGEST:
11301131
authHandler = urllib2.HTTPDigestAuthHandler(kb.passwordMgr)
11311132

1132-
elif aTypeLower == "ntlm":
1133+
elif aTypeLower == AUTH_TYPE.NTLM:
11331134
try:
11341135
from ntlm import HTTPNtlmAuthHandler
11351136
except ImportError:

lib/request/connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from lib.core.data import logger
4848
from lib.core.dicts import POST_HINT_CONTENT_TYPES
4949
from lib.core.enums import ADJUST_TIME_DELAY
50+
from lib.core.enums import AUTH_TYPE
5051
from lib.core.enums import CUSTOM_LOGGING
5152
from lib.core.enums import HTTPHEADER
5253
from lib.core.enums import HTTPMETHOD
@@ -364,7 +365,7 @@ def getPage(**kwargs):
364365

365366
conn = urllib2.urlopen(req)
366367

367-
if not kb.authHeader and getRequestHeader(req, HTTPHEADER.AUTHORIZATION):
368+
if not kb.authHeader and getRequestHeader(req, HTTPHEADER.AUTHORIZATION) and conf.aType == AUTH_TYPE.BASIC:
368369
kb.authHeader = getRequestHeader(req, HTTPHEADER.AUTHORIZATION)
369370

370371
if not kb.proxyAuthHeader and getRequestHeader(req, HTTPHEADER.PROXY_AUTHORIZATION):

0 commit comments

Comments
 (0)