|
27 | 27 | import lib.core.threads |
28 | 28 | import lib.core.convert |
29 | 29 | import lib.request.connect |
| 30 | +import lib.utils.google |
30 | 31 |
|
31 | 32 | from lib.controller.checks import checkConnection |
32 | 33 | from lib.core.common import Backend |
|
91 | 92 | from lib.core.exception import SqlmapMissingDependence |
92 | 93 | from lib.core.exception import SqlmapMissingMandatoryOptionException |
93 | 94 | from lib.core.exception import SqlmapMissingPrivileges |
| 95 | +from lib.core.exception import SqlmapNoneDataException |
94 | 96 | from lib.core.exception import SqlmapSilentQuitException |
95 | 97 | from lib.core.exception import SqlmapSyntaxException |
96 | 98 | from lib.core.exception import SqlmapSystemException |
@@ -1084,18 +1086,22 @@ def _setHTTPProxy(): |
1084 | 1086 | if hasattr(proxyHandler, "%s_open" % _): |
1085 | 1087 | delattr(proxyHandler, "%s_open" % _) |
1086 | 1088 |
|
1087 | | - if not conf.proxy: |
1088 | | - if conf.proxyList: |
1089 | | - conf.proxy = conf.proxyList[0] |
1090 | | - conf.proxyList = conf.proxyList[1:] + conf.proxyList[:1] |
| 1089 | + if conf.proxyList is not None: |
| 1090 | + if not conf.proxyList: |
| 1091 | + errMsg = "list of usable proxies is empty" |
| 1092 | + raise SqlmapNoneDataException(errMsg) |
1091 | 1093 |
|
1092 | | - infoMsg = "loading proxy '%s' from a supplied proxy list file" % conf.proxy |
1093 | | - logger.info(infoMsg) |
1094 | | - else: |
1095 | | - if conf.hostname in ('localhost', '127.0.0.1') or conf.ignoreProxy: |
1096 | | - proxyHandler.proxies = {} |
| 1094 | + conf.proxy = conf.proxyList[0] |
| 1095 | + conf.proxyList = conf.proxyList[1:] |
1097 | 1096 |
|
1098 | | - return |
| 1097 | + infoMsg = "loading proxy '%s' from a supplied proxy list file" % conf.proxy |
| 1098 | + logger.info(infoMsg) |
| 1099 | + |
| 1100 | + elif not conf.proxy: |
| 1101 | + if conf.hostname in ("localhost", "127.0.0.1") or conf.ignoreProxy: |
| 1102 | + proxyHandler.proxies = {} |
| 1103 | + |
| 1104 | + return |
1099 | 1105 |
|
1100 | 1106 | debugMsg = "setting the HTTP/SOCKS proxy for all HTTP requests" |
1101 | 1107 | logger.debug(debugMsg) |
@@ -1127,7 +1133,7 @@ def _setHTTPProxy(): |
1127 | 1133 | if conf.proxyCred: |
1128 | 1134 | _ = re.search("^(.*?):(.*?)$", conf.proxyCred) |
1129 | 1135 | if not _: |
1130 | | - errMsg = "Proxy authentication credentials " |
| 1136 | + errMsg = "proxy authentication credentials " |
1131 | 1137 | errMsg += "value must be in format username:password" |
1132 | 1138 | raise SqlmapSyntaxException(errMsg) |
1133 | 1139 | else: |
@@ -1735,7 +1741,7 @@ def _setConfAttributes(): |
1735 | 1741 | conf.parameters = {} |
1736 | 1742 | conf.path = None |
1737 | 1743 | conf.port = None |
1738 | | - conf.proxyList = [] |
| 1744 | + conf.proxyList = None |
1739 | 1745 | conf.resultsFilename = None |
1740 | 1746 | conf.resultsFP = None |
1741 | 1747 | conf.scheme = None |
@@ -2413,6 +2419,10 @@ def _basicOptionValidation(): |
2413 | 2419 | errMsg = "switch '--tor' is incompatible with option '--proxy'" |
2414 | 2420 | raise SqlmapSyntaxException(errMsg) |
2415 | 2421 |
|
| 2422 | + if conf.proxy and conf.proxyFile: |
| 2423 | + errMsg = "switch '--proxy' is incompatible with option '--proxy-file'" |
| 2424 | + raise SqlmapSyntaxException(errMsg) |
| 2425 | + |
2416 | 2426 | if conf.checkTor and not any((conf.tor, conf.proxy)): |
2417 | 2427 | errMsg = "switch '--check-tor' requires usage of switch '--tor' (or option '--proxy' with HTTP proxy address using Tor)" |
2418 | 2428 | raise SqlmapSyntaxException(errMsg) |
@@ -2480,6 +2490,7 @@ def _resolveCrossReferences(): |
2480 | 2490 | lib.core.common.getPageTemplate = getPageTemplate |
2481 | 2491 | lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage |
2482 | 2492 | lib.request.connect.setHTTPProxy = _setHTTPProxy |
| 2493 | + lib.utils.google.setHTTPProxy = _setHTTPProxy |
2483 | 2494 | lib.controller.checks.setVerbosity = setVerbosity |
2484 | 2495 |
|
2485 | 2496 | def initOptions(inputOptions=AttribDict(), overrideOptions=False): |
|
0 commit comments