forked from sqlmapproject/sqlmap
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlmapapi.py
More file actions
Latest commit
executable file
·74 lines (59 loc) · 2.72 KB
/
Copy pathsqlmapapi.py
File metadata and controls
executable file
·74 lines (59 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
"""
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""
importsys
sys.dont_write_bytecode=True
__import__("lib.utils.versioncheck") # this has to be the first non-standard import
importlogging
importoptparse
importos
importwarnings
warnings.filterwarnings(action="ignore", category=UserWarning)
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
fromlib.core.commonimportgetUnicode
fromlib.core.commonimportsetPaths
fromlib.core.dataimportlogger
fromlib.core.patchimportdirtyPatches
fromlib.core.patchimportresolveCrossReferences
fromlib.core.settingsimportRESTAPI_DEFAULT_ADAPTER
fromlib.core.settingsimportRESTAPI_DEFAULT_ADDRESS
fromlib.core.settingsimportRESTAPI_DEFAULT_PORT
fromlib.core.settingsimportUNICODE_ENCODING
fromlib.utils.apiimportclient
fromlib.utils.apiimportserver
try:
fromsqlmapimportmodulePath
exceptImportError:
defmodulePath():
returngetUnicode(os.path.dirname(os.path.realpath(__file__)), encoding=sys.getfilesystemencoding() orUNICODE_ENCODING)
defmain():
"""
REST-JSON API main function
"""
dirtyPatches()
resolveCrossReferences()
# Set default logging level to debug
logger.setLevel(logging.DEBUG)
# Initialize paths
setPaths(modulePath())
# Parse command line options
apiparser=optparse.OptionParser()
apiparser.add_option("-s", "--server", help="Run as a REST-JSON API server", action="store_true")
apiparser.add_option("-c", "--client", help="Run as a REST-JSON API client", action="store_true")
apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server (default \"%s\")"%RESTAPI_DEFAULT_ADDRESS, default=RESTAPI_DEFAULT_ADDRESS, action="store")
apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server (default %d)"%RESTAPI_DEFAULT_PORT, default=RESTAPI_DEFAULT_PORT, type="int", action="store")
apiparser.add_option("--adapter", help="Server (bottle) adapter to use (default \"%s\")"%RESTAPI_DEFAULT_ADAPTER, default=RESTAPI_DEFAULT_ADAPTER, action="store")
apiparser.add_option("--username", help="Basic authentication username (optional)", action="store")
apiparser.add_option("--password", help="Basic authentication password (optional)", action="store")
(args, _) =apiparser.parse_args()
# Start the client or the server
ifargs.server:
server(args.host, args.port, adapter=args.adapter, username=args.username, password=args.password)
elifargs.client:
client(args.host, args.port, username=args.username, password=args.password)
else:
apiparser.print_help()
if__name__=="__main__":
main()