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

Skip to content

Commit b4526a3

Browse files
committed
Bug fix (usage of socks and http proxies in --proxy-file didn't work together)
1 parent 9849f87 commit b4526a3

1 file changed

Lines changed: 31 additions & 37 deletions

File tree

lib/core/option.py

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -163,42 +163,6 @@
163163
redirectHandler = SmartRedirectHandler()
164164
rangeHandler = HTTPRangeHandler()
165165

166-
def _urllib2Opener():
167-
"""
168-
This function creates the urllib2 OpenerDirector.
169-
"""
170-
171-
debugMsg = "creating HTTP requests opener object"
172-
logger.debug(debugMsg)
173-
174-
handlers = [proxyHandler, authHandler, redirectHandler, rangeHandler, httpsHandler]
175-
176-
if not conf.dropSetCookie:
177-
if not conf.loadCookies:
178-
conf.cj = cookielib.CookieJar()
179-
else:
180-
conf.cj = cookielib.MozillaCookieJar()
181-
resetCookieJar(conf.cj)
182-
183-
handlers.append(urllib2.HTTPCookieProcessor(conf.cj))
184-
185-
# Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
186-
if conf.keepAlive:
187-
warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
188-
warnMsg += "been disabled because of its incompatibility "
189-
190-
if conf.proxy:
191-
warnMsg += "with HTTP(s) proxy"
192-
logger.warn(warnMsg)
193-
elif conf.authType:
194-
warnMsg += "with authentication methods"
195-
logger.warn(warnMsg)
196-
else:
197-
handlers.append(keepAliveHandler)
198-
199-
opener = urllib2.build_opener(*handlers)
200-
urllib2.install_opener(opener)
201-
202166
def _feedTargetsDict(reqFile, addedTargetUrls):
203167
"""
204168
Parses web scarab and burp logs and adds results to the target URL list
@@ -1160,6 +1124,37 @@ def _setHTTPProxy():
11601124

11611125
proxyHandler.__init__(proxyHandler.proxies)
11621126

1127+
debugMsg = "creating HTTP requests opener object"
1128+
logger.debug(debugMsg)
1129+
1130+
handlers = filter(None, [proxyHandler if proxyHandler.proxies else None, authHandler, redirectHandler, rangeHandler, httpsHandler])
1131+
1132+
if not conf.dropSetCookie:
1133+
if not conf.loadCookies:
1134+
conf.cj = cookielib.CookieJar()
1135+
else:
1136+
conf.cj = cookielib.MozillaCookieJar()
1137+
resetCookieJar(conf.cj)
1138+
1139+
handlers.append(urllib2.HTTPCookieProcessor(conf.cj))
1140+
1141+
# Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
1142+
if conf.keepAlive:
1143+
warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
1144+
warnMsg += "been disabled because of its incompatibility "
1145+
1146+
if conf.proxy:
1147+
warnMsg += "with HTTP(s) proxy"
1148+
logger.warn(warnMsg)
1149+
elif conf.authType:
1150+
warnMsg += "with authentication methods"
1151+
logger.warn(warnMsg)
1152+
else:
1153+
handlers.append(keepAliveHandler)
1154+
1155+
opener = urllib2.build_opener(*handlers)
1156+
urllib2.install_opener(opener)
1157+
11631158
def _setSafeVisit():
11641159
"""
11651160
Check and set the safe visit options.
@@ -2550,7 +2545,6 @@ def init():
25502545
_setGoogleDorking()
25512546
_setBulkMultipleTargets()
25522547
_setSitemapTargets()
2553-
_urllib2Opener()
25542548
_checkTor()
25552549
_setCrawler()
25562550
_findPageForms()

0 commit comments

Comments
 (0)