mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-24 08:14:24 +03:00
some code refactoring
This commit is contained in:
parent
1bdf94f236
commit
915d3441e9
|
@ -34,8 +34,10 @@ import ntpath
|
||||||
import posixpath
|
import posixpath
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from StringIO import StringIO
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
from tempfile import mkstemp
|
from tempfile import mkstemp
|
||||||
|
from xml.sax import parse
|
||||||
|
|
||||||
from extra.cloak.cloak import decloak
|
from extra.cloak.cloak import decloak
|
||||||
from lib.contrib import magic
|
from lib.contrib import magic
|
||||||
|
@ -1085,3 +1087,11 @@ def getConsoleWidth(default=80):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return width if width else default
|
return width if width else default
|
||||||
|
|
||||||
|
def parseXmlFile(xmlFile, handler):
|
||||||
|
file = open(paths.GENERIC_XML)
|
||||||
|
content = file.read()
|
||||||
|
stream = StringIO(content)
|
||||||
|
parse(stream, handler)
|
||||||
|
stream.close()
|
||||||
|
file.close()
|
||||||
|
|
|
@ -24,11 +24,10 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from StringIO import StringIO
|
|
||||||
from xml.sax import parse
|
|
||||||
from xml.sax.handler import ContentHandler
|
from xml.sax.handler import ContentHandler
|
||||||
|
|
||||||
from lib.core.common import checkFile
|
from lib.core.common import checkFile
|
||||||
|
from lib.core.common import parseXmlFile
|
||||||
from lib.core.common import sanitizeStr
|
from lib.core.common import sanitizeStr
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import paths
|
from lib.core.data import paths
|
||||||
|
@ -122,11 +121,11 @@ def bannerParser(banner):
|
||||||
|
|
||||||
if kb.dbms == "Microsoft SQL Server":
|
if kb.dbms == "Microsoft SQL Server":
|
||||||
handler = MSSQLBannerHandler(banner, kb.bannerFp)
|
handler = MSSQLBannerHandler(banner, kb.bannerFp)
|
||||||
parse(StringIO(open(xmlfile).read()), handler)
|
parseXmlFile(xmlfile, handler)
|
||||||
|
|
||||||
handler = FingerprintHandler(banner, kb.bannerFp)
|
handler = FingerprintHandler(banner, kb.bannerFp)
|
||||||
parse(StringIO(open(paths.GENERIC_XML).read()), handler)
|
parseXmlFile(paths.GENERIC_XML, handler)
|
||||||
else:
|
else:
|
||||||
handler = FingerprintHandler(banner, kb.bannerFp)
|
handler = FingerprintHandler(banner, kb.bannerFp)
|
||||||
parse(StringIO(open(xmlfile).read()), handler)
|
parseXmlFile(xmlfile, handler)
|
||||||
parse(StringIO(open(paths.GENERIC_XML).read()), handler)
|
parseXmlFile(paths.GENERIC_XML, handler)
|
||||||
|
|
|
@ -24,10 +24,8 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from StringIO import StringIO
|
|
||||||
from xml.sax import parse
|
|
||||||
|
|
||||||
from lib.core.common import checkFile
|
from lib.core.common import checkFile
|
||||||
|
from lib.core.common import parseXmlFile
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import paths
|
from lib.core.data import paths
|
||||||
from lib.parse.handler import FingerprintHandler
|
from lib.parse.handler import FingerprintHandler
|
||||||
|
@ -64,5 +62,5 @@ def headersParser(headers):
|
||||||
|
|
||||||
handler = FingerprintHandler(value, kb.headersFp)
|
handler = FingerprintHandler(value, kb.headersFp)
|
||||||
|
|
||||||
parse(StringIO(open(xmlfile).read()), handler)
|
parseXmlFile(xmlfile, handler)
|
||||||
parse(StringIO(open(paths.GENERIC_XML).read()), handler)
|
parseXmlFile(paths.GENERIC_XML, handler)
|
||||||
|
|
|
@ -24,11 +24,10 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from StringIO import StringIO
|
|
||||||
from xml.sax import parse
|
|
||||||
from xml.sax.handler import ContentHandler
|
from xml.sax.handler import ContentHandler
|
||||||
|
|
||||||
from lib.core.common import checkFile
|
from lib.core.common import checkFile
|
||||||
|
from lib.core.common import parseXmlFile
|
||||||
from lib.core.common import sanitizeStr
|
from lib.core.common import sanitizeStr
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import paths
|
from lib.core.data import paths
|
||||||
|
@ -69,7 +68,7 @@ def htmlParser(page):
|
||||||
checkFile(xmlfile)
|
checkFile(xmlfile)
|
||||||
page = sanitizeStr(page)
|
page = sanitizeStr(page)
|
||||||
handler = htmlHandler(page)
|
handler = htmlHandler(page)
|
||||||
parse(StringIO(open(xmlfile).read()), handler)
|
parseXmlFile(xmlfile, handler)
|
||||||
|
|
||||||
if handler.dbms and handler.dbms not in kb.htmlFp:
|
if handler.dbms and handler.dbms not in kb.htmlFp:
|
||||||
kb.htmlFp.append(handler.dbms)
|
kb.htmlFp.append(handler.dbms)
|
||||||
|
|
|
@ -22,11 +22,10 @@ with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
||||||
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from StringIO import StringIO
|
|
||||||
from xml.sax import parse
|
|
||||||
from xml.sax.handler import ContentHandler
|
from xml.sax.handler import ContentHandler
|
||||||
|
|
||||||
from lib.core.common import checkFile
|
from lib.core.common import checkFile
|
||||||
|
from lib.core.common import parseXmlFile
|
||||||
from lib.core.common import sanitizeStr
|
from lib.core.common import sanitizeStr
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
from lib.core.data import queries
|
from lib.core.data import queries
|
||||||
|
@ -235,4 +234,4 @@ def queriesParser():
|
||||||
|
|
||||||
checkFile(xmlfile)
|
checkFile(xmlfile)
|
||||||
handler = queriesHandler()
|
handler = queriesHandler()
|
||||||
parse(StringIO(open(xmlfile).read()), handler)
|
parseXmlFile(xmlfile, handler)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user