48
48
from lib .core .datatype import advancedDict
49
49
from lib .core .exception import sqlmapFilePathException
50
50
from lib .core .exception import sqlmapGenericException
51
+ from lib .core .exception import sqlmapMissingDependence
51
52
from lib .core .exception import sqlmapMissingMandatoryOptionException
52
53
from lib .core .exception import sqlmapMissingPrivileges
53
54
from lib .core .exception import sqlmapSyntaxException
@@ -528,7 +529,7 @@ def __setHTTPProxy():
528
529
529
530
def __setHTTPAuthentication ():
530
531
"""
531
- Check and set the HTTP authentication method (Basic or Digest ),
532
+ Check and set the HTTP authentication method (Basic, Digest or NTLM ),
532
533
username and password to perform HTTP requests with.
533
534
"""
534
535
@@ -538,29 +539,29 @@ def __setHTTPAuthentication():
538
539
return
539
540
540
541
elif conf .aType and not conf .aCred :
541
- errMsg = "you specified the HTTP Authentication type, but "
542
+ errMsg = "you specified the HTTP authentication type, but "
542
543
errMsg += "did not provide the credentials"
543
544
raise sqlmapSyntaxException , errMsg
544
545
545
546
elif not conf .aType and conf .aCred :
546
- errMsg = "you specified the HTTP Authentication credentials, "
547
+ errMsg = "you specified the HTTP authentication credentials, "
547
548
errMsg += "but did not provide the type"
548
549
raise sqlmapSyntaxException , errMsg
549
550
550
- debugMsg = "setting the HTTP Authentication type and credentials"
551
+ debugMsg = "setting the HTTP authentication type and credentials"
551
552
logger .debug (debugMsg )
552
553
553
554
aTypeLower = conf .aType .lower ()
554
555
555
- if aTypeLower not in ( "basic" , "digest" ):
556
- errMsg = "HTTP Authentication type value must be "
557
- errMsg += "Basic or Digest "
556
+ if aTypeLower not in ( "basic" , "digest" , "ntlm" ):
557
+ errMsg = "HTTP authentication type value must be "
558
+ errMsg += "Basic, Digest or NTLM "
558
559
raise sqlmapSyntaxException , errMsg
559
560
560
561
aCredRegExp = re .search ("^(.*?)\:(.*?)$" , conf .aCred )
561
562
562
563
if not aCredRegExp :
563
- errMsg = "HTTP Authentication credentials value must be "
564
+ errMsg = "HTTP authentication credentials value must be "
564
565
errMsg += "in format username:password"
565
566
raise sqlmapSyntaxException , errMsg
566
567
@@ -572,9 +573,21 @@ def __setHTTPAuthentication():
572
573
573
574
if aTypeLower == "basic" :
574
575
authHandler = urllib2 .HTTPBasicAuthHandler (passwordMgr )
576
+
575
577
elif aTypeLower == "digest" :
576
578
authHandler = urllib2 .HTTPDigestAuthHandler (passwordMgr )
577
579
580
+ elif aTypeLower == "ntlm" :
581
+ try :
582
+ from ntlm import HTTPNtlmAuthHandler
583
+ except ImportError , _ :
584
+ errMsg = "sqlmap requires Python NTLM third-party library "
585
+ errMsg += "in order to authenticate via NTLM, "
586
+ errMsg += "http://code.google.com/p/python-ntlm/"
587
+ raise sqlmapMissingDependence , errMsg
588
+
589
+ authHandler = HTTPNtlmAuthHandler .HTTPNtlmAuthHandler (passwordMgr )
590
+
578
591
579
592
def __setHTTPMethod ():
580
593
"""
0 commit comments