/sqlmap-0.6.3/lib/controller/handler.py

https://github.com/tuwid/darkc0de-old-stuff · Python · 71 lines · 32 code · 13 blank · 26 comment · 6 complexity · 9cf0a222eaf880b77eb154677c55b273 MD5 · raw file

  1. #!/usr/bin/env python
  2. """
  3. $Id: handler.py 186 2008-11-15 23:41:31Z inquisb $
  4. This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
  5. Copyright (c) 2006-2008 Bernardo Damele A. G. <bernardo.damele@gmail.com>
  6. and Daniele Bellucci <daniele.bellucci@gmail.com>
  7. sqlmap is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation version 2 of the License.
  10. sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  13. details.
  14. You should have received a copy of the GNU General Public License along
  15. with sqlmap; if not, write to the Free Software Foundation, Inc., 51
  16. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. """
  18. from lib.core.data import conf
  19. from lib.core.data import kb
  20. from lib.core.data import logger
  21. from lib.core.settings import MSSQL_ALIASES
  22. from lib.core.settings import MYSQL_ALIASES
  23. from lib.core.settings import ORACLE_ALIASES
  24. from lib.core.settings import PGSQL_ALIASES
  25. from plugins.dbms.mssqlserver import MSSQLServerMap
  26. from plugins.dbms.mysql import MySQLMap
  27. from plugins.dbms.oracle import OracleMap
  28. from plugins.dbms.postgresql import PostgreSQLMap
  29. def setHandler():
  30. """
  31. Detect which is the target web application back-end database
  32. management system.
  33. """
  34. count = 0
  35. dbmsNames = ( "MySQL", "Oracle", "PostgreSQL", "Microsoft SQL Server" )
  36. dbmsMap = (
  37. ( MYSQL_ALIASES, MySQLMap ),
  38. ( ORACLE_ALIASES, OracleMap ),
  39. ( PGSQL_ALIASES, PostgreSQLMap ),
  40. ( MSSQL_ALIASES, MSSQLServerMap ),
  41. )
  42. for dbmsAliases, dbmsEntry in dbmsMap:
  43. if conf.dbms and conf.dbms not in dbmsAliases:
  44. debugMsg = "skipping test for %s" % dbmsNames[count]
  45. logger.debug(debugMsg)
  46. count += 1
  47. continue
  48. dbmsHandler = dbmsEntry()
  49. if dbmsHandler.checkDbms():
  50. if not conf.dbms or conf.dbms in dbmsAliases:
  51. kb.dbmsDetected = True
  52. return dbmsHandler
  53. return None