FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmap/sqlmapapi.py at master · sqlmapproject/sqlmap · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
sqlmapproject
/
sqlmap
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
6.3k
Star
38.3k
Code
Issues
25
Pull requests
7
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlmap
/
sqlmapapi.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
120 lines (93 loc) · 4.26 KB
Breadcrumbs
sqlmap
/
sqlmapapi.py
Copy path
File metadata and controls
executable file
·
120 lines (93 loc) · 4.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import
sys
sys
.
dont_write_bytecode
=
True
__import__
(
"lib.utils.versioncheck"
)
# this has to be the first non-standard import
import
logging
import
os
import
warnings
warnings
.
filterwarnings
(
action
=
"ignore"
,
category
=
UserWarning
)
warnings
.
filterwarnings
(
action
=
"ignore"
,
category
=
DeprecationWarning
)
try
:
from
optparse
import
OptionGroup
from
optparse
import
OptionParser
as
ArgumentParser
ArgumentParser
.
add_argument
=
ArgumentParser
.
add_option
def
_add_argument
(
self
,
*
args
,
**
kwargs
):
return
self
.
add_option
(
*
args
,
**
kwargs
)
OptionGroup
.
add_argument
=
_add_argument
except
ImportError
:
from
argparse
import
ArgumentParser
finally
:
def
get_actions
(
instance
):
for
attr
in
(
"option_list"
,
"_group_actions"
,
"_actions"
):
if
hasattr
(
instance
,
attr
):
return
getattr
(
instance
,
attr
)
def
get_groups
(
parser
):
return
getattr
(
parser
,
"option_groups"
,
None
)
or
getattr
(
parser
,
"_action_groups"
)
def
get_all_options
(
parser
):
retVal
=
set
()
for
option
in
get_actions
(
parser
):
if
hasattr
(
option
,
"option_strings"
):
retVal
.
update
(
option
.
option_strings
)
else
:
retVal
.
update
(
option
.
_long_opts
)
retVal
.
update
(
option
.
_short_opts
)
for
group
in
get_groups
(
parser
):
for
option
in
get_actions
(
group
):
if
hasattr
(
option
,
"option_strings"
):
retVal
.
update
(
option
.
option_strings
)
else
:
retVal
.
update
(
option
.
_long_opts
)
retVal
.
update
(
option
.
_short_opts
)
return
retVal
from
lib
.
core
.
common
import
getUnicode
from
lib
.
core
.
common
import
setPaths
from
lib
.
core
.
data
import
logger
from
lib
.
core
.
patch
import
dirtyPatches
from
lib
.
core
.
patch
import
resolveCrossReferences
from
lib
.
core
.
settings
import
RESTAPI_DEFAULT_ADAPTER
from
lib
.
core
.
settings
import
RESTAPI_DEFAULT_ADDRESS
from
lib
.
core
.
settings
import
RESTAPI_DEFAULT_PORT
from
lib
.
core
.
settings
import
UNICODE_ENCODING
from
lib
.
utils
.
api
import
client
from
lib
.
utils
.
api
import
server
try
:
from
sqlmap
import
modulePath
except
ImportError
:
def
modulePath
():
return
getUnicode
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
encoding
=
sys
.
getfilesystemencoding
()
or
UNICODE_ENCODING
)
def
main
():
"""
REST API main function
"""
dirtyPatches
()
resolveCrossReferences
()
# Set default logging level to debug
logger
.
setLevel
(
logging
.
DEBUG
)
# Initialize paths
setPaths
(
modulePath
())
# Parse command line options
apiparser
=
ArgumentParser
()
apiparser
.
add_argument
(
"-s"
,
"--server"
,
help
=
"Run as a REST API server"
,
action
=
"store_true"
)
apiparser
.
add_argument
(
"-c"
,
"--client"
,
help
=
"Run as a REST API client"
,
action
=
"store_true"
)
apiparser
.
add_argument
(
"-H"
,
"--host"
,
help
=
"Host of the REST API server (default
\"
%s
\"
)"
%
RESTAPI_DEFAULT_ADDRESS
,
default
=
RESTAPI_DEFAULT_ADDRESS
)
apiparser
.
add_argument
(
"-p"
,
"--port"
,
help
=
"Port of the REST API server (default %d)"
%
RESTAPI_DEFAULT_PORT
,
default
=
RESTAPI_DEFAULT_PORT
,
type
=
int
)
apiparser
.
add_argument
(
"--adapter"
,
help
=
"Server (bottle) adapter to use (default
\"
%s
\"
)"
%
RESTAPI_DEFAULT_ADAPTER
,
default
=
RESTAPI_DEFAULT_ADAPTER
)
apiparser
.
add_argument
(
"--database"
,
help
=
"Set IPC database filepath (optional)"
)
apiparser
.
add_argument
(
"--username"
,
help
=
"Basic authentication username"
)
apiparser
.
add_argument
(
"--password"
,
help
=
"Basic authentication password"
)
(
args
,
_
)
=
apiparser
.
parse_known_args
()
if
hasattr
(
apiparser
,
"parse_known_args"
)
else
apiparser
.
parse_args
()
if
(
args
.
server
or
args
.
client
)
and
not
all
((
args
.
username
,
args
.
password
)):
apiparser
.
error
(
"--username and --password are mandatory for REST API server/client usage"
)
# Start the client or the server
if
args
.
server
:
server
(
args
.
host
,
args
.
port
,
adapter
=
args
.
adapter
,
username
=
args
.
username
,
password
=
args
.
password
,
database
=
args
.
database
)
elif
args
.
client
:
client
(
args
.
host
,
args
.
port
,
username
=
args
.
username
,
password
=
args
.
password
)
else
:
apiparser
.
print_help
()
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL