Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/lib/core/profiling.py
2989 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
import cProfile
9
import os
10
11
from lib.core.data import logger
12
from lib.core.data import paths
13
14
def profile(profileOutputFile=None):
15
"""
16
This will run the program and present profiling data in a nice looking graph
17
"""
18
19
if profileOutputFile is None:
20
profileOutputFile = os.path.join(paths.SQLMAP_OUTPUT_PATH, "sqlmap_profile.raw")
21
22
if os.path.exists(profileOutputFile):
23
os.remove(profileOutputFile)
24
25
# Start sqlmap main function and generate a raw profile file
26
cProfile.run("start()", profileOutputFile)
27
28
infoMsg = "execution profiled and stored into file '%s' (e.g. 'gprof2dot -f pstats %s | dot -Tpng -o /tmp/sqlmap_profile.png')" % (profileOutputFile, profileOutputFile)
29
logger.info(infoMsg)
30
31