diff --git a/lib/core/dump.py b/lib/core/dump.py index 8b3be65a3..dabe9f3a7 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -431,7 +431,7 @@ class Dump: self.dbTableColumns(printDbs) def query(self, query, queryRes): - self.string(query, queryRes) + self.string(query, queryRes) def rFile(self,filePath,fileData): self.string("%s file saved to" % filePath,fileData,sort=False) diff --git a/lib/core/exception.py b/lib/core/exception.py index 1d31d2df7..c6df89034 100644 --- a/lib/core/exception.py +++ b/lib/core/exception.py @@ -10,6 +10,7 @@ See the file 'doc/COPYING' for copying permission from lib.core.settings import PLATFORM from lib.core.settings import PYVERSION from lib.core.settings import VERSION +from lib.core.settings import REVISION from lib.core.settings import VERSION_STRING @@ -75,7 +76,7 @@ def unhandledException(): errMsg += "following text and any information needed to reproduce the " errMsg += "bug. The developers will try to reproduce the bug, fix it " errMsg += "accordingly and get back to you.\n" - errMsg += "sqlmap version: %s\n" % VERSION + errMsg += "sqlmap version: %s%s\n" % (VERSION, " (r%d)" % REVISION if REVISION else "") errMsg += "Python version: %s\n" % PYVERSION errMsg += "Operating system: %s" % PLATFORM return errMsg diff --git a/lib/core/revision.py b/lib/core/revision.py new file mode 100644 index 000000000..73259d567 --- /dev/null +++ b/lib/core/revision.py @@ -0,0 +1,39 @@ +import os +import re + +from subprocess import PIPE +from subprocess import Popen as execute + +def getRevisionNumber(): + curDir = os.path.dirname(os.path.realpath(__file__)) + retVal = None + + try: + import pysvn + + client = pysvn.Client() + if client.info(curDir): + retVal = client.info(curDir).revision.number + + except ImportError, _: + process = execute("svn info %s" % curDir, shell=True, stdout=PIPE, stderr=PIPE) + + svnStdout, svnStderr = process.communicate() + + if svnStdout: + revision = re.search("Revision:\s+([\d]+)", svnStdout) + + if revision: + retVal = revision.group(1) + + if retVal: + try: + retVal = int(retVal) + except ValueError: + retVal = None + + #if not retVal: + #debugMsg = "sqlmap was not able to retrieve the revision number" + #logger.debug(debugMsg) + + return retVal diff --git a/lib/core/settings.py b/lib/core/settings.py index 5ca3faeac..4164e6cce 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -12,8 +12,11 @@ import os import subprocess import sys +from lib.core.revision import getRevisionNumber + # sqlmap version and site VERSION = "0.9-dev" +REVISION = getRevisionNumber() VERSION_STRING = "sqlmap/%s" % VERSION DESCRIPTION = "automatic SQL injection and database takeover tool" SITE = "http://sqlmap.sourceforge.net"