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

Skip to content

Commit 440b7ef

Browse files
committed
minor optimization
1 parent 7c1af97 commit 440b7ef

18 files changed

Lines changed: 44 additions & 44 deletions

File tree

lib/core/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def nullCastConcatFields(self, fields):
348348
nulledCastedFields.append(self.nullAndCastField(field))
349349

350350
delimiterStr = "%s'%s'%s" % (dbmsDelimiter, kb.chars.delimiter, dbmsDelimiter)
351-
nulledCastedConcatFields = delimiterStr.join([field for field in nulledCastedFields])
351+
nulledCastedConcatFields = delimiterStr.join(field for field in nulledCastedFields)
352352

353353
return nulledCastedConcatFields
354354

lib/core/convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def md5hash(value):
6262

6363
def orddecode(value):
6464
packedString = struct.pack("!"+"I" * len(value), *value)
65-
return "".join([chr(char) for char in struct.unpack("!"+"I"*(len(packedString)/4), packedString)])
65+
return "".join(chr(char) for char in struct.unpack("!"+"I"*(len(packedString)/4), packedString))
6666

6767
def ordencode(value):
68-
return tuple([ord(char) for char in value])
68+
return tuple(ord(char) for char in value)
6969

7070
def sha1hash(value):
7171
if sys.modules.has_key('hashlib'):

lib/core/settings.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -152,30 +152,30 @@
152152
DB2_SYSTEM_DBS = ( "NULLID", "SQLJ", "SYSCAT", "SYSFUN", "SYSIBM", "SYSIBMADM", "SYSIBMINTERNAL", "SYSIBMTS",\
153153
"SYSPROC", "SYSPUBLIC", "SYSSTAT", "SYSTOOLS" )
154154

155-
MSSQL_ALIASES = [ "microsoft sql server", "mssqlserver", "mssql", "ms" ]
156-
MYSQL_ALIASES = [ "mysql", "my" ]
157-
PGSQL_ALIASES = [ "postgresql", "postgres", "pgsql", "psql", "pg" ]
158-
ORACLE_ALIASES = [ "oracle", "orcl", "ora", "or" ]
159-
SQLITE_ALIASES = [ "sqlite", "sqlite3" ]
160-
ACCESS_ALIASES = [ "msaccess", "access", "jet", "microsoft access" ]
161-
FIREBIRD_ALIASES = [ "firebird", "mozilla firebird", "interbase", "ibase", "fb" ]
162-
MAXDB_ALIASES = [ "maxdb", "sap maxdb", "sap db" ]
163-
SYBASE_ALIASES = [ "sybase", "sybase sql server" ]
164-
DB2_ALIASES = [ "db2", "ibm db2", "ibmdb2" ]
155+
MSSQL_ALIASES = ( "microsoft sql server", "mssqlserver", "mssql", "ms" )
156+
MYSQL_ALIASES = ( "mysql", "my" )
157+
PGSQL_ALIASES = ( "postgresql", "postgres", "pgsql", "psql", "pg" )
158+
ORACLE_ALIASES = ( "oracle", "orcl", "ora", "or" )
159+
SQLITE_ALIASES = ( "sqlite", "sqlite3" )
160+
ACCESS_ALIASES = ( "msaccess", "access", "jet", "microsoft access" )
161+
FIREBIRD_ALIASES = ( "firebird", "mozilla firebird", "interbase", "ibase", "fb" )
162+
MAXDB_ALIASES = ( "maxdb", "sap maxdb", "sap db" )
163+
SYBASE_ALIASES = ( "sybase", "sybase sql server" )
164+
DB2_ALIASES = ( "db2", "ibm db2", "ibmdb2" )
165165

166166
SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES + SQLITE_ALIASES + ACCESS_ALIASES + FIREBIRD_ALIASES + MAXDB_ALIASES + SYBASE_ALIASES + DB2_ALIASES
167167
SUPPORTED_OS = ( "linux", "windows" )
168168

169-
DBMS_DICT = { DBMS.MSSQL: [MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"],
170-
DBMS.MYSQL: [MYSQL_ALIASES, "python pymysql", "http://code.google.com/p/pymysql/"],
171-
DBMS.PGSQL: [PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"],
172-
DBMS.ORACLE: [ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"],
173-
DBMS.SQLITE: [SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"],
174-
DBMS.ACCESS: [ACCESS_ALIASES, "python-pyodbc", "http://pyodbc.googlecode.com/"],
175-
DBMS.FIREBIRD: [FIREBIRD_ALIASES, "python-kinterbasdb", "http://kinterbasdb.sourceforge.net/"],
176-
DBMS.MAXDB: [MAXDB_ALIASES, None, None],
177-
DBMS.SYBASE: [SYBASE_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"],
178-
DBMS.DB2: [DB2_ALIASES, "python ibm-db", "http://code.google.com/p/ibm-db/"]
169+
DBMS_DICT = { DBMS.MSSQL: (MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"),
170+
DBMS.MYSQL: (MYSQL_ALIASES, "python pymysql", "http://code.google.com/p/pymysql/"),
171+
DBMS.PGSQL: (PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"),
172+
DBMS.ORACLE: (ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"),
173+
DBMS.SQLITE: (SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"),
174+
DBMS.ACCESS: (ACCESS_ALIASES, "python-pyodbc", "http://pyodbc.googlecode.com/"),
175+
DBMS.FIREBIRD: (FIREBIRD_ALIASES, "python-kinterbasdb", "http://kinterbasdb.sourceforge.net/"),
176+
DBMS.MAXDB: (MAXDB_ALIASES, None, None),
177+
DBMS.SYBASE: (SYBASE_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"),
178+
DBMS.DB2: (DB2_ALIASES, "python ibm-db", "http://code.google.com/p/ibm-db/")
179179
}
180180

181181
REFERER_ALIASES = ( "ref", "referer", "referrer" )
@@ -258,10 +258,10 @@
258258
SOAP_REGEX = r"\A(<\?xml[^>]+>)?\s*<soap.+</soap"
259259

260260
# Reference: http://www.cs.ru.nl/bachelorscripties/2010/Martin_Devillers___0437999___Analyzing_password_strength.pdf
261-
COMMON_PASSWORD_SUFFIXES = ["1", "123", "2", "12", "3", "13", "7", "11", "5", "22", "23", "01", "4", "07", "21", "14", "10", "06", "08", "8", "15", "69", "16", "6", "18"]
261+
COMMON_PASSWORD_SUFFIXES = ("1", "123", "2", "12", "3", "13", "7", "11", "5", "22", "23", "01", "4", "07", "21", "14", "10", "06", "08", "8", "15", "69", "16", "6", "18")
262262

263263
# Reference: http://www.the-interweb.com/serendipity/index.php?/archives/94-A-brief-analysis-of-40,000-leaked-MySpace-passwords.html
264-
COMMON_PASSWORD_SUFFIXES += ["!", ".", "*", "!!", "?", ";", "..", "!!!", ",", "@"]
264+
COMMON_PASSWORD_SUFFIXES += ("!", ".", "*", "!!", "?", ";", "..", "!!!", ",", "@")
265265

266266
# Splitter used between requests in WebScarab log files
267267
WEBSCARAB_SPLITTER = "### Conversation"

lib/core/target.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def __setRequestParams():
147147
# No need for url encoding/decoding the user agent
148148
conf.parameters[PLACE.UA] = urldecode(headerValue)
149149

150-
condition = any([not conf.testParameter, intersect(conf.testParameter, USER_AGENT_ALIASES)])
150+
condition = any((not conf.testParameter, intersect(conf.testParameter, USER_AGENT_ALIASES)))
151151

152152
if condition:
153153
conf.paramDict[PLACE.UA] = { PLACE.UA: headerValue }
@@ -157,7 +157,7 @@ def __setRequestParams():
157157
# No need for url encoding/decoding the referer
158158
conf.parameters[PLACE.REFERER] = urldecode(headerValue)
159159

160-
condition = any([not conf.testParameter, intersect(conf.testParameter, REFERER_ALIASES)])
160+
condition = any((not conf.testParameter, intersect(conf.testParameter, REFERER_ALIASES)))
161161

162162
if condition:
163163
conf.paramDict[PLACE.REFERER] = { PLACE.REFERER: headerValue }

lib/parse/cmdline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ def cmdLineParser():
630630
expandMnemonics(sys.argv[i+1], parser, args)
631631
break
632632

633-
if not any([args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \
634-
args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.realTest, args.wizard, args.dependencies]):
633+
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \
634+
args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.realTest, args.wizard, args.dependencies)):
635635
errMsg = "missing a mandatory parameter (-d, -u, -l, -m, -r, -g, -c, --wizard, --update or --dependencies), "
636636
errMsg += "-h for help"
637637
parser.error(errMsg)

lib/request/connect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def getPage(**kwargs):
266266
if not req.has_header(HTTPHEADER.ACCEPT_ENCODING):
267267
requestHeaders += "%s: identity\n" % HTTPHEADER.ACCEPT_ENCODING
268268

269-
requestHeaders += "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in req.header_items()])
269+
requestHeaders += "\n".join("%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in req.header_items())
270270

271271
if not req.has_header(HTTPHEADER.COOKIE) and cookieStr:
272272
requestHeaders += "\n%s" % cookieStr[:-2]
@@ -396,7 +396,7 @@ def getPage(**kwargs):
396396
responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, status)
397397

398398
if responseHeaders:
399-
logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in responseHeaders.items()])
399+
logHeaders = "\n".join("%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in responseHeaders.items())
400400

401401
logHTTPTraffic(requestMsg, "%s%s\n\n%s" % (responseMsg, logHeaders, page if isinstance(page, unicode) else getUnicode(page)))
402402

@@ -486,7 +486,7 @@ def getPage(**kwargs):
486486

487487
responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, status)
488488
if responseHeaders:
489-
logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in responseHeaders.items()])
489+
logHeaders = "\n".join("%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in responseHeaders.items())
490490

491491
logHTTPTraffic(requestMsg, "%s%s\n\n%s" % (responseMsg, logHeaders, page if isinstance(page, unicode) else getUnicode(page)))
492492

lib/request/inject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def __goInferenceProxy(expression, fromUser=False, expected=None, batch=False, r
319319
expression += FROM_TABLE[Backend.getIdentifiedDbms()]
320320

321321
outputs = __goInferenceFields(expression, expressionFields, expressionFieldsList, payload, expected, resumeValue=resumeValue, charsetType=charsetType, firstChar=firstChar, lastChar=lastChar, dump=dump)
322-
returnValue = ", ".join([output for output in outputs])
322+
returnValue = ", ".join(output for output in outputs)
323323

324324
return returnValue
325325

lib/request/redirecthandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def common_http_redirect(self, result, headers, code, content, msg):
4949
responseMsg += "[#%d] (%d %s):\n" % (threadData.lastRequestUID, code, getUnicode(msg))
5050

5151
if headers:
52-
logHeaders = "\n".join(["%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in headers.items()])
52+
logHeaders = "\n".join("%s: %s" % (key.capitalize() if isinstance(key, basestring) else key, getUnicode(value)) for (key, value) in headers.items())
5353
else:
5454
logHeaders = ""
5555

lib/utils/hash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def hashRecognition(value):
394394
elif isMySQL and regex == HASH.ORACLE_OLD:
395395
continue
396396
elif regex == HASH.CRYPT_GENERIC:
397-
if any([getCompiledRegex(GENERAL_IP_ADDRESS_REGEX).match(value), value.lower() == value, value.upper() == value, value.isdigit()]):
397+
if any((getCompiledRegex(GENERAL_IP_ADDRESS_REGEX).match(value), value.lower() == value, value.upper() == value, value.isdigit())):
398398
continue
399399
elif getCompiledRegex(regex).match(value):
400400
retVal = regex

lib/utils/resume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def resume(expression, payload):
124124

125125
if logValue:
126126
if kb.technique == PAYLOAD.TECHNIQUE.UNION:
127-
logValue = ", ".join([value.replace(DUMP_DEL_MARKER, ", ") for value in logValue])
127+
logValue = ", ".join(value.replace(DUMP_DEL_MARKER, ", ") for value in logValue)
128128
else:
129129
return None
130130
else:

0 commit comments

Comments
 (0)