Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 264e0a6

Browse files
committed
added support for displaying revision number at unhandled exception message
1 parent 9a7fd29 commit 264e0a6

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

lib/core/dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def dbColumns(self, dbColumns, colConsider, dbs):
431431
self.dbTableColumns(printDbs)
432432

433433
def query(self, query, queryRes):
434-
self.string(query, queryRes)
434+
self.string(query, queryRes)
435435

436436
def rFile(self,filePath,fileData):
437437
self.string("%s file saved to" % filePath,fileData,sort=False)

lib/core/exception.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from lib.core.settings import PLATFORM
1111
from lib.core.settings import PYVERSION
1212
from lib.core.settings import VERSION
13+
from lib.core.settings import REVISION
1314
from lib.core.settings import VERSION_STRING
1415

1516

@@ -75,7 +76,7 @@ def unhandledException():
7576
errMsg += "following text and any information needed to reproduce the "
7677
errMsg += "bug. The developers will try to reproduce the bug, fix it "
7778
errMsg += "accordingly and get back to you.\n"
78-
errMsg += "sqlmap version: %s\n" % VERSION
79+
errMsg += "sqlmap version: %s%s\n" % (VERSION, " (r%d)" % REVISION if REVISION else "")
7980
errMsg += "Python version: %s\n" % PYVERSION
8081
errMsg += "Operating system: %s" % PLATFORM
8182
return errMsg

lib/core/revision.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import os
2+
import re
3+
4+
from subprocess import PIPE
5+
from subprocess import Popen as execute
6+
7+
def getRevisionNumber():
8+
curDir = os.path.dirname(os.path.realpath(__file__))
9+
retVal = None
10+
11+
try:
12+
import pysvn
13+
14+
client = pysvn.Client()
15+
if client.info(curDir):
16+
retVal = client.info(curDir).revision.number
17+
18+
except ImportError, _:
19+
process = execute("svn info %s" % curDir, shell=True, stdout=PIPE, stderr=PIPE)
20+
21+
svnStdout, svnStderr = process.communicate()
22+
23+
if svnStdout:
24+
revision = re.search("Revision:\s+([\d]+)", svnStdout)
25+
26+
if revision:
27+
retVal = revision.group(1)
28+
29+
if retVal:
30+
try:
31+
retVal = int(retVal)
32+
except ValueError:
33+
retVal = None
34+
35+
#if not retVal:
36+
#debugMsg = "sqlmap was not able to retrieve the revision number"
37+
#logger.debug(debugMsg)
38+
39+
return retVal

lib/core/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
import subprocess
1313
import sys
1414

15+
from lib.core.revision import getRevisionNumber
16+
1517
# sqlmap version and site
1618
VERSION = "0.9-dev"
19+
REVISION = getRevisionNumber()
1720
VERSION_STRING = "sqlmap/%s" % VERSION
1821
DESCRIPTION = "automatic SQL injection and database takeover tool"
1922
SITE = "http://sqlmap.sourceforge.net"

0 commit comments

Comments
 (0)