From d55a24290888166ae55800c7b295c51778ed34e0 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 14 Jun 2011 19:38:35 +0000 Subject: [PATCH] minor improvement. messages are now warnings (not errors because lots of them are not causing problems for a normal usage) and most of all it's being checked only if the --dependencies is used (until now this switch has been ignored and turned on by default - always) --- lib/core/option.py | 10 ++++++++- lib/parse/cmdline.py | 2 +- lib/utils/deps.py | 52 ++++++++++++++++++++++---------------------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 91ac79867..583d76a2d 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1212,6 +1212,14 @@ def __setHTTPTimeout(): socket.setdefaulttimeout(conf.timeout) +def __checkDependencies(): + """ + Checks for missing dependencies. + """ + + if conf.dependencies: + checkDependencies() + def __cleanupOptions(): """ Cleanup configuration attributes. @@ -1744,7 +1752,7 @@ def init(inputOptions=advancedDict(), overrideOptions=False): __saveCmdline() __setRequestFromFile() __cleanupOptions() - checkDependencies() + __checkDependencies() __basicOptionValidation() __setTorProxySettings() __setMultipleTargets() diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 01de972e3..8362e0b22 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -539,7 +539,7 @@ def cmdLineParser(): miscellaneous.add_option("--dependencies", dest="dependencies", action="store_true", default=False, - help="Show which sqlmap dependencies are not available") + help="Check for missing sqlmap dependencies") # Hidden and/or experimental options parser.add_option("--profile", dest="profile", action="store_true", diff --git a/lib/utils/deps.py b/lib/utils/deps.py index 79174ab5f..8862a3228 100644 --- a/lib/utils/deps.py +++ b/lib/utils/deps.py @@ -27,10 +27,10 @@ def checkDependencies(): import pymssql if not hasattr(pymssql, "__version__") or pymssql.__version__ < "1.0.2": - debugMsg = "'%s' third-party library must be " % data[1] - debugMsg += "version >= 1.0.2 to work properly. " - debugMsg += "Download from %s" % data[2] - logger.debug(debugMsg) + warnMsg = "'%s' third-party library must be " % data[1] + warnMsg += "version >= 1.0.2 to work properly. " + warnMsg += "Download from %s" % data[2] + logger.warn(warnMsg) elif dbmsName == DBMS.MYSQL: import MySQLdb elif dbmsName == DBMS.PGSQL: @@ -44,10 +44,10 @@ def checkDependencies(): elif dbmsName == DBMS.FIREBIRD: import kinterbasdb except ImportError, _: - debugMsg = "sqlmap requires '%s' third-party library " % data[1] - debugMsg += "in order to directly connect to the database " - debugMsg += "%s. Download from %s" % (dbmsName, data[2]) - logger.debug(debugMsg) + warnMsg = "sqlmap requires '%s' third-party library " % data[1] + warnMsg += "in order to directly connect to the database " + warnMsg += "%s. Download from %s" % (dbmsName, data[2]) + logger.warn(warnMsg) missing_libraries.add(data[1]) continue @@ -60,10 +60,10 @@ def checkDependencies(): debugMsg = "'python-impacket' third-party library is found" logger.debug(debugMsg) except ImportError, _: - debugMsg = "sqlmap requires 'python-impacket' third-party library for " - debugMsg += "out-of-band takeover feature. Download from " - debugMsg += "http://code.google.com/p/impacket/" - logger.debug(debugMsg) + warnMsg = "sqlmap requires 'python-impacket' third-party library for " + warnMsg += "out-of-band takeover feature. Download from " + warnMsg += "http://code.google.com/p/impacket/" + logger.warn(warnMsg) missing_libraries.add('python-impacket') try: @@ -71,10 +71,10 @@ def checkDependencies(): debugMsg = "'python-ntlm' third-party library is found" logger.debug(debugMsg) except ImportError, _: - debugMsg = "sqlmap requires 'python-ntlm' third-party library for " - debugMsg += "if you plan to attack a web application behind NTLM " - debugMsg += "authentication. Download from http://code.google.com/p/python-ntlm/" - logger.debug(debugMsg) + warnMsg = "sqlmap requires 'python-ntlm' third-party library for " + warnMsg += "if you plan to attack a web application behind NTLM " + warnMsg += "authentication. Download from http://code.google.com/p/python-ntlm/" + logger.warn(warnMsg) missing_libraries.add('python-ntlm') try: @@ -82,10 +82,10 @@ def checkDependencies(): debugMsg = "'python-svn' third-party library is found" logger.debug(debugMsg) except ImportError, _: - debugMsg = "sqlmap requires 'python-svn' third-party library for " - debugMsg += "if you want to use the sqlmap update functionality. " - debugMsg += "Download from http://pysvn.tigris.org/" - logger.debug(debugMsg) + warnMsg = "sqlmap requires 'python-svn' third-party library for " + warnMsg += "if you want to use the sqlmap update functionality. " + warnMsg += "Download from http://pysvn.tigris.org/" + logger.warn(warnMsg) missing_libraries.add('python-svn') if IS_WIN: @@ -94,12 +94,12 @@ def checkDependencies(): debugMsg = "'python-pyreadline' third-party library is found" logger.debug(debugMsg) except ImportError, _: - debugMsg = "sqlmap requires 'pyreadline' third-party library to " - debugMsg += "be able to take advantage of the sqlmap TAB " - debugMsg += "completion and history support features in the SQL " - debugMsg += "shell and OS shell. Download from " - debugMsg += "http://ipython.scipy.org/moin/PyReadline/Intro" - logger.debug(debugMsg) + warnMsg = "sqlmap requires 'pyreadline' third-party library to " + 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 " + warnMsg += "http://ipython.scipy.org/moin/PyReadline/Intro" + logger.warn(warnMsg) missing_libraries.add('python-pyreadline') if len(missing_libraries) == 0: