4848from lib .core .datatype import advancedDict
4949from lib .core .exception import sqlmapFilePathException
5050from lib .core .exception import sqlmapGenericException
51+ from lib .core .exception import sqlmapMissingDependence
5152from lib .core .exception import sqlmapMissingMandatoryOptionException
5253from lib .core .exception import sqlmapMissingPrivileges
5354from lib .core .exception import sqlmapSyntaxException
@@ -528,7 +529,7 @@ def __setHTTPProxy():
528529
529530def __setHTTPAuthentication ():
530531 """
531- Check and set the HTTP authentication method (Basic or Digest ),
532+ Check and set the HTTP authentication method (Basic, Digest or NTLM ),
532533 username and password to perform HTTP requests with.
533534 """
534535
@@ -538,29 +539,29 @@ def __setHTTPAuthentication():
538539 return
539540
540541 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 "
542543 errMsg += "did not provide the credentials"
543544 raise sqlmapSyntaxException , errMsg
544545
545546 elif not conf .aType and conf .aCred :
546- errMsg = "you specified the HTTP Authentication credentials, "
547+ errMsg = "you specified the HTTP authentication credentials, "
547548 errMsg += "but did not provide the type"
548549 raise sqlmapSyntaxException , errMsg
549550
550- debugMsg = "setting the HTTP Authentication type and credentials"
551+ debugMsg = "setting the HTTP authentication type and credentials"
551552 logger .debug (debugMsg )
552553
553554 aTypeLower = conf .aType .lower ()
554555
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 "
558559 raise sqlmapSyntaxException , errMsg
559560
560561 aCredRegExp = re .search ("^(.*?)\:(.*?)$" , conf .aCred )
561562
562563 if not aCredRegExp :
563- errMsg = "HTTP Authentication credentials value must be "
564+ errMsg = "HTTP authentication credentials value must be "
564565 errMsg += "in format username:password"
565566 raise sqlmapSyntaxException , errMsg
566567
@@ -572,9 +573,21 @@ def __setHTTPAuthentication():
572573
573574 if aTypeLower == "basic" :
574575 authHandler = urllib2 .HTTPBasicAuthHandler (passwordMgr )
576+
575577 elif aTypeLower == "digest" :
576578 authHandler = urllib2 .HTTPDigestAuthHandler (passwordMgr )
577579
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+
578591
579592def __setHTTPMethod ():
580593 """
0 commit comments