FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmap/lib/utils/sqlalchemy.py at master · feixiang8418/sqlmap · GitHub
feixiang8418
/
sqlmap
Public
forked from
sqlmapproject/sqlmap
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlmap
/
lib
/
utils
/
sqlalchemy.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
86 lines (71 loc) · 2.92 KB
Breadcrumbs
sqlmap
/
lib
/
utils
/
sqlalchemy.py
Copy path
File metadata and controls
86 lines (71 loc) · 2.92 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
#!/usr/bin/env python
"""
Copyright (c) 2006-2014 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import
imp
import
logging
import
os
import
re
import
sys
import
warnings
_sqlalchemy
=
None
try
:
f
,
pathname
,
desc
=
imp
.
find_module
(
"sqlalchemy"
,
sys
.
path
[
1
:])
_
=
imp
.
load_module
(
"sqlalchemy"
,
f
,
pathname
,
desc
)
if
hasattr
(
_
,
"dialects"
):
_sqlalchemy
=
_
warnings
.
simplefilter
(
action
=
"ignore"
,
category
=
_sqlalchemy
.
exc
.
SAWarning
)
except
ImportError
:
pass
try
:
import
MySQLdb
# used by SQLAlchemy in case of MySQL
warnings
.
filterwarnings
(
"error"
,
category
=
MySQLdb
.
Warning
)
except
ImportError
:
pass
from
lib
.
core
.
data
import
conf
from
lib
.
core
.
data
import
logger
from
lib
.
core
.
exception
import
SqlmapConnectionException
from
lib
.
core
.
exception
import
SqlmapFilePathException
from
plugins
.
generic
.
connector
import
Connector
as
GenericConnector
class
SQLAlchemy
(
GenericConnector
):
def
__init__
(
self
,
dialect
=
None
):
GenericConnector
.
__init__
(
self
)
self
.
dialect
=
dialect
def
connect
(
self
):
if
_sqlalchemy
:
self
.
initConnection
()
try
:
if
not
self
.
port
and
self
.
db
:
if
not
os
.
path
.
exists
(
self
.
db
):
raise
SqlmapFilePathException
,
"the provided database file '%s' does not exist"
%
self
.
db
_
=
conf
.
direct
.
split
(
"//"
,
1
)
conf
.
direct
=
"%s////%s"
%
(
_
[
0
],
os
.
path
.
abspath
(
self
.
db
))
if
self
.
dialect
:
conf
.
direct
=
conf
.
direct
.
replace
(
conf
.
dbms
,
self
.
dialect
,
1
)
engine
=
_sqlalchemy
.
create_engine
(
conf
.
direct
,
connect_args
=
{
'check_same_thread'
:
False
}
if
self
.
dialect
==
"sqlite"
else
{})
self
.
connector
=
engine
.
connect
()
except
SqlmapFilePathException
:
raise
except
Exception
,
msg
:
raise
SqlmapConnectionException
(
"SQLAlchemy connection issue ('%s')"
%
msg
[
0
])
self
.
printConnected
()
def
fetchall
(
self
):
try
:
retVal
=
[]
for
row
in
self
.
cursor
.
fetchall
():
retVal
.
append
(
tuple
(
row
))
return
retVal
except
_sqlalchemy
.
exc
.
ProgrammingError
,
msg
:
logger
.
log
(
logging
.
WARN
if
conf
.
dbmsHandler
else
logging
.
DEBUG
,
"(remote) %s"
%
msg
.
message
if
hasattr
(
msg
,
"message"
)
else
msg
)
return
None
def
execute
(
self
,
query
):
try
:
self
.
cursor
=
self
.
connector
.
execute
(
query
)
except
(
_sqlalchemy
.
exc
.
OperationalError
,
_sqlalchemy
.
exc
.
ProgrammingError
),
msg
:
logger
.
log
(
logging
.
WARN
if
conf
.
dbmsHandler
else
logging
.
DEBUG
,
"(remote) %s"
%
msg
.
message
if
hasattr
(
msg
,
"message"
)
else
msg
)
except
_sqlalchemy
.
exc
.
InternalError
,
msg
:
raise
SqlmapConnectionException
(
msg
[
1
])
def
select
(
self
,
query
):
self
.
execute
(
query
)
return
self
.
fetchall
()
Back
|
FazBrowse Home
|
New Git URL