From 440b7efe55c812fa07489ba67076a6e413b7bf09 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 20 Nov 2011 20:14:47 +0000 Subject: [PATCH] minor optimization --- lib/core/agent.py | 2 +- lib/core/convert.py | 4 +-- lib/core/settings.py | 44 +++++++++++++++---------------- lib/core/target.py | 4 +-- lib/parse/cmdline.py | 4 +-- lib/request/connect.py | 6 ++--- lib/request/inject.py | 2 +- lib/request/redirecthandler.py | 2 +- lib/utils/hash.py | 2 +- lib/utils/resume.py | 2 +- plugins/dbms/access/syntax.py | 2 +- plugins/dbms/db2/syntax.py | 2 +- plugins/dbms/firebird/syntax.py | 2 +- plugins/dbms/mysql/syntax.py | 2 +- plugins/dbms/oracle/syntax.py | 2 +- plugins/dbms/postgresql/syntax.py | 2 +- plugins/dbms/sybase/syntax.py | 2 +- plugins/generic/enumeration.py | 2 +- 18 files changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index 9a49812f5..78e8d3b28 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -348,7 +348,7 @@ class Agent: nulledCastedFields.append(self.nullAndCastField(field)) delimiterStr = "%s'%s'%s" % (dbmsDelimiter, kb.chars.delimiter, dbmsDelimiter) - nulledCastedConcatFields = delimiterStr.join([field for field in nulledCastedFields]) + nulledCastedConcatFields = delimiterStr.join(field for field in nulledCastedFields) return nulledCastedConcatFields diff --git a/lib/core/convert.py b/lib/core/convert.py index a58fe3ccf..c396744cd 100644 --- a/lib/core/convert.py +++ b/lib/core/convert.py @@ -62,10 +62,10 @@ def md5hash(value): def orddecode(value): packedString = struct.pack("!"+"I" * len(value), *value) - return "".join([chr(char) for char in struct.unpack("!"+"I"*(len(packedString)/4), packedString)]) + return "".join(chr(char) for char in struct.unpack("!"+"I"*(len(packedString)/4), packedString)) def ordencode(value): - return tuple([ord(char) for char in value]) + return tuple(ord(char) for char in value) def sha1hash(value): if sys.modules.has_key('hashlib'): diff --git a/lib/core/settings.py b/lib/core/settings.py index 8673ba30a..e49d15671 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -152,30 +152,30 @@ SYBASE_SYSTEM_DBS = ( "master", "model", "sybsystemdb", "sybsystemprocs" ) DB2_SYSTEM_DBS = ( "NULLID", "SQLJ", "SYSCAT", "SYSFUN", "SYSIBM", "SYSIBMADM", "SYSIBMINTERNAL", "SYSIBMTS",\ "SYSPROC", "SYSPUBLIC", "SYSSTAT", "SYSTOOLS" ) -MSSQL_ALIASES = [ "microsoft sql server", "mssqlserver", "mssql", "ms" ] -MYSQL_ALIASES = [ "mysql", "my" ] -PGSQL_ALIASES = [ "postgresql", "postgres", "pgsql", "psql", "pg" ] -ORACLE_ALIASES = [ "oracle", "orcl", "ora", "or" ] -SQLITE_ALIASES = [ "sqlite", "sqlite3" ] -ACCESS_ALIASES = [ "msaccess", "access", "jet", "microsoft access" ] -FIREBIRD_ALIASES = [ "firebird", "mozilla firebird", "interbase", "ibase", "fb" ] -MAXDB_ALIASES = [ "maxdb", "sap maxdb", "sap db" ] -SYBASE_ALIASES = [ "sybase", "sybase sql server" ] -DB2_ALIASES = [ "db2", "ibm db2", "ibmdb2" ] +MSSQL_ALIASES = ( "microsoft sql server", "mssqlserver", "mssql", "ms" ) +MYSQL_ALIASES = ( "mysql", "my" ) +PGSQL_ALIASES = ( "postgresql", "postgres", "pgsql", "psql", "pg" ) +ORACLE_ALIASES = ( "oracle", "orcl", "ora", "or" ) +SQLITE_ALIASES = ( "sqlite", "sqlite3" ) +ACCESS_ALIASES = ( "msaccess", "access", "jet", "microsoft access" ) +FIREBIRD_ALIASES = ( "firebird", "mozilla firebird", "interbase", "ibase", "fb" ) +MAXDB_ALIASES = ( "maxdb", "sap maxdb", "sap db" ) +SYBASE_ALIASES = ( "sybase", "sybase sql server" ) +DB2_ALIASES = ( "db2", "ibm db2", "ibmdb2" ) SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES + SQLITE_ALIASES + ACCESS_ALIASES + FIREBIRD_ALIASES + MAXDB_ALIASES + SYBASE_ALIASES + DB2_ALIASES SUPPORTED_OS = ( "linux", "windows" ) -DBMS_DICT = { DBMS.MSSQL: [MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"], - DBMS.MYSQL: [MYSQL_ALIASES, "python pymysql", "http://code.google.com/p/pymysql/"], - DBMS.PGSQL: [PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"], - DBMS.ORACLE: [ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"], - DBMS.SQLITE: [SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"], - DBMS.ACCESS: [ACCESS_ALIASES, "python-pyodbc", "http://pyodbc.googlecode.com/"], - DBMS.FIREBIRD: [FIREBIRD_ALIASES, "python-kinterbasdb", "http://kinterbasdb.sourceforge.net/"], - DBMS.MAXDB: [MAXDB_ALIASES, None, None], - DBMS.SYBASE: [SYBASE_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"], - DBMS.DB2: [DB2_ALIASES, "python ibm-db", "http://code.google.com/p/ibm-db/"] +DBMS_DICT = { DBMS.MSSQL: (MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"), + DBMS.MYSQL: (MYSQL_ALIASES, "python pymysql", "http://code.google.com/p/pymysql/"), + DBMS.PGSQL: (PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"), + DBMS.ORACLE: (ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"), + DBMS.SQLITE: (SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"), + DBMS.ACCESS: (ACCESS_ALIASES, "python-pyodbc", "http://pyodbc.googlecode.com/"), + DBMS.FIREBIRD: (FIREBIRD_ALIASES, "python-kinterbasdb", "http://kinterbasdb.sourceforge.net/"), + DBMS.MAXDB: (MAXDB_ALIASES, None, None), + DBMS.SYBASE: (SYBASE_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"), + DBMS.DB2: (DB2_ALIASES, "python ibm-db", "http://code.google.com/p/ibm-db/") } REFERER_ALIASES = ( "ref", "referer", "referrer" ) @@ -258,10 +258,10 @@ GENERAL_IP_ADDRESS_REGEX = r'\A\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\Z' SOAP_REGEX = r"\A(<\?xml[^>]+>)?\s* 0 and not isinstance(value[0], (list, tuple)): - value = zip([conf.db for i in xrange(len(value))], value) + value = zip((conf.db for i in xrange(len(value))), value) for db, table in filterPairValues(value): db = safeSQLIdentificatorNaming(db)