added option --proxy-cred for setting proxy credentials (Feature #195)

This commit is contained in:
Miroslav Stampar 2010-08-18 22:45:00 +00:00
parent 526aebc84c
commit 8aa12db425
3 changed files with 17 additions and 1 deletions

View File

@ -578,6 +578,17 @@ def __setHTTPProxy():
errMsg = "proxy value must be in format 'http://url:port'"
raise sqlmapSyntaxException, errMsg
if conf.pCred:
pCredRegExp = re.search("^(.*?):(.*?)$", conf.pCred)
if not pCredRegExp:
errMsg = "Proxy authentication credentials "
errMsg += "value must be in format username:password"
raise sqlmapSyntaxException, errMsg
# Reference: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection
__proxyString = "%s@%s:%d" % (conf.pCred, __hostname, __port)
else:
__proxyString = "%s:%d" % (__hostname, __port)
# Workaround for http://bugs.python.org/issue1424152 (urllib/urllib2:

View File

@ -51,6 +51,7 @@ optDict = {
"aCert": "string",
"keepAlive": "boolean",
"proxy": "string",
"pCred": "string",
"ignoreProxy": "boolean",
"threads": "integer",
"delay": "float",

View File

@ -119,6 +119,10 @@ def cmdLineParser():
request.add_option("--proxy", dest="proxy",
help="Use a HTTP proxy to connect to the target url")
request.add_option("--proxy-cred", dest="pCred",
help="Proxy authentication credentials "
"(name:password)")
request.add_option("--ignore-proxy", dest="ignoreProxy",
action="store_true",
help="Ignore system default HTTP proxy")