sqlmap/lib/core/dicts.py

240 lines
9.5 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2011-02-19 17:07:08 +03:00
"""
2016-01-06 02:06:12 +03:00
Copyright (c) 2006-2016 sqlmap developers (http://sqlmap.org/)
2011-02-19 17:07:08 +03:00
See the file 'doc/COPYING' for copying permission
"""
2012-08-21 13:19:15 +04:00
from lib.core.enums import DBMS
2013-02-25 13:44:04 +04:00
from lib.core.enums import OS
2012-10-04 13:25:44 +04:00
from lib.core.enums import POST_HINT
2012-08-21 13:19:15 +04:00
from lib.core.settings import BLANK
from lib.core.settings import NULL
from lib.core.settings import MSSQL_ALIASES
from lib.core.settings import MYSQL_ALIASES
from lib.core.settings import PGSQL_ALIASES
from lib.core.settings import ORACLE_ALIASES
from lib.core.settings import SQLITE_ALIASES
from lib.core.settings import ACCESS_ALIASES
from lib.core.settings import FIREBIRD_ALIASES
from lib.core.settings import MAXDB_ALIASES
from lib.core.settings import SYBASE_ALIASES
from lib.core.settings import DB2_ALIASES
from lib.core.settings import HSQLDB_ALIASES
2012-08-21 13:19:15 +04:00
2012-08-21 13:30:01 +04:00
FIREBIRD_TYPES = {
2016-01-15 00:51:26 +03:00
261: "BLOB",
14: "CHAR",
40: "CSTRING",
11: "D_FLOAT",
27: "DOUBLE",
10: "FLOAT",
16: "INT64",
8: "INTEGER",
9: "QUAD",
7: "SMALLINT",
12: "DATE",
13: "TIME",
35: "TIMESTAMP",
37: "VARCHAR",
2011-02-19 17:07:08 +03:00
}
2012-08-21 13:30:01 +04:00
SYBASE_TYPES = {
2016-01-15 00:47:56 +03:00
14: "floatn",
8: "float",
15: "datetimn",
12: "datetime",
23: "real",
28: "numericn",
10: "numeric",
27: "decimaln",
26: "decimal",
17: "moneyn",
11: "money",
21: "smallmoney",
22: "smalldatetime",
13: "intn",
7: "int",
6: "smallint",
5: "tinyint",
16: "bit",
2: "varchar",
18: "sysname",
25: "nvarchar",
1: "char",
24: "nchar",
4: "varbinary",
80: "timestamp",
3: "binary",
19: "text",
20: "image",
2011-02-19 17:07:08 +03:00
}
2011-03-09 14:37:37 +03:00
2012-08-21 13:30:01 +04:00
MYSQL_PRIVS = {
2013-01-10 16:18:44 +04:00
1: "select_priv",
2: "insert_priv",
3: "update_priv",
4: "delete_priv",
5: "create_priv",
6: "drop_priv",
7: "reload_priv",
8: "shutdown_priv",
9: "process_priv",
10: "file_priv",
11: "grant_priv",
12: "references_priv",
13: "index_priv",
14: "alter_priv",
15: "show_db_priv",
16: "super_priv",
17: "create_tmp_table_priv",
18: "lock_tables_priv",
19: "execute_priv",
20: "repl_slave_priv",
21: "repl_client_priv",
22: "create_view_priv",
23: "show_view_priv",
24: "create_routine_priv",
25: "alter_routine_priv",
26: "create_user_priv",
2011-03-09 15:06:32 +03:00
}
2011-03-09 14:37:37 +03:00
2012-08-21 13:30:01 +04:00
PGSQL_PRIVS = {
2013-01-10 16:18:44 +04:00
1: "createdb",
2: "super",
3: "catupd",
2011-03-09 15:06:32 +03:00
}
2011-03-09 14:37:37 +03:00
2015-07-17 15:20:51 +03:00
# Reference(s): http://stackoverflow.com/a/17672504
# http://docwiki.embarcadero.com/InterBase/XE7/en/RDB$USER_PRIVILEGES
2012-08-21 13:30:01 +04:00
FIREBIRD_PRIVS = {
2011-03-09 14:37:37 +03:00
"S": "SELECT",
"I": "INSERT",
"U": "UPDATE",
"D": "DELETE",
2015-07-17 15:20:51 +03:00
"R": "REFERENCE",
2013-01-10 18:02:28 +04:00
"E": "EXECUTE",
2015-07-17 15:20:51 +03:00
"X": "EXECUTE",
"A": "ALL",
"M": "MEMBER",
"T": "DECRYPT",
"E": "ENCRYPT",
"B": "SUBSCRIBE",
2011-03-09 14:37:37 +03:00
}
2012-08-21 13:30:01 +04:00
DB2_PRIVS = {
1: "CONTROLAUTH",
2: "ALTERAUTH",
3: "DELETEAUTH",
4: "INDEXAUTH",
5: "INSERTAUTH",
6: "REFAUTH",
7: "SELECTAUTH",
2013-01-10 18:02:28 +04:00
8: "UPDATEAUTH",
}
2012-08-21 13:19:15 +04:00
2012-08-21 13:30:01 +04:00
DUMP_REPLACEMENTS = {" ": NULL, "": BLANK}
2012-08-21 13:19:15 +04:00
DBMS_DICT = {
2013-06-18 11:36:09 +04:00
DBMS.MSSQL: (MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/", "mssql+pymssql"),
DBMS.MYSQL: (MYSQL_ALIASES, "python pymysql", "https://github.com/petehunt/PyMySQL/", "mysql"),
DBMS.PGSQL: (PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/", "postgresql"),
DBMS.ORACLE: (ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/", "oracle"),
DBMS.SQLITE: (SQLITE_ALIASES, "python-sqlite", "http://packages.ubuntu.com/quantal/python-sqlite", "sqlite"),
DBMS.ACCESS: (ACCESS_ALIASES, "python-pyodbc", "http://pyodbc.googlecode.com/", "access"),
DBMS.FIREBIRD: (FIREBIRD_ALIASES, "python-kinterbasdb", "http://kinterbasdb.sourceforge.net/", "firebird"),
DBMS.MAXDB: (MAXDB_ALIASES, None, None, "maxdb"),
DBMS.SYBASE: (SYBASE_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/", "sybase"),
DBMS.DB2: (DB2_ALIASES, "python ibm-db", "http://code.google.com/p/ibm-db/", "ibm_db_sa"),
2014-01-10 21:23:16 +04:00
DBMS.HSQLDB: (HSQLDB_ALIASES, "python jaydebeapi & python-jpype", "https://pypi.python.org/pypi/JayDeBeApi/ & http://jpype.sourceforge.net/", None),
2012-08-21 13:19:15 +04:00
}
FROM_DUMMY_TABLE = {
DBMS.ORACLE: " FROM DUAL",
DBMS.ACCESS: " FROM MSysAccessObjects",
DBMS.FIREBIRD: " FROM RDB$DATABASE",
DBMS.MAXDB: " FROM VERSIONS",
2013-01-10 18:02:28 +04:00
DBMS.DB2: " FROM SYSIBM.SYSDUMMY1",
DBMS.HSQLDB: " FROM INFORMATION_SCHEMA.SYSTEM_USERS"
2012-08-21 13:19:15 +04:00
}
SQL_STATEMENTS = {
2013-01-10 18:02:28 +04:00
"SQL SELECT statement": (
2012-08-21 13:19:15 +04:00
"select ",
"show ",
" top ",
" distinct ",
" from ",
" from dual",
" where ",
" group by ",
" order by ",
" having ",
" limit ",
" offset ",
" union all ",
" rownum as ",
2013-01-10 18:02:28 +04:00
"(case ", ),
2012-08-21 13:19:15 +04:00
2013-01-10 18:02:28 +04:00
"SQL data definition": (
2012-08-21 13:19:15 +04:00
"create ",
"declare ",
"drop ",
"truncate ",
2013-01-10 18:02:28 +04:00
"alter ", ),
2012-08-21 13:19:15 +04:00
2013-01-10 18:02:28 +04:00
"SQL data manipulation": (
2012-08-21 13:19:15 +04:00
"bulk ",
"insert ",
"update ",
"delete ",
"merge ",
2013-01-10 18:02:28 +04:00
"load ", ),
2012-08-21 13:19:15 +04:00
2013-01-10 18:02:28 +04:00
"SQL data control": (
2012-08-21 13:19:15 +04:00
"grant ",
2013-01-10 18:02:28 +04:00
"revoke ", ),
2012-08-21 13:19:15 +04:00
2013-01-10 18:02:28 +04:00
"SQL data execution": (
2012-08-21 13:19:15 +04:00
"exec ",
2013-06-24 17:37:42 +04:00
"execute ",
2013-06-24 18:01:44 +04:00
"values ",
"call ", ),
2012-08-21 13:19:15 +04:00
2013-01-10 18:02:28 +04:00
"SQL transaction": (
2012-08-21 13:19:15 +04:00
"start transaction ",
"begin work ",
"begin transaction ",
"commit ",
2013-01-10 18:02:28 +04:00
"rollback ", ),
2012-08-21 13:19:15 +04:00
}
2012-10-04 13:25:44 +04:00
POST_HINT_CONTENT_TYPES = {
POST_HINT.JSON: "application/json",
POST_HINT.JSON_LIKE: "application/json",
2012-10-16 14:32:58 +04:00
POST_HINT.MULTIPART: "multipart/form-data",
POST_HINT.SOAP: "application/soap+xml",
2013-01-10 18:02:28 +04:00
POST_HINT.XML: "application/xml",
2014-10-09 17:42:44 +04:00
POST_HINT.ARRAY_LIKE: "application/x-www-form-urlencoded; charset=utf-8",
2012-10-04 13:25:44 +04:00
}
2012-11-28 14:10:57 +04:00
2013-01-18 18:40:37 +04:00
DEPRECATED_OPTIONS = {
2013-01-10 18:02:28 +04:00
"--replicate": "use '--dump-format=SQLITE' instead",
2013-01-18 18:40:37 +04:00
"--no-unescape": "use '--no-escape' instead",
2013-02-13 14:27:03 +04:00
"--binary": "use '--binary-fields' instead",
2015-09-27 16:59:17 +03:00
"--auth-private": "use '--auth-file' instead",
"--check-payload": None,
"--check-waf": None,
2013-01-18 18:40:37 +04:00
}
2013-01-15 19:05:33 +04:00
DUMP_DATA_PREPROCESS = {
DBMS.ORACLE: {"XMLTYPE": "(%s).getStringVal()"}, # Reference: https://www.tibcommunity.com/docs/DOC-3643
DBMS.MSSQL: {"IMAGE": "CONVERT(VARBINARY(MAX),%s)"},
}
2013-02-25 13:44:04 +04:00
DEFAULT_DOC_ROOTS = {
OS.WINDOWS: ("C:/xampp/htdocs/", "C:/wamp/www/", "C:/Inetpub/wwwroot/"),
OS.LINUX: ("/var/www/", "/var/www/html", "/usr/local/apache2/htdocs", "/var/www/nginx-default", "/srv/www") # Reference: https://wiki.apache.org/httpd/DistrosDefaultLayout
2013-02-25 13:44:04 +04:00
}