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

Skip to content

Commit 321cdde

Browse files
committed
DREI patch for --forms
1 parent c5a2567 commit 321cdde

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

lib/core/common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,13 +4232,13 @@ def findPageForms(content, url, raise_=False, addToTargets=False):
42324232
"""
42334233
Parses given page content for possible forms (Note: still not implemented for Python3)
42344234
4235-
>> findPageForms('<html><form action="/input.php" method="POST"><input type="text" name="id" value="1"><input type="submit" value="Submit"></form></html>', '')
4236-
set([(u'/input.php', 'POST', u'id=1', None, None)])
4235+
>>> findPageForms('<html><form action="/input.php" method="POST"><input type="text" name="id" value="1"><input type="submit" value="Submit"></form></html>', 'http://www.site.com') == set([('http://www.site.com/input.php', 'POST', 'id=1', None, None)])
4236+
True
42374237
"""
42384238

4239-
class _(io.BytesIO):
4239+
class _(six.StringIO):
42404240
def __init__(self, content, url):
4241-
io.BytesIO.__init__(self, getBytes(content, kb.pageEncoding))
4241+
six.StringIO.__init__(self, content)
42424242
self._url = url
42434243

42444244
def geturl(self):
@@ -4303,7 +4303,7 @@ def geturl(self):
43034303
else:
43044304
url = urldecode(request.get_full_url(), kb.pageEncoding)
43054305
method = request.get_method()
4306-
data = request.get_data() if request.has_data() else None
4306+
data = request.data
43074307
data = urldecode(data, kb.pageEncoding, spaceplus=False)
43084308

43094309
if not data and method and method.upper() == HTTPMETHOD.POST:

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty import six
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.30"
21+
VERSION = "1.3.5.31"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

thirdparty/clientform/clientform.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ def _show_debug_messages():
9494
_logger.addHandler(handler)
9595

9696
try:
97+
from thirdparty import six
9798
from thirdparty.six.moves import cStringIO as _cStringIO
9899
from thirdparty.six.moves import html_entities as _html_entities
99100
from thirdparty.six.moves import urllib as _urllib
100101
except ImportError:
102+
import six
101103
from six.moves import cStringIO as _cStringIO
102104
from six.moves import html_entities as _html_entities
103105
from six.moves import urllib as _urllib
@@ -173,7 +175,7 @@ def urlencode(query,doseq=False,):
173175
# non-sequence items should not work with len()
174176
x = len(query)
175177
# non-empty strings will fail this
176-
if len(query) and type(query[0]) != types.TupleType:
178+
if len(query) and type(query[0]) != tuple:
177179
raise TypeError()
178180
# zero-length sequences of all types will get here and succeed,
179181
# but that's a minor nit - since the original implementation
@@ -246,7 +248,7 @@ def unescape_charref(data, encoding):
246248
name, base= name[1:], 16
247249
elif not name.isdigit():
248250
base = 16
249-
uc = unichr(int(name, base))
251+
uc = six.unichr(int(name, base))
250252
if encoding is None:
251253
return uc
252254
else:
@@ -270,7 +272,7 @@ def get_entitydefs():
270272
entitydefs["&%s;" % name] = uc
271273
else:
272274
for name, codepoint in _html_entities.name2codepoint.items():
273-
entitydefs["&%s;" % name] = unichr(codepoint)
275+
entitydefs["&%s;" % name] = six.unichr(codepoint)
274276
return entitydefs
275277

276278

@@ -1126,7 +1128,7 @@ def _ParseFileEx(file, base_uri,
11261128
if action is None:
11271129
action = base_uri
11281130
else:
1129-
action = unicode(action, "utf8") if action and not isinstance(action, unicode) else action
1131+
action = six.text_type(action, "utf8") if action and isinstance(action, six.binary_type) else action
11301132
action = _urljoin(base_uri, action)
11311133
# would be nice to make HTMLForm class (form builder) pluggable
11321134
form = HTMLForm(
@@ -1321,8 +1323,8 @@ def __init__(self, type, name, attrs, index=None):
13211323
self.__dict__["type"] = type.lower()
13221324
self.__dict__["name"] = name
13231325
self._value = attrs.get("value")
1324-
self.disabled = attrs.has_key("disabled")
1325-
self.readonly = attrs.has_key("readonly")
1326+
self.disabled = "disabled" in attrs
1327+
self.readonly = "readonly" in attrs
13261328
self.id = attrs.get("id")
13271329

13281330
self.attrs = attrs.copy()
@@ -3398,6 +3400,7 @@ def _switch_click(self, return_type, request_class=_urllib.request.Request):
33983400
return self._request_data()
33993401
else:
34003402
req_data = self._request_data()
3403+
34013404
req = request_class(req_data[0], req_data[1])
34023405
for key, val in req_data[2]:
34033406
add_hdr = req.add_header

0 commit comments

Comments
 (0)