2019-05-08 12:47:52 +02:00
|
|
|
#!/usr/bin/env python
|
2010-09-15 12:59:51 +00:00
|
|
|
|
|
|
|
|
"""
|
2026-01-01 19:12:07 +01:00
|
|
|
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
|
2017-10-11 14:50:46 +02:00
|
|
|
See the file 'LICENSE' for copying permission
|
2010-09-15 12:59:51 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import cProfile
|
2019-06-04 14:48:51 +02:00
|
|
|
import os
|
2010-09-15 12:59:51 +00:00
|
|
|
|
|
|
|
|
from lib.core.data import logger
|
|
|
|
|
from lib.core.data import paths
|
|
|
|
|
|
2021-01-07 13:52:38 +01:00
|
|
|
def profile(profileOutputFile=None):
|
2010-09-15 13:28:56 +00:00
|
|
|
"""
|
|
|
|
|
This will run the program and present profiling data in a nice looking graph
|
|
|
|
|
"""
|
2011-06-08 15:31:27 +00:00
|
|
|
|
2010-09-15 12:59:51 +00:00
|
|
|
if profileOutputFile is None:
|
|
|
|
|
profileOutputFile = os.path.join(paths.SQLMAP_OUTPUT_PATH, "sqlmap_profile.raw")
|
|
|
|
|
|
|
|
|
|
if os.path.exists(profileOutputFile):
|
|
|
|
|
os.remove(profileOutputFile)
|
|
|
|
|
|
|
|
|
|
# Start sqlmap main function and generate a raw profile file
|
|
|
|
|
cProfile.run("start()", profileOutputFile)
|
|
|
|
|
|
2021-01-07 13:52:38 +01:00
|
|
|
infoMsg = "execution profiled and stored into file '%s' (e.g. 'gprof2dot -f pstats %s | dot -Tpng -o /tmp/sqlmap_profile.png')" % (profileOutputFile, profileOutputFile)
|
2010-09-15 12:59:51 +00:00
|
|
|
logger.info(infoMsg)
|