Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 264a270

Browse files
committed
Adding initial support for Cubrid
1 parent 4278bbc commit 264a270

16 files changed

Lines changed: 367 additions & 10 deletions

File tree

data/xml/queries.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,4 +1381,71 @@
13811381
<blind query="SELECT DISTINCT(nspname) FROM pg_namespace,pg_type,pg_attribute b JOIN pg_class a ON a.oid=b.attrelid WHERE a.relnamespace=pg_namespace.oid AND pg_type.oid=b.atttypid AND attnum>0 AND %s" query2="SELECT DISTINCT(relname) FROM pg_namespace,pg_type,pg_attribute b JOIN pg_class a ON a.oid=b.attrelid WHERE a.relnamespace=pg_namespace.oid AND pg_type.oid=b.atttypid AND attnum>0 AND nspname='%s'" count="SELECT COUNT(DISTINCT(nspname)) FROM pg_namespace,pg_type,pg_attribute b JOIN pg_class a ON a.oid=b.attrelid WHERE a.relnamespace=pg_namespace.oid AND pg_type.oid=b.atttypid AND attnum>0 AND %s" count2="SELECT COUNT(DISTINCT(relname)) FROM pg_namespace,pg_type,pg_attribute b JOIN pg_class a ON a.oid=b.attrelid WHERE a.relnamespace=pg_namespace.oid AND pg_type.oid=b.atttypid AND attnum>0 AND nspname='%s'" condition="attname" condition2="nspname" condition3="relname"/>
13821382
</search_column>
13831383
</dbms>
1384+
1385+
<dbms value="Cubrid">
1386+
<cast query="CAST(%s AS VARCHAR(4000))"/>
1387+
<length query="CHAR_LENGTH(%s)"/>
1388+
<isnull query="IFNULL(%s,' ')"/>
1389+
<delimiter query="||"/>
1390+
<limit query="LIMIT %d,%d"/>
1391+
<limitregexp query="\s+LIMIT\s+([\d]+)\s*\,\s*([\d]+)" query2="\s+LIMIT\s+([\d]+)"/>
1392+
<limitgroupstart query="1"/>
1393+
<limitgroupstop query="2"/>
1394+
<limitstring query=" LIMIT "/>
1395+
<order query="ORDER BY %s ASC"/>
1396+
<count query="COUNT(%s)"/>
1397+
<comment query="--" query2="/*" query3="//"/>
1398+
<substring query="MID((%s),%d,%d)"/>
1399+
<concatenate query="%s||%s"/>
1400+
<case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/>
1401+
<hex query="HEX(%s)"/>
1402+
<inference query="ASCII(MID((%s),%d,1))>%d"/>
1403+
<banner query="VERSION()"/>
1404+
<current_user query="CURRENT_USER"/>
1405+
<current_db query="CURRENT_USER"/>
1406+
<hostname/>
1407+
<table_comment query="SELECT comment FROM db_class WHERE owner_name='%s' AND class_name='%s'"/>
1408+
<column_comment query="SELECT db_attribute.comment FROM db_attribute JOIN db_class ON db_attribute.class_name=db_class.class_name WHERE owner_name='%s' AND db_class.class_name='%s' AND attr_name='%s'"/>
1409+
<is_dba query="CURRENT_USER='DBA'"/>
1410+
<check_udf query="(SELECT meth_name FROM db_method WHERE meth_name='%s' LIMIT 0,1)='%s'"/>
1411+
<users>
1412+
<inband query="SELECT name FROM db_user"/>
1413+
<blind query="SELECT name FROM db_user LIMIT %d,1" count="SELECT COUNT(name) FROM db_user"/>
1414+
</users>
1415+
<passwords/>
1416+
<privileges>
1417+
<inband query="SELECT grantee,auth_type FROM DB_AUTH" condition="grantee"/>
1418+
<blind query="SELECT DISTINCT(auth_type) FROM DB_AUTH WHERE grantee %s '%s' LIMIT %d,1" count="SELECT COUNT(DISTINCT(auth_type)) FROM DB_AUTH WHERE grantee %s '%s'"/>
1419+
</privileges>
1420+
<roles/>
1421+
<statements/>
1422+
<dbs>
1423+
<inband query="SELECT owner_name FROM db_class"/>
1424+
<blind query="SELECT DISTINCT(owner_name) FROM db_class LIMIT %d,1" count="SELECT COUNT(DISTINCT(owner_name)) FROM db_class"/>
1425+
</dbs>
1426+
<tables>
1427+
<inband query="SELECT owner_name,class_name FROM db_class" condition="owner_name"/>
1428+
<blind query="SELECT class_name FROM db_class WHERE owner_name='%s' LIMIT %d,1" count="SELECT COUNT(class_name) FROM db_class WHERE owner_name='%s'"/>
1429+
</tables>
1430+
<columns>
1431+
<inband query="SELECT attr_name,data_type FROM db_attribute WHERE class_name='%s'" condition="attr_name"/>
1432+
<blind query="SELECT attr_name FROM db_attribute WHERE class_name='%s'" query2="SELECT data_type FROM db_attribute WHERE class_name='%s' AND attr_name='%s'" count="SELECT COUNT(attr_name) FROM db_attribute WHERE class_name='%s'" condition="attr_name"/>
1433+
</columns>
1434+
<dump_table>
1435+
<inband query="SELECT %s FROM %s.%s"/>
1436+
<blind query="SELECT %s FROM %s.%s LIMIT %d,1" count="SELECT COUNT(*) FROM %s.%s"/>
1437+
</dump_table>
1438+
<search_db>
1439+
<inband query="SELECT name FROM db_user WHERE %s" condition="name"/>
1440+
<blind query="SELECT name FROM db_user WHERE %s" count="SELECT COUNT(name) FROM db_user WHERE %s" condition="name"/>
1441+
</search_db>
1442+
<search_table>
1443+
<inband query="SELECT owner_name,class_name FROM db_class WHERE %s" condition="class_name" condition2="owner_name"/>
1444+
<blind query="SELECT DISTINCT(owner_name) FROM db_class WHERE %s" query2="SELECT DISTINCT(class_name) FROM db_class WHERE owner_name='%s'" count="SELECT COUNT(DISTINCT(owner_name)) FROM db_class WHERE %s" count2="SELECT COUNT(DISTINCT(class_name)) FROM db_class WHERE owner_name='%s'" condition="class_name" condition2="owner_name"/>
1445+
</search_table>
1446+
<search_column>
1447+
<inband query="SELECT owner_name,db_class.class_name FROM db_attribute JOIN db_class ON db_attribute.class_name=db_class.class_name WHERE %s" condition="attr_name" condition2="owner_name" condition3="db_class.class_name"/>
1448+
<blind query="SELECT DISTINCT(owner_name) FROM db_attribute JOIN db_class ON db_attribute.class_name=db_class.class_name WHERE %s" query2="SELECT DISTINCT(db_class.class_name) FROM db_attribute JOIN db_class ON db_attribute.class_name=db_class.class_name WHERE owner_name='%s'" count="SELECT COUNT(DISTINCT(owner_name)) FROM db_attribute JOIN db_class ON db_attribute.class_name=db_class.class_name WHERE %s" count2="SELECT COUNT(DISTINCT(db_class.class_name)) FROM db_attribute JOIN db_class ON db_attribute.class_name=db_class.class_name WHERE owner_name='%s'" condition="attr_name" condition2="owner_name" condition3="db_class.class_name"/>
1449+
</search_column>
1450+
</dbms>
13841451
</root>

lib/controller/handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from lib.core.settings import ACCESS_ALIASES
1515
from lib.core.settings import ALTIBASE_ALIASES
1616
from lib.core.settings import CRATEDB_ALIASES
17+
from lib.core.settings import CUBRID_ALIASES
1718
from lib.core.settings import DB2_ALIASES
1819
from lib.core.settings import DERBY_ALIASES
1920
from lib.core.settings import FIREBIRD_ALIASES
@@ -40,6 +41,8 @@
4041
from plugins.dbms.altibase import AltibaseMap
4142
from plugins.dbms.cratedb.connector import Connector as CrateDBConn
4243
from plugins.dbms.cratedb import CrateDBMap
44+
from plugins.dbms.cubrid.connector import Connector as CubridConn
45+
from plugins.dbms.cubrid import CubridMap
4346
from plugins.dbms.db2.connector import Connector as DB2Conn
4447
from plugins.dbms.db2 import DB2Map
4548
from plugins.dbms.derby.connector import Connector as DerbyConn
@@ -105,6 +108,7 @@ def setHandler():
105108
(DBMS.ALTIBASE, ALTIBASE_ALIASES, AltibaseMap, AltibaseConn),
106109
(DBMS.MIMERSQL, MIMERSQL_ALIASES, MimerSQLMap, MimerSQLConn),
107110
(DBMS.CRATEDB, CRATEDB_ALIASES, CrateDBMap, CrateDBConn),
111+
(DBMS.CUBRID, CUBRID_ALIASES, CubridMap, CubridConn),
108112
]
109113

110114
_ = max(_ if (conf.get("dbms") or Backend.getIdentifiedDbms() or kb.heuristicExtendedDbms or "").lower() in _[1] else () for _ in items)

lib/core/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def suffixQuery(self, expression, comment=None, suffix=None, where=None, trimEmp
301301
comment = getTechniqueData().comment if comment is None else comment
302302

303303
if any((comment or "").startswith(_) for _ in ("--", GENERIC_SQL_COMMENT_MARKER)):
304-
if not GENERIC_SQL_COMMENT.startswith(queries[Backend.getIdentifiedDbms()].comment.query):
304+
if Backend.getIdentifiedDbms() and not GENERIC_SQL_COMMENT.startswith(queries[Backend.getIdentifiedDbms()].comment.query):
305305
comment = queries[Backend.getIdentifiedDbms()].comment.query
306306

307307
if comment is not None:
@@ -660,7 +660,7 @@ def concatQuery(self, query, unpack=True):
660660
elif fieldsNoSelect:
661661
concatenatedQuery = "CONCAT('%s',%s,'%s')" % (kb.chars.start, concatenatedQuery, kb.chars.stop)
662662

663-
elif Backend.getIdentifiedDbms() in (DBMS.PGSQL, DBMS.ORACLE, DBMS.SQLITE, DBMS.DB2, DBMS.FIREBIRD, DBMS.HSQLDB, DBMS.H2, DBMS.MONETDB, DBMS.DERBY, DBMS.VERTICA, DBMS.MCKOI, DBMS.PRESTO, DBMS.ALTIBASE, DBMS.MIMERSQL, DBMS.CRATEDB):
663+
elif Backend.getIdentifiedDbms() in (DBMS.PGSQL, DBMS.ORACLE, DBMS.SQLITE, DBMS.DB2, DBMS.FIREBIRD, DBMS.HSQLDB, DBMS.H2, DBMS.MONETDB, DBMS.DERBY, DBMS.VERTICA, DBMS.MCKOI, DBMS.PRESTO, DBMS.ALTIBASE, DBMS.MIMERSQL, DBMS.CRATEDB, DBMS.CUBRID):
664664
if fieldsExists:
665665
concatenatedQuery = concatenatedQuery.replace("SELECT ", "'%s'||" % kb.chars.start, 1)
666666
concatenatedQuery += "||'%s'" % kb.chars.stop
@@ -949,7 +949,7 @@ def limitQuery(self, num, query, field=None, uniqueField=None):
949949
fromFrom = limitedQuery[fromIndex + 1:]
950950
orderBy = None
951951

952-
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.SQLITE, DBMS.H2, DBMS.VERTICA, DBMS.PRESTO, DBMS.MIMERSQL):
952+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.SQLITE, DBMS.H2, DBMS.VERTICA, DBMS.PRESTO, DBMS.MIMERSQL, DBMS.CUBRID):
953953
limitStr = queries[Backend.getIdentifiedDbms()].limit.query % (num, 1)
954954
limitedQuery += " %s" % limitStr
955955

lib/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,7 +4076,7 @@ def safeSQLIdentificatorNaming(name, isTable=False):
40764076
if retVal.upper() in kb.keywords or (retVal or " ")[0].isdigit() or not re.match(r"\A[A-Za-z0-9_@%s\$]+\Z" % ('.' if _ else ""), retVal): # MsSQL is the only DBMS where we automatically prepend schema to table name (dot is normal)
40774077
retVal = unsafeSQLIdentificatorNaming(retVal)
40784078

4079-
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ACCESS, DBMS.SQLITE): # Note: in SQLite double-quotes are treated as string if column/identifier is non-existent (e.g. SELECT "foobar" FROM users)
4079+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ACCESS, DBMS.CUBRID, DBMS.SQLITE): # Note: in SQLite double-quotes are treated as string if column/identifier is non-existent (e.g. SELECT "foobar" FROM users)
40804080
retVal = "`%s`" % retVal
40814081
elif Backend.getIdentifiedDbms() in (DBMS.PGSQL, DBMS.DB2, DBMS.HSQLDB, DBMS.H2, DBMS.INFORMIX, DBMS.MONETDB, DBMS.VERTICA, DBMS.MCKOI, DBMS.PRESTO, DBMS.CRATEDB):
40824082
retVal = "\"%s\"" % retVal
@@ -4114,7 +4114,7 @@ def unsafeSQLIdentificatorNaming(name):
41144114
retVal = name
41154115

41164116
if isinstance(name, six.string_types):
4117-
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ACCESS, DBMS.SQLITE):
4117+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ACCESS, DBMS.CUBRID, DBMS.SQLITE):
41184118
retVal = name.replace("`", "")
41194119
elif Backend.getIdentifiedDbms() in (DBMS.PGSQL, DBMS.DB2, DBMS.HSQLDB, DBMS.H2, DBMS.INFORMIX, DBMS.MONETDB, DBMS.VERTICA, DBMS.MCKOI, DBMS.PRESTO, DBMS.CRATEDB):
41204120
retVal = name.replace("\"", "")

lib/core/dicts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from lib.core.settings import ALTIBASE_ALIASES
1414
from lib.core.settings import BLANK
1515
from lib.core.settings import CRATEDB_ALIASES
16+
from lib.core.settings import CUBRID_ALIASES
1617
from lib.core.settings import DB2_ALIASES
1718
from lib.core.settings import DERBY_ALIASES
1819
from lib.core.settings import FIREBIRD_ALIASES
@@ -214,6 +215,7 @@
214215
DBMS.ALTIBASE: (ALTIBASE_ALIASES, None, None, None),
215216
DBMS.MIMERSQL: (MIMERSQL_ALIASES, "mimerpy", "https://github.com/mimersql/MimerPy", None),
216217
DBMS.CRATEDB: (CRATEDB_ALIASES, "python-psycopg2", "http://initd.org/psycopg/", "postgresql"),
218+
DBMS.CUBRID: (CUBRID_ALIASES, "CUBRID-Python", "https://github.com/CUBRID/cubrid-python", None),
217219
}
218220

219221
# Reference: https://blog.jooq.org/tag/sysibm-sysdummy1/
@@ -245,6 +247,7 @@
245247
DBMS.ALTIBASE: "TDESENCRYPT(NULL,NULL)",
246248
DBMS.MIMERSQL: "ASCII_CHAR(256)",
247249
DBMS.CRATEDB: "(NULL~NULL)",
250+
DBMS.CUBRID: "(NULL SETEQ NULL)",
248251
}
249252

250253
SQL_STATEMENTS = {

lib/core/enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class DBMS(object):
5353
ALTIBASE = "Altibase"
5454
MIMERSQL = "MimerSQL"
5555
CRATEDB = "CrateDB"
56+
CUBRID = "Cubrid"
5657

5758
class DBMS_DIRECTORY_NAME(object):
5859
ACCESS = "access"
@@ -76,6 +77,7 @@ class DBMS_DIRECTORY_NAME(object):
7677
ALTIBASE = "altibase"
7778
MIMERSQL = "mimersql"
7879
CRATEDB = "cratedb"
80+
CUBRID = "cubrid"
7981

8082
class FORK(object):
8183
MARIADB = "MariaDB"

lib/core/settings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.4.2.6"
21+
VERSION = "1.4.2.7"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -267,6 +267,7 @@
267267
ALTIBASE_SYSTEM_DBS = ("SYSTEM_",)
268268
MIMERSQL_SYSTEM_DBS = ("information_schema", "SYSTEM",)
269269
CRATEDB_SYSTEM_DBS = ("information_schema", "pg_catalog", "sys")
270+
CUBRID_SYSTEM_DBS = ("",)
270271

271272
# Note: (<regular>) + (<forks>)
272273
MSSQL_ALIASES = ("microsoft sql server", "mssqlserver", "mssql", "ms")
@@ -290,13 +291,14 @@
290291
ALTIBASE_ALIASES = ("altibase",)
291292
MIMERSQL_ALIASES = ("mimersql", "mimer")
292293
CRATEDB_ALIASES = ("cratedb", "crate")
294+
CUBRID_ALIASES = ("cubrid",)
293295

294296
DBMS_DIRECTORY_DICT = dict((getattr(DBMS, _), getattr(DBMS_DIRECTORY_NAME, _)) for _ in dir(DBMS) if not _.startswith("_"))
295297

296-
SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES + SQLITE_ALIASES + ACCESS_ALIASES + FIREBIRD_ALIASES + MAXDB_ALIASES + SYBASE_ALIASES + DB2_ALIASES + HSQLDB_ALIASES + H2_ALIASES + INFORMIX_ALIASES + MONETDB_ALIASES + DERBY_ALIASES + VERTICA_ALIASES + MCKOI_ALIASES + PRESTO_ALIASES + ALTIBASE_ALIASES + MIMERSQL_ALIASES + CRATEDB_ALIASES
298+
SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES + SQLITE_ALIASES + ACCESS_ALIASES + FIREBIRD_ALIASES + MAXDB_ALIASES + SYBASE_ALIASES + DB2_ALIASES + HSQLDB_ALIASES + H2_ALIASES + INFORMIX_ALIASES + MONETDB_ALIASES + DERBY_ALIASES + VERTICA_ALIASES + MCKOI_ALIASES + PRESTO_ALIASES + ALTIBASE_ALIASES + MIMERSQL_ALIASES + CRATEDB_ALIASES + CUBRID_ALIASES
297299
SUPPORTED_OS = ("linux", "windows")
298300

299-
DBMS_ALIASES = ((DBMS.MSSQL, MSSQL_ALIASES), (DBMS.MYSQL, MYSQL_ALIASES), (DBMS.PGSQL, PGSQL_ALIASES), (DBMS.ORACLE, ORACLE_ALIASES), (DBMS.SQLITE, SQLITE_ALIASES), (DBMS.ACCESS, ACCESS_ALIASES), (DBMS.FIREBIRD, FIREBIRD_ALIASES), (DBMS.MAXDB, MAXDB_ALIASES), (DBMS.SYBASE, SYBASE_ALIASES), (DBMS.DB2, DB2_ALIASES), (DBMS.HSQLDB, HSQLDB_ALIASES), (DBMS.H2, H2_ALIASES), (DBMS.INFORMIX, INFORMIX_ALIASES), (DBMS.MONETDB, MONETDB_ALIASES), (DBMS.DERBY, DERBY_ALIASES), (DBMS.VERTICA, VERTICA_ALIASES), (DBMS.MCKOI, MCKOI_ALIASES), (DBMS.PRESTO, PRESTO_ALIASES), (DBMS.ALTIBASE, ALTIBASE_ALIASES), (DBMS.MIMERSQL, MIMERSQL_ALIASES), (DBMS.CRATEDB, CRATEDB_ALIASES))
301+
DBMS_ALIASES = ((DBMS.MSSQL, MSSQL_ALIASES), (DBMS.MYSQL, MYSQL_ALIASES), (DBMS.PGSQL, PGSQL_ALIASES), (DBMS.ORACLE, ORACLE_ALIASES), (DBMS.SQLITE, SQLITE_ALIASES), (DBMS.ACCESS, ACCESS_ALIASES), (DBMS.FIREBIRD, FIREBIRD_ALIASES), (DBMS.MAXDB, MAXDB_ALIASES), (DBMS.SYBASE, SYBASE_ALIASES), (DBMS.DB2, DB2_ALIASES), (DBMS.HSQLDB, HSQLDB_ALIASES), (DBMS.H2, H2_ALIASES), (DBMS.INFORMIX, INFORMIX_ALIASES), (DBMS.MONETDB, MONETDB_ALIASES), (DBMS.DERBY, DERBY_ALIASES), (DBMS.VERTICA, VERTICA_ALIASES), (DBMS.MCKOI, MCKOI_ALIASES), (DBMS.PRESTO, PRESTO_ALIASES), (DBMS.ALTIBASE, ALTIBASE_ALIASES), (DBMS.MIMERSQL, MIMERSQL_ALIASES), (DBMS.CRATEDB, CRATEDB_ALIASES), (DBMS.CUBRID, CUBRID_ALIASES))
300302

301303
USER_AGENT_ALIASES = ("ua", "useragent", "user-agent")
302304
REFERER_ALIASES = ("ref", "referer", "referrer")

lib/utils/deps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def checkDependencies():
5656
__import__("prestodb")
5757
elif dbmsName == DBMS.MIMERSQL:
5858
__import__("mimerpy")
59+
elif dbmsName == DBMS.CUBRID:
60+
__import__("CUBRIDdb")
5961
except:
6062
warnMsg = "sqlmap requires '%s' third-party library " % data[1]
6163
warnMsg += "in order to directly connect to the DBMS "

plugins/dbms/cubrid/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
5+
See the file 'LICENSE' for copying permission
6+
"""
7+
8+
from lib.core.enums import DBMS
9+
from lib.core.settings import CUBRID_SYSTEM_DBS
10+
from lib.core.unescaper import unescaper
11+
12+
from plugins.dbms.cubrid.enumeration import Enumeration
13+
from plugins.dbms.cubrid.filesystem import Filesystem
14+
from plugins.dbms.cubrid.fingerprint import Fingerprint
15+
from plugins.dbms.cubrid.syntax import Syntax
16+
from plugins.dbms.cubrid.takeover import Takeover
17+
from plugins.generic.misc import Miscellaneous
18+
19+
class CubridMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover):
20+
"""
21+
This class defines Cubrid methods
22+
"""
23+
24+
def __init__(self):
25+
self.excludeDbsList = CUBRID_SYSTEM_DBS
26+
27+
for cls in self.__class__.__bases__:
28+
cls.__init__(self)
29+
30+
unescaper[DBMS.CUBRID] = Syntax.escape

plugins/dbms/cubrid/connector.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
5+
See the file 'LICENSE' for copying permission
6+
"""
7+
8+
try:
9+
import CUBRIDdb
10+
except:
11+
pass
12+
13+
import logging
14+
15+
from lib.core.common import getSafeExString
16+
from lib.core.data import conf
17+
from lib.core.data import logger
18+
from lib.core.exception import SqlmapConnectionException
19+
from plugins.generic.connector import Connector as GenericConnector
20+
21+
class Connector(GenericConnector):
22+
"""
23+
Homepage: https://github.com/CUBRID/cubrid-python
24+
User guide: https://github.com/CUBRID/cubrid-python/blob/develop/README.md
25+
API: https://www.python.org/dev/peps/pep-0249/
26+
License: BSD License
27+
"""
28+
29+
def connect(self):
30+
self.initConnection()
31+
32+
try:
33+
self.connector = CUBRIDdb.connect(hostname=self.hostname, username=self.user, password=self.password, database=self.db, port=self.port, connect_timeout=conf.timeout)
34+
except CUBRIDdb.DatabaseError as ex:
35+
raise SqlmapConnectionException(getSafeExString(ex))
36+
37+
self.initCursor()
38+
self.printConnected()
39+
40+
def fetchall(self):
41+
try:
42+
return self.cursor.fetchall()
43+
except CUBRIDdb.DatabaseError as ex:
44+
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex))
45+
return None
46+
47+
def execute(self, query):
48+
try:
49+
self.cursor.execute(query)
50+
except CUBRIDdb.DatabaseError as ex:
51+
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex))
52+
except CUBRIDdb.Error as ex:
53+
raise SqlmapConnectionException(getSafeExString(ex))
54+
55+
self.connector.commit()
56+
57+
def select(self, query):
58+
self.execute(query)
59+
return self.fetchall()

0 commit comments

Comments
 (0)