MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _setHTTPHandlers

Function _setHTTPHandlers

lib/core/option.py:1105–1223  ·  view source on GitHub ↗

Check and set the HTTP/SOCKS proxy for all HTTP requests.

()

Source from the content-addressed store, hash-verified

1103 thread.start()
1104
1105def _setHTTPHandlers():
1106 """
1107 Check and set the HTTP/SOCKS proxy for all HTTP requests.
1108 """
1109
1110 with kb.locks.handlers:
1111 if conf.proxyList:
1112 conf.proxy = conf.proxyList[0]
1113 conf.proxyList = conf.proxyList[1:] + conf.proxyList[:1]
1114
1115 if len(conf.proxyList) > 1:
1116 infoMsg = "loading proxy '%s' from a supplied proxy list file" % conf.proxy
1117 logger.info(infoMsg)
1118
1119 elif not conf.proxy:
1120 if conf.hostname in ("localhost", "127.0.0.1") or conf.ignoreProxy:
1121 proxyHandler.proxies = {}
1122
1123 if conf.proxy:
1124 debugMsg = "setting the HTTP/SOCKS proxy for all HTTP requests"
1125 logger.debug(debugMsg)
1126
1127 try:
1128 _ = _urllib.parse.urlsplit(conf.proxy)
1129 except Exception as ex:
1130 errMsg = "invalid proxy address '%s' ('%s')" % (conf.proxy, getSafeExString(ex))
1131 raise SqlmapSyntaxException(errMsg)
1132
1133 match = re.search(r"\A([^:]*):([^:]*)@([^@]+)\Z", _.netloc)
1134 if match:
1135 username, password = match.group(1), match.group(2)
1136 else:
1137 username, password = None, None
1138
1139 hostnamePort = _.netloc.rsplit('@', 1)[-1].rsplit(":", 1)
1140
1141 scheme = _.scheme.upper()
1142 hostname = hostnamePort[0]
1143 port = None
1144
1145 if len(hostnamePort) == 2:
1146 try:
1147 port = int(hostnamePort[1])
1148 except:
1149 pass # drops into the next check block
1150
1151 if not all((scheme, hasattr(PROXY_TYPE, scheme), hostname, port)):
1152 errMsg = "proxy value must be in format '(%s)://address:port'" % "|".join(_[0].lower() for _ in getPublicTypeMembers(PROXY_TYPE))
1153 raise SqlmapSyntaxException(errMsg)
1154
1155 if conf.proxyCred:
1156 _ = re.search(r"\A(.*?):(.*?)\Z", conf.proxyCred)
1157 if not _:
1158 errMsg = "proxy authentication credentials "
1159 errMsg += "value must be in format username:password"
1160 raise SqlmapSyntaxException(errMsg)
1161 else:
1162 username = _.group(1)

Callers 1

initFunction · 0.85

Calls 11

getSafeExStringFunction · 0.90
getPublicTypeMembersFunction · 0.90
singleTimeWarnMessageFunction · 0.90
filterNoneFunction · 0.90
resetCookieJarFunction · 0.90
infoMethod · 0.80
debugMethod · 0.80
searchMethod · 0.45
__init__Method · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…