sqlmap/lib/core/profiling.py

30 lines
885 B
Python
Raw Normal View History

2019-05-08 13:47:52 +03:00
#!/usr/bin/env python
2010-09-15 16:59:51 +04:00
"""
2023-01-03 01:24:59 +03:00
Copyright (c) 2006-2023 sqlmap developers (https://sqlmap.org/)
2017-10-11 15:50:46 +03:00
See the file 'LICENSE' for copying permission
2010-09-15 16:59:51 +04:00
"""
import cProfile
2019-06-04 15:48:51 +03:00
import os
2010-09-15 16:59:51 +04:00
from lib.core.data import logger
from lib.core.data import paths
2021-01-07 15:52:38 +03:00
def profile(profileOutputFile=None):
2010-09-15 17:28:56 +04:00
"""
This will run the program and present profiling data in a nice looking graph
"""
2011-06-08 19:31:27 +04:00
2010-09-15 16:59:51 +04: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 15:52:38 +03: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 16:59:51 +04:00
logger.info(infoMsg)