Skip to content

Commit ebd2a94

Browse files
committed
Patching profile capabilities
1 parent 0d38897 commit ebd2a94

File tree

9 files changed

+4
-5169
lines changed

9 files changed

+4
-5169
lines changed

doc/THANKS.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ Giorgio Fedon, <giorgio.fedon(at)gmail.com>
151151
Kasper Fons, <thefeds(at)mail.dk>
152152
* for reporting several bugs
153153

154-
Jose Fonseca, <jose.r.fonseca(at)gmail.com>
155-
* for his Gprof2Dot utility for converting profiler output to dot graph(s) and for his XDot utility to render nicely dot graph(s), both included in sqlmap tree inside extra folder. These libraries are used for sqlmap development purposes only
156-
http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
157-
http://code.google.com/p/jrfonseca/wiki/XDot
158-
159154
Alan Franzoni, <alan.franzoni(at)gmail.com>
160155
* for helping out with Python subprocess library
161156

doc/THIRD-PARTY.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4848

4949
* The `Chardet` library located under `thirdparty/chardet/`.
5050
Copyright (C) 2008, Mark Pilgrim.
51-
* The `Gprof2dot` library located under `thirdparty/gprof2dot/`.
52-
Copyright (C) 2008-2009, Jose Fonseca.
5351
* The `KeepAlive` library located under `thirdparty/keepalive/`.
5452
Copyright (C) 2002-2003, Michael D. Stenner.
5553
* The `MultipartPost` library located under `thirdparty/multipart/`.
5654
Copyright (C) 2006, Will Holcomb.
57-
* The `XDot` library located under `thirdparty/xdot/`
58-
Copyright (C) 2008, Jose Fonseca.
5955
* The `icmpsh` tool located under `extra/icmpsh/`.
6056
Copyright (C) 2010, Nico Leidecker, Bernardo Damele.
6157

lib/core/profiling.py

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,86 +14,19 @@
1414
from lib.core.data import paths
1515
from lib.core.settings import UNICODE_ENCODING
1616

17-
def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
17+
def profile(profileOutputFile=None):
1818
"""
1919
This will run the program and present profiling data in a nice looking graph
2020
"""
2121

22-
try:
23-
__import__("gobject")
24-
from thirdparty.gprof2dot import gprof2dot
25-
from thirdparty.xdot import xdot
26-
import gtk
27-
import pydot
28-
except ImportError as ex:
29-
errMsg = "profiling requires third-party libraries ('%s') " % getSafeExString(ex)
30-
errMsg += "(Hint: 'sudo apt install python-pydot python-pyparsing python-profiler graphviz')"
31-
logger.error(errMsg)
32-
33-
return
34-
3522
if profileOutputFile is None:
3623
profileOutputFile = os.path.join(paths.SQLMAP_OUTPUT_PATH, "sqlmap_profile.raw")
3724

38-
if dotOutputFile is None:
39-
dotOutputFile = os.path.join(paths.SQLMAP_OUTPUT_PATH, "sqlmap_profile.dot")
40-
41-
if imageOutputFile is None:
42-
imageOutputFile = os.path.join(paths.SQLMAP_OUTPUT_PATH, "sqlmap_profile.png")
43-
4425
if os.path.exists(profileOutputFile):
4526
os.remove(profileOutputFile)
4627

47-
if os.path.exists(dotOutputFile):
48-
os.remove(dotOutputFile)
49-
50-
if os.path.exists(imageOutputFile):
51-
os.remove(imageOutputFile)
52-
53-
infoMsg = "profiling the execution into file '%s'" % profileOutputFile
54-
logger.info(infoMsg)
55-
5628
# Start sqlmap main function and generate a raw profile file
5729
cProfile.run("start()", profileOutputFile)
5830

59-
infoMsg = "converting profile data into a dot file '%s'" % dotOutputFile
31+
infoMsg = "execution profiled and stored into file '%s' (e.g. 'gprof2dot -f pstats %s | dot -Tpng -o /tmp/sqlmap_profile.png')" % (profileOutputFile, profileOutputFile)
6032
logger.info(infoMsg)
61-
62-
# Create dot file by using extra/gprof2dot/gprof2dot.py
63-
# http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
64-
dotFilePointer = codecs.open(dotOutputFile, 'wt', UNICODE_ENCODING)
65-
parser = gprof2dot.PstatsParser(profileOutputFile)
66-
profile = parser.parse()
67-
profile.prune(0.5 / 100.0, 0.1 / 100.0)
68-
dot = gprof2dot.DotWriter(dotFilePointer)
69-
dot.graph(profile, gprof2dot.TEMPERATURE_COLORMAP)
70-
dotFilePointer.close()
71-
72-
infoMsg = "converting dot file into a graph image '%s'" % imageOutputFile
73-
logger.info(infoMsg)
74-
75-
# Create graph image (png) by using pydot (python-pydot)
76-
# http://code.google.com/p/pydot/
77-
pydotGraph = pydot.graph_from_dot_file(dotOutputFile)
78-
79-
# Reference: http://stackoverflow.com/questions/38176472/graph-write-pdfiris-pdf-attributeerror-list-object-has-no-attribute-writ
80-
if isinstance(pydotGraph, list):
81-
pydotGraph = pydotGraph[0]
82-
83-
try:
84-
pydotGraph.write_png(imageOutputFile)
85-
except OSError:
86-
errMsg = "profiling requires graphviz installed "
87-
errMsg += "(Hint: 'sudo apt install graphviz')"
88-
logger.error(errMsg)
89-
else:
90-
infoMsg = "displaying interactive graph with xdot library"
91-
logger.info(infoMsg)
92-
93-
# Display interactive Graphviz dot file by using extra/xdot/xdot.py
94-
# http://code.google.com/p/jrfonseca/wiki/XDot
95-
win = xdot.DotWindow()
96-
win.connect('destroy', gtk.main_quit)
97-
win.set_filter("dot")
98-
win.open_file(dotOutputFile)
99-
gtk.main()

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.5.1.14"
21+
VERSION = "1.5.1.15"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

sqlmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def main():
182182
fuzzTest()
183183
else:
184184
from lib.controller.controller import start
185-
if conf.profile and six.PY2:
185+
if conf.profile:
186186
from lib.core.profiling import profile
187187
globals()["start"] = start
188188
profile()

thirdparty/gprof2dot/__init__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)