Minor style update (PEP8)

This commit is contained in:
Miroslav Stampar 2013-01-10 15:02:28 +01:00
parent ca3d35a878
commit 934d41dac2
22 changed files with 87 additions and 82 deletions

View File

@ -617,4 +617,3 @@ def start():
logger.info(infoMsg)
return True

View File

@ -56,7 +56,7 @@ def setHandler():
("Firebird", FIREBIRD_ALIASES, FirebirdMap, FirebirdConn),
("SAP MaxDB", MAXDB_ALIASES, MaxDBMap, MaxDBConn),
("Sybase", SYBASE_ALIASES, SybaseMap, SybaseConn),
("IBM DB2", DB2_ALIASES, DB2Map, DB2Conn)
("IBM DB2", DB2_ALIASES, DB2Map, DB2Conn),
]
_ = max(_ if (Backend.getIdentifiedDbms() or "").lower() in _[1] else None for _ in items)

View File

@ -223,7 +223,7 @@ class Agent(object):
_ = (
("[DELIMITER_START]", kb.chars.start), ("[DELIMITER_STOP]", kb.chars.stop),\
("[AT_REPLACE]", kb.chars.at), ("[SPACE_REPLACE]", kb.chars.space), ("[DOLLAR_REPLACE]", kb.chars.dollar),\
("[HASH_REPLACE]", kb.chars.hash_)
("[HASH_REPLACE]", kb.chars.hash_),
)
payload = reduce(lambda x, y: x.replace(y[0], y[1]), _, payload)

View File

@ -22,7 +22,7 @@ _defaults = {
"risk": 1,
"dumpFormat": "CSV",
"tech": "BEUSTQ",
"torType": "HTTP"
}
"torType": "HTTP",
}
defaults = AttribDict(_defaults)

View File

@ -34,7 +34,7 @@ FIREBIRD_TYPES = {
"12": "DATE",
"13": "TIME",
"35": "TIMESTAMP",
"37": "VARCHAR"
"37": "VARCHAR",
}
SYBASE_TYPES = {
@ -109,7 +109,7 @@ FIREBIRD_PRIVS = {
"U": "UPDATE",
"D": "DELETE",
"R": "REFERENCES",
"E": "EXECUTE"
"E": "EXECUTE",
}
DB2_PRIVS = {
@ -120,7 +120,7 @@ DB2_PRIVS = {
5: "INSERTAUTH",
6: "REFAUTH",
7: "SELECTAUTH",
8: "UPDATEAUTH"
8: "UPDATEAUTH",
}
DUMP_REPLACEMENTS = {" ": NULL, "": BLANK}
@ -135,7 +135,7 @@ DBMS_DICT = {
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.DB2: (DB2_ALIASES, "python ibm-db", "http://code.google.com/p/ibm-db/"),
}
FROM_DUMMY_TABLE = {
@ -143,7 +143,7 @@ FROM_DUMMY_TABLE = {
DBMS.ACCESS: " FROM MSysAccessObjects",
DBMS.FIREBIRD: " FROM RDB$DATABASE",
DBMS.MAXDB: " FROM VERSIONS",
DBMS.DB2: " FROM SYSIBM.SYSDUMMY1"
DBMS.DB2: " FROM SYSIBM.SYSDUMMY1",
}
SQL_STATEMENTS = {
@ -199,7 +199,9 @@ POST_HINT_CONTENT_TYPES = {
POST_HINT.JSON: "application/json",
POST_HINT.MULTIPART: "multipart/form-data",
POST_HINT.SOAP: "application/soap+xml",
POST_HINT.XML: "application/xml"
POST_HINT.XML: "application/xml",
}
DEPRECATED_HINTS = {"--replicate": "use '--dump-format=SQLITE' instead"}
DEPRECATED_HINTS = {
"--replicate": "use '--dump-format=SQLITE' instead",
}

View File

@ -178,7 +178,7 @@ class PAYLOAD:
3: "UNION query",
4: "stacked queries",
5: "AND/OR time-based blind",
6: "inline query"
6: "inline query",
}
PARAMETER = {
@ -186,14 +186,14 @@ class PAYLOAD:
2: "Single quoted string",
3: "LIKE single quoted string",
4: "Double quoted string",
5: "LIKE double quoted string"
5: "LIKE double quoted string",
}
RISK = {
0: "No risk",
1: "Low risk",
2: "Medium risk",
3: "High risk"
3: "High risk",
}
CLAUSE = {
@ -205,7 +205,7 @@ class PAYLOAD:
5: "OFFSET",
6: "TOP",
7: "Table name",
8: "Column name"
8: "Column name",
}
class METHOD:

View File

@ -244,7 +244,7 @@ def _feedTargetsDict(reqFile, addedTargetUrls):
else:
scheme, port = None, None
if not re.search (r"^[\n]*(GET|POST).*?\sHTTP\/", request, re.I | re.M):
if not re.search(r"^[\n]*(GET|POST).*?\sHTTP\/", request, re.I | re.M):
continue
if re.search(r"^[\n]*(GET|POST).*?\.(%s)\sHTTP\/" % "|".join(CRAWL_EXCLUDE_EXTENSIONS), request, re.I | re.M):
@ -353,6 +353,7 @@ def _loadQueries():
class DictObject(object):
def __init__(self):
self.__dict__ = {}
def __contains__(self, name):
return name in self.__dict__
@ -1247,7 +1248,7 @@ def _setHTTPUserAgent():
if count == 1:
userAgent = kb.userAgents[0]
else:
userAgent = kb.userAgents[randomRange(stop=count-1)]
userAgent = kb.userAgents[randomRange(stop=count - 1)]
userAgent = sanitizeStr(userAgent)
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, userAgent))
@ -1821,7 +1822,7 @@ class LogRecorder(logging.StreamHandler):
"""
self.loghist.append({'levelname': record.levelname,
'text': record.msg % record.args if record.args else record.msg,
'id': len(self.loghist)+1})
'id': len(self.loghist) + 1})
if conf.fdLog:
# TODO: this is very heavy operation and slows down a lot the
@ -2009,7 +2010,7 @@ def _basicOptionValidation():
errMsg = "maximum number of used threads is %d avoiding possible connection issues" % MAX_NUMBER_OF_THREADS
raise SqlmapSyntaxException(errMsg)
if conf.forms and not any ((conf.url, conf.bulkFile)):
if conf.forms and not any((conf.url, conf.bulkFile)):
errMsg = "switch '--forms' requires usage of option '-u' (--url) or '-m'"
raise SqlmapSyntaxException(errMsg)

View File

@ -18,7 +18,7 @@ optDict = {
"requestFile": "string",
"sessionFile": "string",
"googleDork": "string",
"configFile": "string"
"configFile": "string",
},
"Request": {
@ -47,7 +47,7 @@ optDict = {
"safUrl": "string",
"saFreq": "integer",
"skipUrlEncode": "boolean",
"evalCode": "string"
"evalCode": "string",
},
"Optimization": {
@ -55,7 +55,7 @@ optDict = {
"predictOutput": "boolean",
"keepAlive": "boolean",
"nullConnection": "boolean",
"threads": "integer"
"threads": "integer",
},
"Injection": {
@ -69,7 +69,7 @@ optDict = {
"prefix": "string",
"suffix": "string",
"skip": "string",
"tamper": "string"
"tamper": "string",
},
"Detection": {
@ -80,7 +80,7 @@ optDict = {
"regexp": "string",
"code": "integer",
"textOnly": "boolean",
"titles": "boolean"
"titles": "boolean",
},
"Techniques": {
@ -89,11 +89,11 @@ optDict = {
"uCols": "string",
"uChar": "string",
"dnsName": "string",
"secondOrder": "string"
"secondOrder": "string",
},
"Fingerprint": {
"extensiveFp": "boolean"
"extensiveFp": "boolean",
},
"Enumeration": {
@ -126,23 +126,23 @@ optDict = {
"lastChar": "integer",
"query": "string",
"sqlShell": "boolean",
"sqlFile": "string"
"sqlFile": "string",
},
"Brute": {
"commonTables": "boolean",
"commonColumns": "boolean"
"commonColumns": "boolean",
},
"User-defined function": {
"udfInject": "boolean",
"shLib": "string"
"shLib": "string",
},
"File system": {
"rFile": "string",
"wFile": "string",
"dFile": "string"
"dFile": "string",
},
"Takeover": {
@ -153,7 +153,7 @@ optDict = {
"osBof": "boolean",
"privEsc": "boolean",
"msfPath": "string",
"tmpPath": "string"
"tmpPath": "string",
},
"Windows": {
@ -163,7 +163,7 @@ optDict = {
"regKey": "string",
"regVal": "string",
"regData": "string",
"regType": "string"
"regType": "string",
},
"General": {
@ -208,7 +208,7 @@ optDict = {
"smart": "boolean",
"testFilter": "string",
"wizard": "boolean",
"verbose": "integer"
"verbose": "integer",
},
"Hidden": {
"profile": "boolean",
@ -217,6 +217,6 @@ optDict = {
"smokeTest": "boolean",
"liveTest": "boolean",
"stopFail": "boolean",
"runCase": "string"
"runCase": "string",
}
}

View File

@ -201,7 +201,7 @@ BASIC_HELP_ITEMS = (
"checkTor",
"flushSession",
"tor",
"wizard"
"wizard",
)
# String representation for NULL value
@ -218,7 +218,7 @@ ERROR_PARSING_REGEXES = (
r"<b>[^<]*(fatal|error|warning|exception)[^<]*</b>:?\s*(?P<result>.+?)<br\s*/?\s*>",
r"(?m)^(fatal|error|warning|exception):?\s*(?P<result>.+?)$",
r"<li>Error Type:<br>(?P<result>.+?)</li>",
r"error '[0-9a-f]{8}'((<[^>]+>)|\s)+(?P<result>[^<>]+)"
r"error '[0-9a-f]{8}'((<[^>]+>)|\s)+(?P<result>[^<>]+)",
)
# Regular expression used for parsing charset info from meta html headers

View File

@ -49,7 +49,7 @@ def blockingReadFromFD(fd):
break
if not output:
raise EOFError("fd %s has been closed." % fd )
raise EOFError("fd %s has been closed." % fd)
return output

View File

@ -517,7 +517,7 @@ def cmdLineParser():
# General options
general = OptionGroup(parser, "General", "These options can be used "
"to set some general working parameters" )
"to set some general working parameters")
#general.add_option("-x", dest="xmlFile",
# help="Dump the data into an XML file")

View File

@ -30,7 +30,7 @@ def headersParser(headers):
"servlet-engine": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "servlet.xml"),
"set-cookie": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "cookie.xml"),
"x-aspnet-version": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-aspnet-version.xml"),
"x-powered-by": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-powered-by.xml")
"x-powered-by": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-powered-by.xml"),
}
for header in itertools.ifilter(lambda x: x in kb.headerPaths, headers):

View File

@ -111,7 +111,7 @@ def checkCharEncoding(encoding, warn=True):
return encoding
# Reference: http://www.destructor.de/charsets/index.htm
translate = { "windows-874": "iso-8859-11", "en_us": "utf8", "macintosh": "iso-8859-1", "euc_tw": "big5_tw", "th": "tis-620", "unicode": "utf8", "utc8": "utf8", "ebcdic": "ebcdic-cp-be"}
translate = {"windows-874": "iso-8859-11", "en_us": "utf8", "macintosh": "iso-8859-1", "euc_tw": "big5_tw", "th": "tis-620", "unicode": "utf8", "utc8": "utf8", "ebcdic": "ebcdic-cp-be"}
for delimiter in (';', ',', '('):
if delimiter in encoding:

View File

@ -86,7 +86,7 @@ class Metasploit:
2: ("Reverse TCP: Try to connect back from the database host to this machine, on all ports between the specified and 65535", "reverse_tcp_allports"),
3: ("Reverse HTTP: Connect back from the database host to this machine tunnelling traffic over HTTP", "reverse_http"),
4: ("Reverse HTTPS: Connect back from the database host to this machine tunnelling traffic over HTTPS", "reverse_https"),
5: ("Bind TCP: Listen on the database host for a connection", "bind_tcp")
5: ("Bind TCP: Listen on the database host for a connection", "bind_tcp"),
},
"linux": {
1: ("Reverse TCP: Connect back from the database host to this machine (default)", "reverse_tcp"),

View File

@ -33,17 +33,17 @@ class Registry:
self._batRead = (
"@ECHO OFF\r\n",
readParse
readParse,
)
self._batAdd = (
"@ECHO OFF\r\n",
"REG ADD \"%s\" /v \"%s\" /t %s /d %s /f" % (self._regKey, self._regValue, self._regType, self._regData)
"REG ADD \"%s\" /v \"%s\" /t %s /d %s /f" % (self._regKey, self._regValue, self._regType, self._regData),
)
self._batDel = (
"@ECHO OFF\r\n",
"REG DELETE \"%s\" /v \"%s\" /f" % (self._regKey, self._regValue)
"REG DELETE \"%s\" /v \"%s\" /f" % (self._regKey, self._regValue),
)
def _createLocalBatchFile(self):

View File

@ -28,7 +28,10 @@ class _GetchUnix(object):
import tty
def __call__(self):
import sys, tty, termios
import sys
import termios
import tty
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:

View File

@ -298,7 +298,7 @@ __functions__ = {
HASH.MD5_GENERIC: md5_generic_passwd,
HASH.SHA1_GENERIC: sha1_generic_passwd,
HASH.CRYPT_GENERIC: crypt_generic_passwd,
HASH.WORDPRESS: wordpress_passwd
HASH.WORDPRESS: wordpress_passwd,
}
def storeHashesToFile(attack_dict):

View File

@ -52,7 +52,7 @@ class Fingerprint(GenericFingerprint):
"97": ("MSysModules2", "MSysAccessObjects"),
"2000" : ("!MSysModules2", "MSysAccessObjects"),
"2002-2003" : ("MSysAccessStorage", "!MSysNavPaneObjectIDs"),
"2007" : ("MSysAccessStorage", "MSysNavPaneObjectIDs")
"2007" : ("MSysAccessStorage", "MSysNavPaneObjectIDs"),
}
# MSysAccessXML is not a reliable system table because it doesn't always exist
# ("Access through Access", p6, should be "normally doesn't exist" instead of "is normally empty")

View File

@ -73,7 +73,7 @@ class Fingerprint(GenericFingerprint):
("1.0", ("EXISTS(SELECT CURRENT_USER FROM RDB$DATABASE)",)),
("1.5", ("NULLIF(%d,%d) IS NULL", "EXISTS(SELECT CURRENT_TRANSACTION FROM RDB$DATABASE)")),
("2.0", ("EXISTS(SELECT CURRENT_TIME(0) FROM RDB$DATABASE)", "BIT_LENGTH(%d)>0", "CHAR_LENGTH(%d)>0")),
("2.1", ("BIN_XOR(%d,%d)=0", "PI()>0.%d", "RAND()<1.%d", "FLOOR(1.%d)>=0"))
("2.1", ("BIN_XOR(%d,%d)=0", "PI()>0.%d", "RAND()<1.%d", "FLOOR(1.%d)>=0")),
)
for i in xrange(len(table)):

View File

@ -41,7 +41,7 @@ class Takeover(GenericTakeover):
#"2003-2": ("CHAR(0xe4)+CHAR(0x37)+CHAR(0xea)+CHAR(0x7c)", "CHAR(0x15)+CHAR(0xc9)+CHAR(0x93)+CHAR(0x7c)", "CHAR(0x96)+CHAR(0xdc)+CHAR(0xa7)+CHAR(0x7c)", "CHAR(0x73)+CHAR(0x1e)+CHAR(0x8f)+CHAR(0x7c)", "CHAR(0x73)+CHAR(0x1e)+CHAR(0x8f)+CHAR(0x7c)", "CHAR(0x17)+CHAR(0xf5)+CHAR(0x83)+CHAR(0x7c)", "CHAR(0x1b)+CHAR(0xa0)+CHAR(0x86)+CHAR(0x7c)", "CHAR(0x1b)+CHAR(0xa0)+CHAR(0x86)+CHAR(0x7c)" ),
# 2003 Service Pack 2 updated at 05/2009
"2003-2": ("CHAR(0xc3)+CHAR(0xdb)+CHAR(0x67)+CHAR(0x77)", "CHAR(0x15)+CHAR(0xc9)+CHAR(0x93)+CHAR(0x7c)", "CHAR(0x96)+CHAR(0xdc)+CHAR(0xa7)+CHAR(0x7c)", "CHAR(0x73)+CHAR(0x1e)+CHAR(0x8f)+CHAR(0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