2019-05-08 13:47:52 +03:00
|
|
|
#!/usr/bin/env python
|
2011-06-13 22:44:02 +04:00
|
|
|
|
|
|
|
"""
|
2020-01-01 15:25:15 +03:00
|
|
|
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2011-06-13 22:44:02 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
from lib.core.data import logger
|
2012-08-21 13:19:15 +04:00
|
|
|
from lib.core.dicts import DBMS_DICT
|
2011-06-13 22:44:02 +04:00
|
|
|
from lib.core.enums import DBMS
|
|
|
|
from lib.core.settings import IS_WIN
|
|
|
|
|
2011-06-13 23:00:27 +04:00
|
|
|
def checkDependencies():
|
2011-06-13 22:44:02 +04:00
|
|
|
missing_libraries = set()
|
|
|
|
|
|
|
|
for dbmsName, data in DBMS_DICT.items():
|
|
|
|
if data[1] is None:
|
|
|
|
continue
|
|
|
|
|
|
|
|
try:
|
|
|
|
if dbmsName in (DBMS.MSSQL, DBMS.SYBASE):
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("_mssql")
|
2011-06-13 22:44:02 +04:00
|
|
|
|
2019-06-01 14:42:57 +03:00
|
|
|
pymssql = __import__("pymssql")
|
2011-06-13 22:44:02 +04:00
|
|
|
if not hasattr(pymssql, "__version__") or pymssql.__version__ < "1.0.2":
|
2011-06-14 23:38:35 +04:00
|
|
|
warnMsg = "'%s' third-party library must be " % data[1]
|
|
|
|
warnMsg += "version >= 1.0.2 to work properly. "
|
2018-02-14 01:10:53 +03:00
|
|
|
warnMsg += "Download from '%s'" % data[2]
|
2011-06-14 23:38:35 +04:00
|
|
|
logger.warn(warnMsg)
|
2011-06-13 22:44:02 +04:00
|
|
|
elif dbmsName == DBMS.MYSQL:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("pymysql")
|
2011-06-13 22:44:02 +04:00
|
|
|
elif dbmsName == DBMS.PGSQL:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("psycopg2")
|
2011-06-13 22:44:02 +04:00
|
|
|
elif dbmsName == DBMS.ORACLE:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("cx_Oracle")
|
2011-06-13 22:44:02 +04:00
|
|
|
elif dbmsName == DBMS.SQLITE:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("sqlite3")
|
2011-06-13 22:44:02 +04:00
|
|
|
elif dbmsName == DBMS.ACCESS:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("pyodbc")
|
2011-06-13 22:44:02 +04:00
|
|
|
elif dbmsName == DBMS.FIREBIRD:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("kinterbasdb")
|
2013-01-17 18:20:34 +04:00
|
|
|
elif dbmsName == DBMS.DB2:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("ibm_db_dbi")
|
2013-07-01 14:50:03 +04:00
|
|
|
elif dbmsName == DBMS.HSQLDB:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("jaydebeapi")
|
|
|
|
__import__("jpype")
|
2016-09-23 13:33:27 +03:00
|
|
|
elif dbmsName == DBMS.INFORMIX:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("ibm_db_dbi")
|
2020-01-17 19:14:41 +03:00
|
|
|
elif dbmsName == DBMS.MONETDB:
|
|
|
|
__import__("pymonetdb")
|
2020-01-20 17:33:45 +03:00
|
|
|
elif dbmsName == DBMS.DERBY:
|
|
|
|
__import__("drda")
|
2020-01-21 17:40:59 +03:00
|
|
|
elif dbmsName == DBMS.VERTICA:
|
|
|
|
__import__("vertica_python")
|
2017-10-20 11:00:26 +03:00
|
|
|
except:
|
2012-10-30 14:54:21 +04:00
|
|
|
warnMsg = "sqlmap requires '%s' third-party library " % data[1]
|
2014-12-05 13:15:33 +03:00
|
|
|
warnMsg += "in order to directly connect to the DBMS "
|
2018-02-14 01:10:53 +03:00
|
|
|
warnMsg += "'%s'. Download from '%s'" % (dbmsName, data[2])
|
2011-06-14 23:38:35 +04:00
|
|
|
logger.warn(warnMsg)
|
2011-06-13 22:44:02 +04:00
|
|
|
missing_libraries.add(data[1])
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
debugMsg = "'%s' third-party library is found" % data[1]
|
|
|
|
logger.debug(debugMsg)
|
|
|
|
|
|
|
|
try:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("impacket")
|
2011-06-13 22:44:02 +04:00
|
|
|
debugMsg = "'python-impacket' third-party library is found"
|
|
|
|
logger.debug(debugMsg)
|
2012-12-06 13:21:53 +04:00
|
|
|
except ImportError:
|
2012-10-30 14:54:21 +04:00
|
|
|
warnMsg = "sqlmap requires 'python-impacket' third-party library for "
|
2011-06-14 23:38:35 +04:00
|
|
|
warnMsg += "out-of-band takeover feature. Download from "
|
2018-08-28 15:13:48 +03:00
|
|
|
warnMsg += "'https://github.com/coresecurity/impacket'"
|
2011-06-14 23:38:35 +04:00
|
|
|
logger.warn(warnMsg)
|
2011-06-13 22:44:02 +04:00
|
|
|
missing_libraries.add('python-impacket')
|
|
|
|
|
|
|
|
try:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("ntlm")
|
2011-06-13 22:44:02 +04:00
|
|
|
debugMsg = "'python-ntlm' third-party library is found"
|
|
|
|
logger.debug(debugMsg)
|
2012-12-06 13:21:53 +04:00
|
|
|
except ImportError:
|
2015-05-11 12:01:21 +03:00
|
|
|
warnMsg = "sqlmap requires 'python-ntlm' third-party library "
|
2011-06-14 23:38:35 +04:00
|
|
|
warnMsg += "if you plan to attack a web application behind NTLM "
|
2018-08-28 15:13:48 +03:00
|
|
|
warnMsg += "authentication. Download from 'https://github.com/mullender/python-ntlm'"
|
2011-06-14 23:38:35 +04:00
|
|
|
logger.warn(warnMsg)
|
2011-06-13 22:44:02 +04:00
|
|
|
missing_libraries.add('python-ntlm')
|
|
|
|
|
2015-03-24 17:25:16 +03:00
|
|
|
try:
|
2019-11-28 15:41:02 +03:00
|
|
|
__import__("websocket._abnf")
|
2019-11-21 16:55:05 +03:00
|
|
|
debugMsg = "'websocket-client' library is found"
|
2015-03-24 17:25:16 +03:00
|
|
|
logger.debug(debugMsg)
|
|
|
|
except ImportError:
|
2015-05-11 12:01:21 +03:00
|
|
|
warnMsg = "sqlmap requires 'websocket-client' third-party library "
|
|
|
|
warnMsg += "if you plan to attack a web application using WebSocket. "
|
2018-02-14 01:10:53 +03:00
|
|
|
warnMsg += "Download from 'https://pypi.python.org/pypi/websocket-client/'"
|
2015-03-24 17:25:16 +03:00
|
|
|
logger.warn(warnMsg)
|
|
|
|
missing_libraries.add('websocket-client')
|
|
|
|
|
2019-11-21 16:55:05 +03:00
|
|
|
try:
|
|
|
|
__import__("tkinter")
|
|
|
|
debugMsg = "'tkinter' library is found"
|
|
|
|
logger.debug(debugMsg)
|
|
|
|
except ImportError:
|
|
|
|
warnMsg = "sqlmap requires 'tkinter' library "
|
|
|
|
warnMsg += "if you plan to run a GUI"
|
|
|
|
logger.warn(warnMsg)
|
|
|
|
missing_libraries.add('tkinter')
|
|
|
|
|
|
|
|
try:
|
|
|
|
__import__("tkinter.ttk")
|
|
|
|
debugMsg = "'tkinter.ttk' library is found"
|
|
|
|
logger.debug(debugMsg)
|
|
|
|
except ImportError:
|
|
|
|
warnMsg = "sqlmap requires 'tkinter.ttk' library "
|
|
|
|
warnMsg += "if you plan to run a GUI"
|
|
|
|
logger.warn(warnMsg)
|
|
|
|
missing_libraries.add('tkinter.ttk')
|
|
|
|
|
2011-06-13 22:44:02 +04:00
|
|
|
if IS_WIN:
|
|
|
|
try:
|
2016-12-20 01:47:39 +03:00
|
|
|
__import__("pyreadline")
|
2011-06-13 22:44:02 +04:00
|
|
|
debugMsg = "'python-pyreadline' third-party library is found"
|
|
|
|
logger.debug(debugMsg)
|
2012-12-06 13:21:53 +04:00
|
|
|
except ImportError:
|
2012-10-30 14:54:21 +04:00
|
|
|
warnMsg = "sqlmap requires 'pyreadline' third-party library to "
|
2011-06-14 23:38:35 +04:00
|
|
|
warnMsg += "be able to take advantage of the sqlmap TAB "
|
|
|
|
warnMsg += "completion and history support features in the SQL "
|
|
|
|
warnMsg += "shell and OS shell. Download from "
|
2018-08-28 15:13:48 +03:00
|
|
|
warnMsg += "'https://pypi.org/project/pyreadline/'"
|
2011-06-14 23:38:35 +04:00
|
|
|
logger.warn(warnMsg)
|
2011-06-13 22:44:02 +04:00
|
|
|
missing_libraries.add('python-pyreadline')
|
|
|
|
|
|
|
|
if len(missing_libraries) == 0:
|
2011-06-13 23:00:27 +04:00
|
|
|
infoMsg = "all dependencies are installed"
|
2012-12-06 14:15:05 +04:00
|
|
|
logger.info(infoMsg)
|