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

Skip to content

Commit 8aa12db

Browse files
committed
added option --proxy-cred for setting proxy credentials (Feature #195)
1 parent 526aebc commit 8aa12db

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

lib/core/option.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,18 @@ def __setHTTPProxy():
578578
errMsg = "proxy value must be in format 'http://url:port'"
579579
raise sqlmapSyntaxException, errMsg
580580

581-
__proxyString = "%s:%d" % (__hostname, __port)
581+
if conf.pCred:
582+
pCredRegExp = re.search("^(.*?):(.*?)$", conf.pCred)
583+
584+
if not pCredRegExp:
585+
errMsg = "Proxy authentication credentials "
586+
errMsg += "value must be in format username:password"
587+
raise sqlmapSyntaxException, errMsg
588+
589+
# Reference: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection
590+
__proxyString = "%s@%s:%d" % (conf.pCred, __hostname, __port)
591+
else:
592+
__proxyString = "%s:%d" % (__hostname, __port)
582593

583594
# Workaround for http://bugs.python.org/issue1424152 (urllib/urllib2:
584595
# HTTPS over (Squid) Proxy fails) as long as HTTP over SSL requests

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"aCert": "string",
5252
"keepAlive": "boolean",
5353
"proxy": "string",
54+
"pCred": "string",
5455
"ignoreProxy": "boolean",
5556
"threads": "integer",
5657
"delay": "float",

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ def cmdLineParser():
119119
request.add_option("--proxy", dest="proxy",
120120
help="Use a HTTP proxy to connect to the target url")
121121

122+
request.add_option("--proxy-cred", dest="pCred",
123+
help="Proxy authentication credentials "
124+
"(name:password)")
125+
122126
request.add_option("--ignore-proxy", dest="ignoreProxy",
123127
action="store_true",
124128
help="Ignore system default HTTP proxy")

0 commit comments

Comments
 (0)