mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 09:36:35 +03:00
minor refactoring
This commit is contained in:
parent
81bd9a201b
commit
41b60b26fc
|
@ -621,7 +621,7 @@ class Tag(PageElement):
|
||||||
self._getAttrMap()
|
self._getAttrMap()
|
||||||
self.attrMap[key] = value
|
self.attrMap[key] = value
|
||||||
found = False
|
found = False
|
||||||
for i in range(0, len(self.attrs)):
|
for i in xrange(0, len(self.attrs)):
|
||||||
if self.attrs[i][0] == key:
|
if self.attrs[i][0] == key:
|
||||||
self.attrs[i] = (key, value)
|
self.attrs[i] = (key, value)
|
||||||
found = True
|
found = True
|
||||||
|
@ -664,7 +664,7 @@ class Tag(PageElement):
|
||||||
return True
|
return True
|
||||||
if not hasattr(other, 'name') or not hasattr(other, 'attrs') or not hasattr(other, 'contents') or self.name != other.name or self.attrs != other.attrs or len(self) != len(other):
|
if not hasattr(other, 'name') or not hasattr(other, 'attrs') or not hasattr(other, 'contents') or self.name != other.name or self.attrs != other.attrs or len(self) != len(other):
|
||||||
return False
|
return False
|
||||||
for i in range(0, len(self.contents)):
|
for i in xrange(0, len(self.contents)):
|
||||||
if self.contents[i] != other.contents[i]:
|
if self.contents[i] != other.contents[i]:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -1267,14 +1267,14 @@ class BeautifulStoneSoup(Tag, SGMLParser):
|
||||||
|
|
||||||
numPops = 0
|
numPops = 0
|
||||||
mostRecentTag = None
|
mostRecentTag = None
|
||||||
for i in range(len(self.tagStack)-1, 0, -1):
|
for i in xrange(len(self.tagStack)-1, 0, -1):
|
||||||
if name == self.tagStack[i].name:
|
if name == self.tagStack[i].name:
|
||||||
numPops = len(self.tagStack)-i
|
numPops = len(self.tagStack)-i
|
||||||
break
|
break
|
||||||
if not inclusivePop:
|
if not inclusivePop:
|
||||||
numPops = numPops - 1
|
numPops = numPops - 1
|
||||||
|
|
||||||
for i in range(0, numPops):
|
for i in xrange(0, numPops):
|
||||||
mostRecentTag = self.popTag()
|
mostRecentTag = self.popTag()
|
||||||
return mostRecentTag
|
return mostRecentTag
|
||||||
|
|
||||||
|
@ -1301,7 +1301,7 @@ class BeautifulStoneSoup(Tag, SGMLParser):
|
||||||
isResetNesting = self.RESET_NESTING_TAGS.has_key(name)
|
isResetNesting = self.RESET_NESTING_TAGS.has_key(name)
|
||||||
popTo = None
|
popTo = None
|
||||||
inclusive = True
|
inclusive = True
|
||||||
for i in range(len(self.tagStack)-1, 0, -1):
|
for i in xrange(len(self.tagStack)-1, 0, -1):
|
||||||
p = self.tagStack[i]
|
p = self.tagStack[i]
|
||||||
if (not p or p.name == name) and not isNestable:
|
if (not p or p.name == name) and not isNestable:
|
||||||
#Non-nestable tags get popped to the top or to their
|
#Non-nestable tags get popped to the top or to their
|
||||||
|
@ -1579,7 +1579,7 @@ class BeautifulSoup(BeautifulStoneSoup):
|
||||||
contentTypeIndex = None
|
contentTypeIndex = None
|
||||||
tagNeedsEncodingSubstitution = False
|
tagNeedsEncodingSubstitution = False
|
||||||
|
|
||||||
for i in range(0, len(attrs)):
|
for i in xrange(0, len(attrs)):
|
||||||
key, value = attrs[i]
|
key, value = attrs[i]
|
||||||
key = key.lower()
|
key = key.lower()
|
||||||
if key == 'http-equiv':
|
if key == 'http-equiv':
|
||||||
|
@ -1968,7 +1968,7 @@ class UnicodeDammit:
|
||||||
250,251,252,253,254,255)
|
250,251,252,253,254,255)
|
||||||
import string
|
import string
|
||||||
c.EBCDIC_TO_ASCII_MAP = string.maketrans( \
|
c.EBCDIC_TO_ASCII_MAP = string.maketrans( \
|
||||||
''.join(map(chr, range(256))), ''.join(map(chr, emap)))
|
''.join(map(chr, xrange(256))), ''.join(map(chr, emap)))
|
||||||
return s.translate(c.EBCDIC_TO_ASCII_MAP)
|
return s.translate(c.EBCDIC_TO_ASCII_MAP)
|
||||||
|
|
||||||
MS_CHARS = { '\x80' : ('euro', '20AC'),
|
MS_CHARS = { '\x80' : ('euro', '20AC'),
|
||||||
|
|
|
@ -50,7 +50,7 @@ class EUCJPProber(MultiByteCharSetProber):
|
||||||
|
|
||||||
def feed(self, aBuf):
|
def feed(self, aBuf):
|
||||||
aLen = len(aBuf)
|
aLen = len(aBuf)
|
||||||
for i in range(0, aLen):
|
for i in xrange(0, aLen):
|
||||||
codingState = self._mCodingSM.next_state(aBuf[i])
|
codingState = self._mCodingSM.next_state(aBuf[i])
|
||||||
if codingState == eError:
|
if codingState == eError:
|
||||||
if constants._debug:
|
if constants._debug:
|
||||||
|
|
|
@ -51,7 +51,7 @@ class MultiByteCharSetProber(CharSetProber):
|
||||||
|
|
||||||
def feed(self, aBuf):
|
def feed(self, aBuf):
|
||||||
aLen = len(aBuf)
|
aLen = len(aBuf)
|
||||||
for i in range(0, aLen):
|
for i in xrange(0, aLen):
|
||||||
codingState = self._mCodingSM.next_state(aBuf[i])
|
codingState = self._mCodingSM.next_state(aBuf[i])
|
||||||
if codingState == eError:
|
if codingState == eError:
|
||||||
if constants._debug:
|
if constants._debug:
|
||||||
|
|
|
@ -50,7 +50,7 @@ class SJISProber(MultiByteCharSetProber):
|
||||||
|
|
||||||
def feed(self, aBuf):
|
def feed(self, aBuf):
|
||||||
aLen = len(aBuf)
|
aLen = len(aBuf)
|
||||||
for i in range(0, aLen):
|
for i in xrange(0, aLen):
|
||||||
codingState = self._mCodingSM.next_state(aBuf[i])
|
codingState = self._mCodingSM.next_state(aBuf[i])
|
||||||
if codingState == eError:
|
if codingState == eError:
|
||||||
if constants._debug:
|
if constants._debug:
|
||||||
|
|
|
@ -69,7 +69,7 @@ class UTF8Prober(CharSetProber):
|
||||||
def get_confidence(self):
|
def get_confidence(self):
|
||||||
unlike = 0.99
|
unlike = 0.99
|
||||||
if self._mNumOfMBChar < 6:
|
if self._mNumOfMBChar < 6:
|
||||||
for i in range(0, self._mNumOfMBChar):
|
for i in xrange(0, self._mNumOfMBChar):
|
||||||
unlike = unlike * ONE_CHAR_PROB
|
unlike = unlike * ONE_CHAR_PROB
|
||||||
return 1.0 - unlike
|
return 1.0 - unlike
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -384,7 +384,7 @@ class MimeWriter:
|
||||||
# 2.2 urllib2 doesn't normalize header case
|
# 2.2 urllib2 doesn't normalize header case
|
||||||
self._http_hdrs.append((key.capitalize(), value))
|
self._http_hdrs.append((key.capitalize(), value))
|
||||||
else:
|
else:
|
||||||
for i in range(1, len(lines)):
|
for i in xrange(1, len(lines)):
|
||||||
lines[i] = " " + lines[i].strip()
|
lines[i] = " " + lines[i].strip()
|
||||||
value = "\r\n".join(lines) + "\r\n"
|
value = "\r\n".join(lines) + "\r\n"
|
||||||
line = key.title() + ": " + value
|
line = key.title() + ": " + value
|
||||||
|
@ -1129,7 +1129,7 @@ def _ParseFileEx(file, base_uri,
|
||||||
forms, labels, id_to_labels, backwards_compat)
|
forms, labels, id_to_labels, backwards_compat)
|
||||||
form._urlparse = _urlparse
|
form._urlparse = _urlparse
|
||||||
form._urlunparse = _urlunparse
|
form._urlunparse = _urlunparse
|
||||||
for ii in range(len(controls)):
|
for ii in xrange(len(controls)):
|
||||||
type, name, attrs = controls[ii]
|
type, name, attrs = controls[ii]
|
||||||
# index=ii*10 allows ImageControl to return multiple ordered pairs
|
# index=ii*10 allows ImageControl to return multiple ordered pairs
|
||||||
form.new_control(
|
form.new_control(
|
||||||
|
@ -2020,7 +2020,7 @@ class ListControl(Control):
|
||||||
# always count nameless elements as separate controls
|
# always count nameless elements as separate controls
|
||||||
Control.add_to_form(self, form)
|
Control.add_to_form(self, form)
|
||||||
else:
|
else:
|
||||||
for ii in range(len(form.controls)-1, -1, -1):
|
for ii in xrange(len(form.controls)-1, -1, -1):
|
||||||
control = form.controls[ii]
|
control = form.controls[ii]
|
||||||
if control.name == self.name and control.type == self.type:
|
if control.name == self.name and control.type == self.type:
|
||||||
if control._closed:
|
if control._closed:
|
||||||
|
@ -2151,7 +2151,7 @@ class ListControl(Control):
|
||||||
names[nn] = 1
|
names[nn] = 1
|
||||||
for name, count in names.items():
|
for name, count in names.items():
|
||||||
on, off = self._get_items(name, count)
|
on, off = self._get_items(name, count)
|
||||||
for i in range(count):
|
for i in xrange(count):
|
||||||
if on:
|
if on:
|
||||||
item = on[0]
|
item = on[0]
|
||||||
del on[0]
|
del on[0]
|
||||||
|
@ -2850,7 +2850,7 @@ class HTMLForm:
|
||||||
control = klass(type, name, a, index)
|
control = klass(type, name, a, index)
|
||||||
|
|
||||||
if type == "select" and len(attrs) == 1:
|
if type == "select" and len(attrs) == 1:
|
||||||
for ii in range(len(self.controls)-1, -1, -1):
|
for ii in xrange(len(self.controls)-1, -1, -1):
|
||||||
ctl = self.controls[ii]
|
ctl = self.controls[ii]
|
||||||
if ctl.type == "select":
|
if ctl.type == "select":
|
||||||
ctl.close_control()
|
ctl.close_control()
|
||||||
|
@ -3333,7 +3333,7 @@ class HTMLForm:
|
||||||
control_index is the index of the control in self.controls
|
control_index is the index of the control in self.controls
|
||||||
"""
|
"""
|
||||||
pairs = []
|
pairs = []
|
||||||
for control_index in range(len(self.controls)):
|
for control_index in xrange(len(self.controls)):
|
||||||
control = self.controls[control_index]
|
control = self.controls[control_index]
|
||||||
for ii, key, val in control._totally_ordered_pairs():
|
for ii, key, val in control._totally_ordered_pairs():
|
||||||
pairs.append((ii, key, val, control_index))
|
pairs.append((ii, key, val, control_index))
|
||||||
|
|
|
@ -475,7 +475,7 @@ def _set_key(password):
|
||||||
|
|
||||||
k = [0] * (_ITERATIONS * 2)
|
k = [0] * (_ITERATIONS * 2)
|
||||||
|
|
||||||
for i in range(_ITERATIONS):
|
for i in xrange(_ITERATIONS):
|
||||||
# Only operates on top 28 bits.
|
# Only operates on top 28 bits.
|
||||||
if shifts2[i]:
|
if shifts2[i]:
|
||||||
c = (c >> 2) | (c << 26)
|
c = (c >> 2) | (c << 26)
|
||||||
|
@ -513,9 +513,9 @@ def _body(ks, E0, E1):
|
||||||
# Copy global variable into locals for loop.
|
# Copy global variable into locals for loop.
|
||||||
SP0, SP1, SP2, SP3, SP4, SP5, SP6, SP7 = _SPtrans
|
SP0, SP1, SP2, SP3, SP4, SP5, SP6, SP7 = _SPtrans
|
||||||
|
|
||||||
inner = range(0, _ITERATIONS*2, 2)
|
inner = xrange(0, _ITERATIONS*2, 2)
|
||||||
l = r = 0
|
l = r = 0
|
||||||
for j in range(25):
|
for j in xrange(25):
|
||||||
l,r = r,l
|
l,r = r,l
|
||||||
for i in inner:
|
for i in inner:
|
||||||
t = r ^ ((r >> 16) & 0xffff)
|
t = r ^ ((r >> 16) & 0xffff)
|
||||||
|
@ -602,7 +602,7 @@ crypt supported by the OpenBSD C library.
|
||||||
t2 >> 18 & 0x3f, t2 >> 12 & 0x3f, t2 >> 6 & 0x3f, t2 & 0x3f,
|
t2 >> 18 & 0x3f, t2 >> 12 & 0x3f, t2 >> 6 & 0x3f, t2 & 0x3f,
|
||||||
t3 >> 18 & 0x3f, t3 >> 12 & 0x3f, t3 >> 6 & 0x3f ]
|
t3 >> 18 & 0x3f, t3 >> 12 & 0x3f, t3 >> 6 & 0x3f ]
|
||||||
# Convert to characters.
|
# Convert to characters.
|
||||||
for i in range(len(r)):
|
for i in xrange(len(r)):
|
||||||
r[i] = _cov_2char[r[i]]
|
r[i] = _cov_2char[r[i]]
|
||||||
return salt[:2] + string.join(r, '')
|
return salt[:2] + string.join(r, '')
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ def updateMSSQLXML():
|
||||||
root = doc.createElement("root")
|
root = doc.createElement("root")
|
||||||
doc.appendChild(root)
|
doc.appendChild(root)
|
||||||
|
|
||||||
for index in range(0, releasesCount):
|
for index in xrange(0, releasesCount):
|
||||||
release = releases[index]
|
release = releases[index]
|
||||||
|
|
||||||
# Skip Microsoft SQL Server 6.5 because the HTML
|
# Skip Microsoft SQL Server 6.5 because the HTML
|
||||||
|
|
|
@ -23,16 +23,16 @@ def get_pagerank(url):
|
||||||
rank = '0'
|
rank = '0'
|
||||||
return rank
|
return rank
|
||||||
|
|
||||||
def int_str(string, integer, factor):
|
def int_str(string_, integer, factor):
|
||||||
for i in range(len(string)) :
|
for i in xrange(len(string_)) :
|
||||||
integer *= factor
|
integer *= factor
|
||||||
integer &= 0xFFFFFFFF
|
integer &= 0xFFFFFFFF
|
||||||
integer += ord(string[i])
|
integer += ord(string_[i])
|
||||||
return integer
|
return integer
|
||||||
|
|
||||||
def hash_url(string):
|
def hash_url(string_):
|
||||||
c1 = int_str(string, 0x1505, 0x21)
|
c1 = int_str(string_, 0x1505, 0x21)
|
||||||
c2 = int_str(string, 0, 0x1003F)
|
c2 = int_str(string_, 0, 0x1003F)
|
||||||
|
|
||||||
c1 >>= 2
|
c1 >>= 2
|
||||||
c1 = ((c1 >> 4) & 0x3FFFFC0) | (c1 & 0x3F)
|
c1 = ((c1 >> 4) & 0x3FFFFC0) | (c1 & 0x3F)
|
||||||
|
|
|
@ -40,7 +40,6 @@ def safecharencode(value):
|
||||||
retVal = value
|
retVal = value
|
||||||
|
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
|
|
||||||
retVal = retVal.replace('\\', SLASH_MARKER)
|
retVal = retVal.replace('\\', SLASH_MARKER)
|
||||||
|
|
||||||
for char in SAFE_ENCODE_SLASH_REPLACEMENTS:
|
for char in SAFE_ENCODE_SLASH_REPLACEMENTS:
|
||||||
|
|
|
@ -152,6 +152,9 @@ def htmlescape(value):
|
||||||
return value.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''').replace(' ', ' ')
|
return value.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''').replace(' ', ' ')
|
||||||
|
|
||||||
def htmlunescape(value):
|
def htmlunescape(value):
|
||||||
retVal = value.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace(''', "'").replace(' ', ' ')
|
retVal = value
|
||||||
retVal = re.sub('&#(\d+);', lambda x: unichr(int(x.group(1))), retVal)
|
if value and isinstance(value, basestring):
|
||||||
|
if '&' in retVal:
|
||||||
|
retVal = retVal.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace(' ', ' ')
|
||||||
|
retVal = re.sub('&#(\d+);', lambda x: unichr(int(x.group(1))), retVal)
|
||||||
return retVal
|
return retVal
|
||||||
|
|
|
@ -1389,10 +1389,7 @@ class Enumeration:
|
||||||
|
|
||||||
if not count:
|
if not count:
|
||||||
query = dumpNode.count % table
|
query = dumpNode.count % table
|
||||||
if blind:
|
count = inject.getValue(query, inband=False, error=False) if blind else count = inject.getValue(query, blind=False)
|
||||||
count = inject.getValue(query, inband=False, error=False)
|
|
||||||
else:
|
|
||||||
count = inject.getValue(query, blind=False)
|
|
||||||
|
|
||||||
if count == "0":
|
if count == "0":
|
||||||
infoMsg = "table '%s' appears to be empty" % table
|
infoMsg = "table '%s' appears to be empty" % table
|
||||||
|
@ -1403,6 +1400,7 @@ class Enumeration:
|
||||||
entries[column] = []
|
entries[column] = []
|
||||||
|
|
||||||
return entries, lengths
|
return entries, lengths
|
||||||
|
|
||||||
elif isNoneValue(count):
|
elif isNoneValue(count):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ def tamper(payload):
|
||||||
if payload:
|
if payload:
|
||||||
for i in xrange(len(payload)):
|
for i in xrange(len(payload)):
|
||||||
if payload[i].isspace():
|
if payload[i].isspace():
|
||||||
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for x in range(random.randint(6, 12)))
|
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for _ in xrange(random.randint(6, 12)))
|
||||||
retVal += "--%s%%0A" % randomStr
|
retVal += "--%s%%0A" % randomStr
|
||||||
elif payload[i] == '#' or payload[i:i+3] == '-- ':
|
elif payload[i] == '#' or payload[i:i+3] == '-- ':
|
||||||
retVal += payload[i:]
|
retVal += payload[i:]
|
||||||
|
|
|
@ -46,7 +46,7 @@ def tamper(payload):
|
||||||
if payload:
|
if payload:
|
||||||
for i in xrange(len(payload)):
|
for i in xrange(len(payload)):
|
||||||
if payload[i].isspace():
|
if payload[i].isspace():
|
||||||
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for x in range(random.randint(6, 12)))
|
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for _ in xrange(random.randint(6, 12)))
|
||||||
retVal += "%%23%s%%0A" % randomStr
|
retVal += "%%23%s%%0A" % randomStr
|
||||||
elif payload[i] == '#' or payload[i:i+3] == '-- ':
|
elif payload[i] == '#' or payload[i:i+3] == '-- ':
|
||||||
retVal += payload[i:]
|
retVal += payload[i:]
|
||||||
|
|
|
@ -46,7 +46,7 @@ def tamper(payload):
|
||||||
|
|
||||||
def process(match):
|
def process(match):
|
||||||
word = match.group('word')
|
word = match.group('word')
|
||||||
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for x in range(random.randint(6, 12)))
|
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for _ in xrange(random.randint(6, 12)))
|
||||||
|
|
||||||
if word.upper() in kb.keywords and word.upper() not in IGNORE_SPACE_AFFECTED_KEYWORDS:
|
if word.upper() in kb.keywords and word.upper() not in IGNORE_SPACE_AFFECTED_KEYWORDS:
|
||||||
return match.group().replace(word, "%s%%23%s%%0A" % (word, randomStr))
|
return match.group().replace(word, "%s%%23%s%%0A" % (word, randomStr))
|
||||||
|
@ -60,7 +60,7 @@ def tamper(payload):
|
||||||
|
|
||||||
for i in xrange(len(payload)):
|
for i in xrange(len(payload)):
|
||||||
if payload[i].isspace():
|
if payload[i].isspace():
|
||||||
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for x in range(random.randint(6, 12)))
|
randomStr = ''.join(random.choice(string.ascii_uppercase + string.lowercase) for _ in xrange(random.randint(6, 12)))
|
||||||
retVal += "%%23%s%%0A" % randomStr
|
retVal += "%%23%s%%0A" % randomStr
|
||||||
elif payload[i] == '#' or payload[i:i+3] == '-- ':
|
elif payload[i] == '#' or payload[i:i+3] == '-- ':
|
||||||
retVal += payload[i:]
|
retVal += payload[i:]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user