|
163 | 163 | redirectHandler = SmartRedirectHandler() |
164 | 164 | rangeHandler = HTTPRangeHandler() |
165 | 165 |
|
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 | | - |
202 | 166 | def _feedTargetsDict(reqFile, addedTargetUrls): |
203 | 167 | """ |
204 | 168 | Parses web scarab and burp logs and adds results to the target URL list |
@@ -1160,6 +1124,37 @@ def _setHTTPProxy(): |
1160 | 1124 |
|
1161 | 1125 | proxyHandler.__init__(proxyHandler.proxies) |
1162 | 1126 |
|
| 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 | + |
1163 | 1158 | def _setSafeVisit(): |
1164 | 1159 | """ |
1165 | 1160 | Check and set the safe visit options. |
@@ -2550,7 +2545,6 @@ def init(): |
2550 | 2545 | _setGoogleDorking() |
2551 | 2546 | _setBulkMultipleTargets() |
2552 | 2547 | _setSitemapTargets() |
2553 | | - _urllib2Opener() |
2554 | 2548 | _checkTor() |
2555 | 2549 | _setCrawler() |
2556 | 2550 | _findPageForms() |
|
0 commit comments