mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-09 14:11:29 +00:00
Some PEP8 related style cleaning
This commit is contained in:
@@ -758,7 +758,7 @@ class Agent(object):
|
||||
limitStr = queries[Backend.getIdentifiedDbms()].limit.query
|
||||
fromIndex = limitedQuery.index(" FROM ")
|
||||
untilFrom = limitedQuery[:fromIndex]
|
||||
fromFrom = limitedQuery[fromIndex+1:]
|
||||
fromFrom = limitedQuery[fromIndex + 1:]
|
||||
orderBy = False
|
||||
|
||||
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.SQLITE):
|
||||
@@ -766,7 +766,7 @@ class Agent(object):
|
||||
limitedQuery += " %s" % limitStr
|
||||
|
||||
elif Backend.isDbms(DBMS.FIREBIRD):
|
||||
limitStr = queries[Backend.getIdentifiedDbms()].limit.query % (num+1, num+1)
|
||||
limitStr = queries[Backend.getIdentifiedDbms()].limit.query % (num + 1, num + 1)
|
||||
limitedQuery += " %s" % limitStr
|
||||
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2):
|
||||
|
||||
@@ -560,7 +560,7 @@ def paramToDict(place, parameters=None):
|
||||
elif len(conf.testParameter) != len(testableParameters.keys()):
|
||||
for parameter in conf.testParameter:
|
||||
if parameter not in testableParameters:
|
||||
warnMsg = "provided parameter '%s' " % parameter
|
||||
warnMsg = "provided parameter '%s' " % parameter
|
||||
warnMsg += "is not inside the %s" % place
|
||||
logger.warn(warnMsg)
|
||||
|
||||
@@ -1489,7 +1489,7 @@ def getConsoleWidth(default=80):
|
||||
if os.getenv("COLUMNS", "").isdigit():
|
||||
width = int(os.getenv("COLUMNS"))
|
||||
else:
|
||||
output=execute('stty size', shell=True, stdout=PIPE, stderr=PIPE).stdout.read()
|
||||
output = execute("stty size", shell=True, stdout=PIPE, stderr=PIPE).stdout.read()
|
||||
items = output.split()
|
||||
|
||||
if len(items) == 2 and items[1].isdigit():
|
||||
|
||||
@@ -54,8 +54,8 @@ def md5hash(value):
|
||||
return md5.new(value).hexdigest()
|
||||
|
||||
def orddecode(value):
|
||||
packedString = struct.pack("!"+"I" * len(value), *value)
|
||||
return "".join(chr(char) for char in struct.unpack("!"+"I"*(len(packedString)/4), packedString))
|
||||
packedString = struct.pack("!" + "I" * len(value), *value)
|
||||
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)
|
||||
|
||||
@@ -7,7 +7,7 @@ See the file 'doc/COPYING' for copying permission
|
||||
|
||||
from lib.core.datatype import AttribDict
|
||||
|
||||
_defaults = {
|
||||
_defaults = {
|
||||
"csvDel": ",",
|
||||
"timeSec": 5,
|
||||
"googlePage": 1,
|
||||
@@ -23,6 +23,6 @@ _defaults = {
|
||||
"dumpFormat": "CSV",
|
||||
"tech": "BEUSTQ",
|
||||
"torType": "HTTP"
|
||||
}
|
||||
}
|
||||
|
||||
defaults = AttribDict(_defaults)
|
||||
|
||||
@@ -69,38 +69,38 @@ SYBASE_TYPES = {
|
||||
}
|
||||
|
||||
MYSQL_PRIVS = {
|
||||
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",
|
||||
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",
|
||||
}
|
||||
|
||||
PGSQL_PRIVS = {
|
||||
1:"createdb",
|
||||
2:"super",
|
||||
3:"catupd",
|
||||
1: "createdb",
|
||||
2: "super",
|
||||
3: "catupd",
|
||||
}
|
||||
|
||||
FIREBIRD_PRIVS = {
|
||||
|
||||
@@ -117,13 +117,13 @@ class Dump(object):
|
||||
if elements:
|
||||
self._write("")
|
||||
|
||||
def banner(self,data):
|
||||
def banner(self, data):
|
||||
self.string("banner", data)
|
||||
|
||||
def currentUser(self,data):
|
||||
def currentUser(self, data):
|
||||
self.string("current user", data)
|
||||
|
||||
def currentDb(self,data):
|
||||
def currentDb(self, data):
|
||||
if Backend.isDbms(DBMS.MAXDB):
|
||||
self.string("current database (no practical usage on %s)" % Backend.getIdentifiedDbms(), data)
|
||||
elif Backend.isDbms(DBMS.ORACLE):
|
||||
@@ -131,13 +131,13 @@ class Dump(object):
|
||||
else:
|
||||
self.string("current database", data)
|
||||
|
||||
def hostname(self,data):
|
||||
def hostname(self, data):
|
||||
self.string("hostname", data)
|
||||
|
||||
def dba(self,data):
|
||||
def dba(self, data):
|
||||
self.string("current user is DBA", data)
|
||||
|
||||
def users(self,users):
|
||||
def users(self, users):
|
||||
self.lister("database management system users", users)
|
||||
|
||||
def userSettings(self, header, userSettings, subHeader):
|
||||
@@ -174,7 +174,7 @@ class Dump(object):
|
||||
|
||||
self.singleString("")
|
||||
|
||||
def dbs(self,dbs):
|
||||
def dbs(self, dbs):
|
||||
self.lister("available databases", dbs)
|
||||
|
||||
def dbTables(self, dbTables):
|
||||
|
||||
@@ -272,7 +272,7 @@ def _feedTargetsDict(reqFile, addedTargetUrls):
|
||||
index = 5
|
||||
|
||||
url = line[index:line.index(" HTTP/")]
|
||||
method = line[:index-1]
|
||||
method = line[:index - 1]
|
||||
|
||||
if "?" in line and "=" in line:
|
||||
params = True
|
||||
@@ -587,7 +587,7 @@ def _findPageForms():
|
||||
for i in xrange(len(targets)):
|
||||
try:
|
||||
target = targets[i]
|
||||
page, _, _= Request.getPage(url=target.strip(), crawling=True, raise404=False)
|
||||
page, _, _ = Request.getPage(url=target.strip(), crawling=True, raise404=False)
|
||||
findPageForms(page, target, False, True)
|
||||
|
||||
if conf.verbose in (1, 2):
|
||||
@@ -942,7 +942,7 @@ def _setHTTPProxy():
|
||||
try:
|
||||
port = int(hostnamePort[1])
|
||||
except:
|
||||
pass #drops into the next check block
|
||||
pass # drops into the next check block
|
||||
|
||||
if not all((scheme, hasattr(PROXY_TYPE, scheme), hostname, port)):
|
||||
errMsg = "proxy value must be in format '(%s)://url:port'" % "|".join(_[0].lower() for _ in getPublicTypeMembers(PROXY_TYPE))
|
||||
@@ -1373,8 +1373,9 @@ def _cleanupOptions():
|
||||
conf.data = re.sub(INJECT_HERE_MARK.replace(" ", r"[^A-Za-z]*"), CUSTOM_INJECTION_MARK_CHAR, conf.data, re.I)
|
||||
|
||||
if re.search(r'%[0-9a-f]{2}', conf.data, re.I):
|
||||
class _(unicode):
|
||||
pass
|
||||
original = conf.data
|
||||
class _(unicode): pass
|
||||
conf.data = _(urldecode(conf.data))
|
||||
setattr(conf.data, UNENCODED_ORIGINAL_VALUE, original)
|
||||
else:
|
||||
@@ -1409,7 +1410,7 @@ def _cleanupOptions():
|
||||
conf.code = int(conf.code)
|
||||
|
||||
if conf.csvDel:
|
||||
conf.csvDel = conf.csvDel.decode("string_escape") # e.g. '\\t' -> '\t'
|
||||
conf.csvDel = conf.csvDel.decode("string_escape") # e.g. '\\t' -> '\t'
|
||||
|
||||
if conf.torPort and conf.torPort.isdigit():
|
||||
conf.torPort = int(conf.torPort)
|
||||
@@ -1504,7 +1505,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
|
||||
kb.authHeader = None
|
||||
kb.bannerFp = AttribDict()
|
||||
|
||||
kb.brute = AttribDict({"tables":[], "columns":[]})
|
||||
kb.brute = AttribDict({"tables": [], "columns": []})
|
||||
kb.bruteMode = False
|
||||
|
||||
kb.cache = AttribDict()
|
||||
@@ -1592,7 +1593,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
|
||||
kb.redirectChoice = None
|
||||
kb.redirectSetCookie = None
|
||||
kb.reflectiveMechanism = True
|
||||
kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS:0, REFLECTIVE_COUNTER.HIT:0}
|
||||
kb.reflectiveCounters = {REFLECTIVE_COUNTER.MISS: 0, REFLECTIVE_COUNTER.HIT: 0}
|
||||
kb.responseTimes = []
|
||||
kb.resumeValues = True
|
||||
kb.safeCharEncode = False
|
||||
|
||||
@@ -65,7 +65,7 @@ def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
|
||||
dotFilePointer = codecs.open(dotOutputFile, 'wt', UNICODE_ENCODING)
|
||||
parser = gprof2dot.PstatsParser(profileOutputFile)
|
||||
profile = parser.parse()
|
||||
profile.prune(0.5/100.0, 0.1/100.0)
|
||||
profile.prune(0.5 / 100.0, 0.1 / 100.0)
|
||||
dot = gprof2dot.DotWriter(dotFilePointer)
|
||||
dot.graph(profile, gprof2dot.TEMPERATURE_COLORMAP)
|
||||
dotFilePointer.close()
|
||||
|
||||
@@ -64,7 +64,7 @@ def purge(directory):
|
||||
except:
|
||||
pass
|
||||
|
||||
dirpaths.sort(cmp = lambda x, y: y.count(os.path.sep) - x.count(os.path.sep))
|
||||
dirpaths.sort(cmp=lambda x, y: y.count(os.path.sep) - x.count(os.path.sep))
|
||||
|
||||
logger.debug("renaming directory names to random values...")
|
||||
for dirpath in dirpaths:
|
||||
|
||||
@@ -61,7 +61,7 @@ class Replication(object):
|
||||
"""
|
||||
|
||||
if len(values) == len(self.columns):
|
||||
self.execute('INSERT INTO "%s" VALUES (%s)' % (self.name, ','.join(['?']*len(values))), safechardecode(values))
|
||||
self.execute('INSERT INTO "%s" VALUES (%s)' % (self.name, ','.join(['?'] * len(values))), safechardecode(values))
|
||||
else:
|
||||
errMsg = "wrong number of columns used in replicating insert"
|
||||
raise SqlmapValueException(errMsg)
|
||||
|
||||
@@ -234,7 +234,7 @@ EMPTY_FORM_FIELDS_REGEX = r'(&|\A)(?P<result>[^=]+=(&|\Z))'
|
||||
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")
|
||||
|
||||
# Reference: http://www.the-interweb.com/serendipity/index.php?/archives/94-A-brief-analysis-of-40,000-leaked-MySpace-passwords.html
|
||||
COMMON_PASSWORD_SUFFIXES += ("!", ".", "*", "!!", "?", ";", "..", "!!!", ",", "@")
|
||||
COMMON_PASSWORD_SUFFIXES += ("!", ".", "*", "!!", "?", ";", "..", "!!!", ", ", "@")
|
||||
|
||||
# Splitter used between requests in WebScarab log files
|
||||
WEBSCARAB_SPLITTER = "### Conversation"
|
||||
@@ -363,7 +363,7 @@ DUMMY_SQL_INJECTION_CHARS = ";()'"
|
||||
DUMMY_USER_INJECTION = r"(?i)[^\w](AND|OR)\s+[^\s]+[=><]"
|
||||
|
||||
# Extensions skipped by crawler
|
||||
CRAWL_EXCLUDE_EXTENSIONS = ("gif","jpg","jar","tif","bmp","war","ear","mpg","wmv","mpeg","scm","iso","dmp","dll","cab","so","avi","bin","exe","iso","tar","png","pdf","ps","mp3","zip","rar","gz")
|
||||
CRAWL_EXCLUDE_EXTENSIONS = ("gif", "jpg", "jar", "tif", "bmp", "war", "ear", "mpg", "wmv", "mpeg", "scm", "iso", "dmp", "dll", "cab", "so", "avi", "bin", "exe", "iso", "tar", "png", "pdf", "ps", "mp3", "zip", "rar", "gz")
|
||||
|
||||
# Template used for common table existence check
|
||||
BRUTE_TABLE_EXISTS_TEMPLATE = "EXISTS(SELECT %d FROM %s)"
|
||||
@@ -420,7 +420,7 @@ HASHDB_FLUSH_RETRIES = 3
|
||||
HASHDB_MILESTONE_VALUE = "cAWxkLYCQT" # r5129 "".join(random.sample(string.letters, 10))
|
||||
|
||||
# Warn user of possible delay due to large page dump in full UNION query injections
|
||||
LARGE_OUTPUT_THRESHOLD = 1024**2
|
||||
LARGE_OUTPUT_THRESHOLD = 1024 ** 2
|
||||
|
||||
# On huge tables there is a considerable slowdown if every row retrieval requires ORDER BY (most noticable in table dumping using ERROR injections)
|
||||
SLOW_ORDER_COUNT_THRESHOLD = 10000
|
||||
|
||||
@@ -142,7 +142,7 @@ class Popen(subprocess.Popen):
|
||||
try:
|
||||
written = os.write(self.stdin.fileno(), input)
|
||||
except OSError, why:
|
||||
if why[0] == errno.EPIPE: #broken pipe
|
||||
if why[0] == errno.EPIPE: # broken pipe
|
||||
return self._close('stdin')
|
||||
raise
|
||||
|
||||
@@ -155,7 +155,7 @@ class Popen(subprocess.Popen):
|
||||
|
||||
flags = fcntl.fcntl(conn, fcntl.F_GETFL)
|
||||
if not conn.closed:
|
||||
fcntl.fcntl(conn, fcntl.F_SETFL, flags| os.O_NONBLOCK)
|
||||
fcntl.fcntl(conn, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||
|
||||
try:
|
||||
if not select.select([conn], [], [], 0)[0]:
|
||||
@@ -175,7 +175,7 @@ class Popen(subprocess.Popen):
|
||||
def recv_some(p, t=.1, e=1, tr=5, stderr=0):
|
||||
if tr < 1:
|
||||
tr = 1
|
||||
x = time.time()+t
|
||||
x = time.time() + t
|
||||
y = []
|
||||
r = ''
|
||||
if stderr:
|
||||
@@ -189,7 +189,7 @@ def recv_some(p, t=.1, e=1, tr=5, stderr=0):
|
||||
elif r:
|
||||
y.append(r)
|
||||
else:
|
||||
time.sleep(max((x-time.time())/tr, 0))
|
||||
time.sleep(max((x - time.time()) / tr, 0))
|
||||
return ''.join(y)
|
||||
|
||||
def send_all(p, data):
|
||||
|
||||
@@ -131,7 +131,7 @@ def _setRequestParams():
|
||||
kb.processUserMarks = True if kb.postHint else kb.processUserMarks
|
||||
|
||||
if re.search(URI_INJECTABLE_REGEX, conf.url, re.I) and not any(map(lambda place: place in conf.parameters, [PLACE.GET, PLACE.POST])):
|
||||
warnMsg = "you've provided target url without any GET "
|
||||
warnMsg = "you've provided target url without any GET "
|
||||
warnMsg += "parameters (e.g. www.site.com/article.php?id=1) "
|
||||
warnMsg += "and without providing any POST parameters "
|
||||
warnMsg += "through --data option"
|
||||
|
||||
@@ -234,7 +234,7 @@ def runCase(switches=None, parse=None):
|
||||
logger.error("unhandled exception occurred ('%s')" % str(exception))
|
||||
tback = traceback.format_exc()
|
||||
retVal = False
|
||||
elif result is False: # if None, ignore
|
||||
elif result is False: # if None, ignore
|
||||
logger.error("the test did not run")
|
||||
retVal = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user