mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-26 03:23:48 +03:00
more dump/unicode cleanup
This commit is contained in:
parent
64ad3b03be
commit
2fb8bf3b6a
|
@ -1352,6 +1352,12 @@ def getCommonStart(strings=[]):
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
def getUnicode(value):
|
||||||
|
if isinstance(value, basestring):
|
||||||
|
return value if isinstance(value, unicode) else unicode(value, conf.dataEncoding)
|
||||||
|
else:
|
||||||
|
return unicode(value)
|
||||||
|
|
||||||
def getBruteUnicode(string):
|
def getBruteUnicode(string):
|
||||||
retVal = unicode()
|
retVal = unicode()
|
||||||
for char in string:
|
for char in string:
|
||||||
|
|
|
@ -27,6 +27,7 @@ import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from lib.core.common import dataToDumpFile
|
from lib.core.common import dataToDumpFile
|
||||||
|
from lib.core.common import getUnicode
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ class Dump:
|
||||||
conf.loggedToOut = True
|
conf.loggedToOut = True
|
||||||
|
|
||||||
def __formatString(self, string):
|
def __formatString(self, string):
|
||||||
string = unicode(string)
|
string = getUnicode(string)
|
||||||
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
||||||
string = string.replace("__START__", "").replace("__STOP__", "")
|
string = string.replace("__START__", "").replace("__STOP__", "")
|
||||||
string = string.replace("__DEL__", ", ")
|
string = string.replace("__DEL__", ", ")
|
||||||
|
@ -71,7 +72,7 @@ class Dump:
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
data = unicode(data)
|
data = getUnicode(data)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
data = self.__formatString(data)
|
data = self.__formatString(data)
|
||||||
|
@ -99,7 +100,7 @@ class Dump:
|
||||||
if isinstance(element, basestring):
|
if isinstance(element, basestring):
|
||||||
self.__write("[*] %s" % element)
|
self.__write("[*] %s" % element)
|
||||||
elif isinstance(element, (list, tuple, set)):
|
elif isinstance(element, (list, tuple, set)):
|
||||||
self.__write("[*] " + ", ".join(unicode(e) for e in element))
|
self.__write("[*] " + ", ".join(getUnicode(e) for e in element))
|
||||||
|
|
||||||
if elements:
|
if elements:
|
||||||
self.__write("")
|
self.__write("")
|
||||||
|
@ -318,7 +319,7 @@ class Dump:
|
||||||
if column != "__infos__":
|
if column != "__infos__":
|
||||||
info = tableValues[column]
|
info = tableValues[column]
|
||||||
|
|
||||||
value = unicode(info["values"][i]) if type(info["values"][i]) != unicode else info["values"][i]
|
value = getUnicode(info["values"][i])
|
||||||
|
|
||||||
if re.search("^[\ *]*$", value):
|
if re.search("^[\ *]*$", value):
|
||||||
value = "NULL"
|
value = "NULL"
|
||||||
|
|
|
@ -7,6 +7,7 @@ import re
|
||||||
import xml.sax.saxutils as saxutils
|
import xml.sax.saxutils as saxutils
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
|
|
||||||
|
from lib.core.common import getUnicode
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
from lib.core.exception import sqlmapFilePathException
|
from lib.core.exception import sqlmapFilePathException
|
||||||
|
@ -130,22 +131,16 @@ class XMLDump:
|
||||||
if attrValue is None :
|
if attrValue is None :
|
||||||
attr.nodeValue = u''
|
attr.nodeValue = u''
|
||||||
else :
|
else :
|
||||||
attr.nodeValue = self.__getUnicode(attrValue)
|
attr.nodeValue = getUnicode(attrValue)
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
def __formatString(self, string):
|
def __formatString(self, string):
|
||||||
string = self.__getUnicode(string)
|
string = getUnicode(string)
|
||||||
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
||||||
string = string.replace("__START__", "").replace("__STOP__", "")
|
string = string.replace("__START__", "").replace("__STOP__", "")
|
||||||
string = string.replace("__DEL__", ", ")
|
string = string.replace("__DEL__", ", ")
|
||||||
return string
|
return string
|
||||||
|
|
||||||
def __getUnicode(self, value):
|
|
||||||
if isinstance(value, basestring):
|
|
||||||
return value if isinstance(value, unicode) else unicode(value, "utf-8")
|
|
||||||
else:
|
|
||||||
return unicode(value)
|
|
||||||
|
|
||||||
def string(self, header, data, sort=True):
|
def string(self, header, data, sort=True):
|
||||||
'''
|
'''
|
||||||
Adds string element to the xml.
|
Adds string element to the xml.
|
||||||
|
@ -196,7 +191,7 @@ class XMLDump:
|
||||||
for e in element :
|
for e in element :
|
||||||
memberElemStr = self.__doc.createElement(MEMBER_ELEM)
|
memberElemStr = self.__doc.createElement(MEMBER_ELEM)
|
||||||
memberElemStr.setAttributeNode(self.__createAttribute(TYPE_ATTR, "string"))
|
memberElemStr.setAttributeNode(self.__createAttribute(TYPE_ATTR, "string"))
|
||||||
memberElemStr.appendChild(self.__createTextNode(self.__getUnicode(e)))
|
memberElemStr.appendChild(self.__createTextNode(getUnicode(e)))
|
||||||
memberElem.appendChild(memberElemStr)
|
memberElem.appendChild(memberElemStr)
|
||||||
listsElem = self.__getRootChild(LSTS_ELEM_NAME)
|
listsElem = self.__getRootChild(LSTS_ELEM_NAME)
|
||||||
if not(listsElem):
|
if not(listsElem):
|
||||||
|
@ -250,7 +245,7 @@ class XMLDump:
|
||||||
Adds information to the xml that indicates whether the user has DBA privileges
|
Adds information to the xml that indicates whether the user has DBA privileges
|
||||||
'''
|
'''
|
||||||
isDBAElem = self.__doc.createElement(IS_DBA_ELEM_NAME)
|
isDBAElem = self.__doc.createElement(IS_DBA_ELEM_NAME)
|
||||||
isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, self.__getUnicode(isDBA)))
|
isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, getUnicode(isDBA)))
|
||||||
self.__addToRoot(isDBAElem)
|
self.__addToRoot(isDBAElem)
|
||||||
|
|
||||||
def users(self,users):
|
def users(self,users):
|
||||||
|
@ -502,7 +497,7 @@ class XMLDump:
|
||||||
'''
|
'''
|
||||||
if ((self.__outputFP is not None) and not(self.__outputFP.closed)):
|
if ((self.__outputFP is not None) and not(self.__outputFP.closed)):
|
||||||
statusElem = self.__doc.createElement(STATUS_ELEM_NAME)
|
statusElem = self.__doc.createElement(STATUS_ELEM_NAME)
|
||||||
statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,self.__getUnicode(resultStatus)))
|
statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,getUnicode(resultStatus)))
|
||||||
|
|
||||||
if not(resultStatus) :
|
if not(resultStatus) :
|
||||||
errorElem = self.__doc.createElement(ERROR_ELEM_NAME)
|
errorElem = self.__doc.createElement(ERROR_ELEM_NAME)
|
||||||
|
@ -512,7 +507,7 @@ class XMLDump:
|
||||||
else :
|
else :
|
||||||
errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE))
|
errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE))
|
||||||
|
|
||||||
errorElem.appendChild(self.__createTextNode(self.__getUnicode(resultMsg)))
|
errorElem.appendChild(self.__createTextNode(getUnicode(resultMsg)))
|
||||||
statusElem.appendChild(errorElem)
|
statusElem.appendChild(errorElem)
|
||||||
|
|
||||||
self.__addToRoot(statusElem)
|
self.__addToRoot(statusElem)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user