mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 09:36:35 +03:00
added support for proper unicode session(s) storage/retrieval
This commit is contained in:
parent
f34e6badfd
commit
e9be60e1ac
|
@ -22,6 +22,7 @@ with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
|||
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
"""
|
||||
|
||||
import codecs
|
||||
import cProfile
|
||||
import os
|
||||
import random
|
||||
|
@ -351,8 +352,11 @@ def filePathToString(filePath):
|
|||
return strRepl
|
||||
|
||||
def dataToStdout(data):
|
||||
sys.stdout.write(data)
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
sys.stdout.write(data)
|
||||
sys.stdout.flush()
|
||||
except UnicodeEncodeError:
|
||||
print data.encode("utf8")
|
||||
|
||||
def dataToSessionFile(data):
|
||||
if not conf.sessionFile:
|
||||
|
@ -371,7 +375,7 @@ def dataToOutFile(data):
|
|||
|
||||
rFile = filePathToString(conf.rFile)
|
||||
rFilePath = "%s%s%s" % (conf.filePath, os.sep, rFile)
|
||||
rFileFP = open(rFilePath, "wb")
|
||||
rFileFP = codecs.open(rFilePath, "wb", "utf-8")
|
||||
|
||||
rFileFP.write(data)
|
||||
rFileFP.flush()
|
||||
|
@ -412,7 +416,7 @@ def fileToStr(fileName):
|
|||
@rtype: C{str}
|
||||
"""
|
||||
|
||||
filePointer = open(fileName, "r")
|
||||
filePointer = codecs.open(fileName, "r", "utf-8")
|
||||
fileText = filePointer.read()
|
||||
|
||||
return fileText.replace(" ", "").replace("\t", "").replace("\r", "").replace("\n", " ")
|
||||
|
|
|
@ -22,8 +22,9 @@ with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
|||
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
"""
|
||||
|
||||
import os
|
||||
import codecs
|
||||
import re
|
||||
import os
|
||||
|
||||
from lib.core.common import dataToDumpFile
|
||||
from lib.core.data import conf
|
||||
|
@ -54,7 +55,7 @@ class Dump:
|
|||
|
||||
def setOutputFile(self):
|
||||
self.__outputFile = "%s%slog" % (conf.outputPath, os.sep)
|
||||
self.__outputFP = open(self.__outputFile, "a")
|
||||
self.__outputFP = codecs.open(self.__outputFile, "a", "utf-8")
|
||||
|
||||
def string(self, header, data, sort=True):
|
||||
if isinstance(data, (list, tuple, set)):
|
||||
|
@ -267,7 +268,7 @@ class Dump:
|
|||
os.makedirs(dumpDbPath, 0755)
|
||||
|
||||
dumpFileName = "%s%s%s.csv" % (dumpDbPath, os.sep, table)
|
||||
dumpFP = open(dumpFileName, "w")
|
||||
dumpFP = codecs.open(dumpFileName, "w", "utf-8")
|
||||
|
||||
count = int(tableValues["__infos__"]["count"])
|
||||
separator = ""
|
||||
|
@ -319,13 +320,14 @@ class Dump:
|
|||
for column in columns:
|
||||
if column != "__infos__":
|
||||
info = tableValues[column]
|
||||
value = info["values"][i]
|
||||
|
||||
if re.search("^[\ *]*$", str(value)):
|
||||
value = unicode(info["values"][i]) if type(info["values"][i]) != unicode else info["values"][i]
|
||||
|
||||
if re.search("^[\ *]*$", value):
|
||||
value = "NULL"
|
||||
|
||||
maxlength = int(info["length"])
|
||||
blank = " " * (maxlength - len(str(value)))
|
||||
blank = " " * (maxlength - len(value))
|
||||
self.__write("| %s%s" % (value, blank), n=False)
|
||||
|
||||
if not conf.multipleTargets and field == fields:
|
||||
|
|
|
@ -22,6 +22,7 @@ with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
|||
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
"""
|
||||
|
||||
import codecs
|
||||
import cookielib
|
||||
import ctypes
|
||||
import difflib
|
||||
|
@ -96,7 +97,7 @@ def __urllib2Opener():
|
|||
urllib2.install_opener(opener)
|
||||
|
||||
def __feedTargetsDict(reqFile, addedTargetUrls):
|
||||
fp = open(reqFile, "r")
|
||||
fp = codecs.open(reqFile, "r", "utf-8")
|
||||
|
||||
fread = fp.read()
|
||||
fread = fread.replace("\r", "")
|
||||
|
|
|
@ -22,6 +22,7 @@ with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
|||
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
"""
|
||||
|
||||
import codecs
|
||||
import os
|
||||
import time
|
||||
|
||||
|
@ -121,11 +122,11 @@ def __setOutputResume():
|
|||
|
||||
if os.path.exists(conf.sessionFile):
|
||||
if not conf.flushSession:
|
||||
readSessionFP = open(conf.sessionFile, "r")
|
||||
readSessionFP = codecs.open(conf.sessionFile, "r", "utf-8")
|
||||
__url_cache = set()
|
||||
__expression_cache = {}
|
||||
|
||||
for line in readSessionFP.xreadlines():
|
||||
for line in readSessionFP.readlines(): #xreadlines doesn't return unicode strings when codec.open used
|
||||
if line.count("][") == 4:
|
||||
line = line.split("][")
|
||||
|
||||
|
@ -170,7 +171,7 @@ def __setOutputResume():
|
|||
raise sqlmapFilePathException, errMsg
|
||||
|
||||
try:
|
||||
conf.sessionFP = open(conf.sessionFile, "a")
|
||||
conf.sessionFP = codecs.open(conf.sessionFile, "a", "utf-8")
|
||||
dataToSessionFile("\n[%s]\n" % time.strftime("%X %x"))
|
||||
except IOError:
|
||||
errMsg = "unable to write on the session file specified"
|
||||
|
|
|
@ -194,10 +194,10 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
|||
minValue = charTbl[0]
|
||||
else:
|
||||
retVal = minValue + 1
|
||||
if retVal < 256:
|
||||
if retVal < 128:
|
||||
return chr(retVal)
|
||||
else:
|
||||
return unichr(retVal)
|
||||
return unichr(retVal) #test value 50089
|
||||
|
||||
def etaProgressUpdate(charTime, index):
|
||||
if len(progressTime) <= ( (length * 3) / 100 ):
|
||||
|
|
Loading…
Reference in New Issue
Block a user