diff --git a/lib/controller/checks.py b/lib/controller/checks.py index dc8ed740a..4565ee5f3 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -257,7 +257,7 @@ def checkDynParam(place, parameter, value): logger.info(infoMsg) randInt = randomInt() - payload = agent.payload(place, parameter, value, str(randInt)) + payload = agent.payload(place, parameter, value, unicode(randInt)) dynResult1 = Request.queryPage(payload, place) if True == dynResult1: @@ -395,7 +395,7 @@ def checkConnection(): conf.seqMatcher.set_seq1(page) except sqlmapConnectionException, errMsg: - errMsg = str(errMsg) + errMsg = unicode(errMsg) raise sqlmapConnectionException, errMsg return True diff --git a/lib/controller/controller.py b/lib/controller/controller.py index 436fd773d..a81e84b92 100644 --- a/lib/controller/controller.py +++ b/lib/controller/controller.py @@ -155,7 +155,7 @@ def start(): if not conf.dropSetCookie: for _, cookie in enumerate(conf.cj): - cookie = str(cookie) + cookie = unicode(cookie) index = cookie.index(" for ") cookieStr += "%s;" % cookie[8:index] @@ -267,7 +267,7 @@ def start(): action() except exceptionsTuple, e: - e = str(e) + e = unicode(e) if conf.multipleTargets: e += ", skipping to next url" diff --git a/lib/core/common.py b/lib/core/common.py index e0e8005ab..4a213a4d2 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -451,7 +451,7 @@ def readInput(message, default=None): message += "\n> " if conf.batch and default: - infoMsg = "%s%s" % (message, str(default)) + infoMsg = "%s%s" % (message, unicode(default)) logger.info(infoMsg) debugMsg = "used the default behaviour, running in batch mode" @@ -517,7 +517,7 @@ def sanitizeStr(inpStr): @rtype: C{str} """ - cleanString = str(inpStr) + cleanString = unicode(inpStr) cleanString = cleanString.replace("\n", " ").replace("\r", "") return cleanString @@ -638,8 +638,8 @@ def parseTargetDirect(): conf.dbmsUser = details.group('user') conf.dbmsPass = details.group('pass') else: - conf.dbmsUser = str() - conf.dbmsPass = str() + conf.dbmsUser = unicode() + conf.dbmsPass = unicode() if not conf.dbmsPass: conf.dbmsPass = None @@ -1032,7 +1032,7 @@ def safeStringFormat(formatStr, params): if index != -1: if count < len(params): - retVal = retVal[:index] + str(params[count]) + retVal[index+2:] + retVal = retVal[:index] + unicode(params[count]) + retVal[index+2:] else: raise sqlmapNoneDataException, "wrong number of parameters during string formatting" count += 1 @@ -1107,7 +1107,7 @@ def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None): import gtk import pydot except ImportError, e: - errMsg = "profiling requires third-party libraries (%s)" % str(e) + errMsg = "profiling requires third-party libraries (%s)" % unicode(e) logger.error(errMsg) return @@ -1343,7 +1343,7 @@ def getCommonStart(strings=[]): if len(strings) == 1: return strings[0] - retVal = str() + retVal = unicode() maxCount = min(len(string) for string in strings) count = 0 diff --git a/lib/core/dump.py b/lib/core/dump.py index 34d9fff9b..5eb3c4b90 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -63,7 +63,7 @@ class Dump: return - data = str(data) + data = unicode(data) if data: data = data.replace("__NEWLINE__", "\n").replace("__TAB__", "\t") @@ -93,7 +93,7 @@ class Dump: if isinstance(element, basestring): self.__write("[*] %s" % element) elif isinstance(element, (list, tuple, set)): - self.__write("[*] " + ", ".join(str(e) for e in element)) + self.__write("[*] " + ", ".join(unicode(e) for e in element)) if elements: self.__write("") diff --git a/lib/core/progress.py b/lib/core/progress.py index 7d5a5751d..615182d16 100644 --- a/lib/core/progress.py +++ b/lib/core/progress.py @@ -80,7 +80,7 @@ class ProgressBar: " " * (allFull - numHashes)) # Add the percentage at the beginning of the progress bar - percentString = str(percentDone) + "%" + percentString = unicode(percentDone) + "%" self.__progBar = "%s %s" % (percentString, self.__progBar) def draw(self, eta=0): @@ -102,4 +102,4 @@ class ProgressBar: This method returns the progress bar string """ - return str(self.__progBar) + return unicode(self.__progBar) diff --git a/lib/core/update.py b/lib/core/update.py index 837164e16..0c974e28c 100644 --- a/lib/core/update.py +++ b/lib/core/update.py @@ -214,7 +214,7 @@ def __updateSqlmap(): logger.debug(debugMsg) def notify(event_dict): - action = str(event_dict['action']) + action = unicode(event_dict['action']) index = action.find('_') prefix = action[index + 1].upper() if index != -1 else action.capitalize() @@ -224,7 +224,7 @@ def __updateSqlmap(): if action.find('_completed') == -1: print "%s\t%s" % (prefix, event_dict['path']) else: - revision = str(event_dict['revision']) + revision = unicode(event_dict['revision']) index = revision.find('number ') if index != -1: diff --git a/lib/request/basic.py b/lib/request/basic.py index 67cb912f1..b712a8d36 100644 --- a/lib/request/basic.py +++ b/lib/request/basic.py @@ -94,7 +94,7 @@ def decodePage(page, encoding): Decode gzip/deflate HTTP response """ - if str(encoding).lower() in ('gzip', 'x-gzip', 'deflate'): + if unicode(encoding).lower() in (u'gzip', u'x-gzip', u'deflate'): if encoding == 'deflate': # http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations data = StringIO.StringIO(zlib.decompress(page, -15)) diff --git a/lib/request/connect.py b/lib/request/connect.py index 7e40c2757..ac34cb674 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -163,7 +163,7 @@ class Connect: if not cookieStr: cookieStr = "Cookie: " - cookie = str(cookie) + cookie = unicode(cookie) index = cookie.index(" for ") cookieStr += "%s; " % cookie[8:index] @@ -257,7 +257,7 @@ class Connect: responseMsg += "(%s - %d):\n" % (status, code) if conf.verbose <= 4: - responseMsg += str(responseHeaders) + responseMsg += unicode(responseHeaders) elif conf.verbose > 4: responseMsg += "%s\n%s\n" % (responseHeaders, page) diff --git a/lib/request/direct.py b/lib/request/direct.py index ca8ef944f..cc5c487cd 100644 --- a/lib/request/direct.py +++ b/lib/request/direct.py @@ -54,7 +54,7 @@ def direct(query, content=True): output = base64unpickle(kb.resumedQueries[conf.hostname][query][:-1]) infoMsg = "resumed from file '%s': " % conf.sessionFile - infoMsg += "%s..." % str(output)[:20] + infoMsg += "%s..." % unicode(output)[:20] logger.info(infoMsg) elif select: output = timeout(func=conf.dbmsConnector.select, args=(query,), duration=conf.timeout, default=None) @@ -67,7 +67,7 @@ def direct(query, content=True): if len(output) == 1: if len(output[0]) == 1: - return str(list(output)[0][0]) + return unicode(list(output)[0][0]) else: return list(output) else: diff --git a/lib/takeover/metasploit.py b/lib/takeover/metasploit.py index d663f6223..51c965c8f 100644 --- a/lib/takeover/metasploit.py +++ b/lib/takeover/metasploit.py @@ -156,7 +156,7 @@ class Metasploit: if not choice: if lst: - choice = str(default) + choice = unicode(default) else: return default diff --git a/lib/techniques/inband/union/use.py b/lib/techniques/inband/union/use.py index fdc508dab..71185d118 100644 --- a/lib/techniques/inband/union/use.py +++ b/lib/techniques/inband/union/use.py @@ -227,7 +227,7 @@ def unionUse(expression, direct=False, unescape=True, resetCounter=False, nullCh # sql injection output startPosition = resultPage.index(temp.start) endPosition = resultPage.rindex(temp.stop) + len(temp.stop) - value = str(resultPage[startPosition:endPosition]) + value = unicode(resultPage[startPosition:endPosition]) duration = calculateDeltaSeconds(start) diff --git a/lib/utils/google.py b/lib/utils/google.py index db26cdaa6..a1ea89a16 100644 --- a/lib/utils/google.py +++ b/lib/utils/google.py @@ -123,7 +123,7 @@ class Google: responseMsg = "HTTP response (%s - %d):\n" % (status, code) if conf.verbose <= 4: - responseMsg += str(responseHeaders) + responseMsg += unicode(responseHeaders) elif conf.verbose > 4: responseMsg += "%s\n%s\n" % (responseHeaders, page) diff --git a/plugins/dbms/firebird/fingerprint.py b/plugins/dbms/firebird/fingerprint.py index 8091c54e8..dac5828d2 100644 --- a/plugins/dbms/firebird/fingerprint.py +++ b/plugins/dbms/firebird/fingerprint.py @@ -94,7 +94,7 @@ class Fingerprint(GenericFingerprint): for i in xrange(len(table)): version, checks = table[i] failed = False - check = checks[randomRange(0,len(checks)-1)].replace("%d", str(randomRange(1,100))) + check = checks[randomRange(0,len(checks)-1)].replace("%d", unicode(randomRange(1,100))) payload = agent.fullPayload(check) result = Request.queryPage(payload) if result: diff --git a/plugins/dbms/mssqlserver/fingerprint.py b/plugins/dbms/mssqlserver/fingerprint.py index 32c6c97ca..56fa036e6 100644 --- a/plugins/dbms/mssqlserver/fingerprint.py +++ b/plugins/dbms/mssqlserver/fingerprint.py @@ -217,7 +217,7 @@ class Fingerprint(GenericFingerprint): for sp in sps: query = "(SELECT LEN(%s) FROM %s WHERE %s " % (self.tblField, self.fileTblName, self.tblField) - query += "LIKE '%Service Pack " + str(sp) + "%')>0" + query += "LIKE '%Service Pack " + unicode(sp) + "%')>0" query = agent.forgeCaseStatement(query) if inject.getValue(query, charsetType=1) == "1": diff --git a/plugins/dbms/mysql/fingerprint.py b/plugins/dbms/mysql/fingerprint.py index dc58b2df4..a3b945852 100644 --- a/plugins/dbms/mysql/fingerprint.py +++ b/plugins/dbms/mysql/fingerprint.py @@ -76,7 +76,7 @@ class Fingerprint(GenericFingerprint): for version in range(element[0], element[1] + 1): randInt = randomInt() - version = str(version) + version = unicode(version) query = agent.prefixQuery(" /*!%s AND %d=%d*/" % (version, randInt, randInt + 1)) query = agent.postfixQuery(query) payload = agent.payload(newValue=query) @@ -168,7 +168,7 @@ class Fingerprint(GenericFingerprint): infoMsg = "testing MySQL" logger.info(infoMsg) - randInt = str(randomInt(1)) + randInt = unicode(randomInt(1)) payload = agent.fullPayload(" AND CONNECTION_ID()=CONNECTION_ID()") result = Request.queryPage(payload) diff --git a/plugins/dbms/postgresql/fingerprint.py b/plugins/dbms/postgresql/fingerprint.py index 1e675d447..861bc0a14 100644 --- a/plugins/dbms/postgresql/fingerprint.py +++ b/plugins/dbms/postgresql/fingerprint.py @@ -97,7 +97,7 @@ class Fingerprint(GenericFingerprint): infoMsg = "testing PostgreSQL" logger.info(infoMsg) - randInt = str(randomInt(1)) + randInt = unicode(randomInt(1)) payload = agent.fullPayload(" AND %s::int=%s" % (randInt, randInt)) result = Request.queryPage(payload) diff --git a/sqlmap.py b/sqlmap.py index c7c84083b..0cc1d05ab 100755 --- a/sqlmap.py +++ b/sqlmap.py @@ -81,7 +81,7 @@ def main(): else: start() except exceptionsTuple, e: - e = str(e) + e = unicode(e) logger.error(e) except KeyboardInterrupt: