Skip to content

Commit b2855e0

Browse files
committed
Minor patch
1 parent a711c9e commit b2855e0

5 files changed

Lines changed: 45 additions & 14 deletions

File tree

lib/core/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,10 @@ def logHTTPTraffic(requestLogMsg, responseLogMsg):
22442244
dataToTrafficFile("%s%s%s%s" % (os.linesep, 76 * '#', os.linesep, os.linesep))
22452245

22462246
def getPageTemplate(payload, place): # Cross-linked function
2247-
pass
2247+
raise NotImplementedError
2248+
2249+
def setHTTPProxy(): # Cross-linked function
2250+
raise NotImplementedError
22482251

22492252
def getPublicTypeMembers(type_, onlyValues=False):
22502253
"""

lib/core/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def htmlunescape(value):
133133
return retVal
134134

135135
def singleTimeWarnMessage(message): # Cross-linked function
136-
pass
136+
raise NotImplementedError
137137

138138
def stdoutencode(data):
139139
retVal = None

lib/core/option.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
authHandler = urllib2.BaseHandler()
150150
httpsHandler = HTTPSHandler()
151151
keepAliveHandler = keepalive.HTTPHandler()
152-
proxyHandler = urllib2.BaseHandler()
152+
proxyHandler = urllib2.ProxyHandler()
153153
redirectHandler = SmartRedirectHandler()
154154
rangeHandler = HTTPRangeHandler()
155155

@@ -981,21 +981,23 @@ def _setHTTPProxy():
981981
Check and set the HTTP/SOCKS proxy for all HTTP requests.
982982
"""
983983

984-
global proxyHandler
985-
986984
if not conf.proxy:
987-
if conf.hostname in ('localhost', '127.0.0.1') or conf.ignoreProxy:
988-
proxyHandler = urllib2.ProxyHandler({})
985+
if conf.proxyList:
986+
conf.proxy = conf.proxyList[0]
987+
conf.proxyList = conf.proxyList[1:] + conf.proxyList[:1]
988+
else:
989+
if conf.hostname in ('localhost', '127.0.0.1') or conf.ignoreProxy:
990+
proxyHandler.proxies = {}
989991

990-
return
992+
return
991993

992994
debugMsg = "setting the HTTP/SOCKS proxy for all HTTP requests"
993995
logger.debug(debugMsg)
994996

995-
proxySplit = urlparse.urlsplit(conf.proxy)
996-
hostnamePort = proxySplit.netloc.split(":")
997+
_ = urlparse.urlsplit(conf.proxy)
998+
hostnamePort = _.netloc.split(":")
997999

998-
scheme = proxySplit.scheme.upper()
1000+
scheme = _.scheme.upper()
9991001
hostname = hostnamePort[0]
10001002
port = None
10011003
username = None
@@ -1022,17 +1024,23 @@ def _setHTTPProxy():
10221024
password = _.group(2)
10231025

10241026
if scheme in (PROXY_TYPE.SOCKS4, PROXY_TYPE.SOCKS5):
1027+
proxyHandler.proxies = {}
1028+
10251029
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5 if scheme == PROXY_TYPE.SOCKS5 else socks.PROXY_TYPE_SOCKS4, hostname, port, username=username, password=password)
10261030
socks.wrapmodule(urllib2)
10271031
else:
1032+
socks.unwrapmodule(urllib2)
1033+
10281034
if conf.proxyCred:
10291035
# Reference: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection
10301036
proxyString = "%s@" % conf.proxyCred
10311037
else:
10321038
proxyString = ""
10331039

10341040
proxyString += "%s:%d" % (hostname, port)
1035-
proxyHandler = urllib2.ProxyHandler({"http": proxyString, "https": proxyString})
1041+
proxyHandler.proxies = {"http": proxyString, "https": proxyString}
1042+
1043+
proxyHandler.__init__(proxyHandler.proxies)
10361044

10371045
def _setSafeUrl():
10381046
"""
@@ -1540,6 +1548,7 @@ def _setConfAttributes():
15401548
conf.parameters = {}
15411549
conf.path = None
15421550
conf.port = None
1551+
conf.proxyList = []
15431552
conf.resultsFilename = None
15441553
conf.resultsFP = None
15451554
conf.scheme = None
@@ -1908,6 +1917,12 @@ def _setDNSServer():
19081917
errMsg += "for incoming address resolution attempts"
19091918
raise SqlmapMissingPrivileges(errMsg)
19101919

1920+
def _setProxyList():
1921+
if not conf.proxyFile:
1922+
return
1923+
1924+
conf.proxyList = getFileItems(conf.proxyFile)
1925+
19111926
def _setTorProxySettings():
19121927
if not conf.tor:
19131928
return
@@ -2154,8 +2169,11 @@ def _basicOptionValidation():
21542169
raise SqlmapFilePathException(errMsg)
21552170

21562171
def _resolveCrossReferences():
2172+
import pdb
2173+
pdb.set_trace()
21572174
lib.core.threads.readInput = readInput
21582175
lib.core.common.getPageTemplate = getPageTemplate
2176+
lib.core.common.setHTTPProxy = _setHTTPProxy
21592177
lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage
21602178

21612179
def initOptions(inputOptions=AttribDict(), overrideOptions=False):
@@ -2180,6 +2198,7 @@ def init():
21802198
_purgeOutput()
21812199
_checkDependencies()
21822200
_basicOptionValidation()
2201+
_setProxyList()
21832202
_setTorProxySettings()
21842203
_setDNSServer()
21852204
_adjustLoggingFormatter()

lib/request/connect.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from lib.core.common import randomStr
3838
from lib.core.common import readInput
3939
from lib.core.common import removeReflectiveValues
40+
from lib.core.common import setHTTPProxy
4041
from lib.core.common import singleTimeLogMessage
4142
from lib.core.common import singleTimeWarnMessage
4243
from lib.core.common import stdev
@@ -107,6 +108,14 @@ def _retryProxy(**kwargs):
107108
threadData = getCurrentThreadData()
108109
threadData.retriesCount += 1
109110

111+
if threadData.retriesCount >= conf.retries:
112+
warnMsg = "changing proxy"
113+
logger.warn(warnMsg)
114+
115+
conf.proxy = conf.proxyList[0]
116+
conf.proxyList = conf.proxyList[1:] + conf.proxyList[:1]
117+
setHTTPProxy()
118+
110119
if kb.testMode and kb.previousMethod == PAYLOAD.METHOD.TIME:
111120
# timed based payloads can cause web server unresponsiveness
112121
# if the injectable piece of code is some kind of JOIN-like query

plugins/dbms/oracle/connector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def connect(self):
4242
try:
4343
self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password, mode=cx_Oracle.SYSDBA)
4444
logger.info("successfully connected as SYSDBA")
45-
except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError):
45+
except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError):
4646
try:
4747
self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password)
48-
except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError), msg:
48+
except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError), msg:
4949
raise SqlmapConnectionException(msg)
5050

5151
self.initCursor()

0 commit comments

Comments
 (0)