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

Skip to content

Commit a6c26fe

Browse files
zellerinstamparm
authored andcommitted
Python 3 binary-character fixes for two urllib requests (#4077)
* Fix python3 binary - character mismatch in api.py Convert between text and binary data in api.py call to urllib.request and response from it. In python3 sqlmapapi -c it fixes, at least - not nice output from log/list commands - any command that POSTs data (including new) crashing sqlmapapi * Fix python3 binary - character mismatch in search.py Before: python3 sqlmap.py -g <long random string> (...) [18:35:17] [INFO] using search result page #1 no usable links found. What do you want to do? [1] (re)try with DuckDuckGo (default) [2] (re)try with Bing [3] quit > 1 [18:35:21] [CRITICAL] unable to connect After: python3 sqlmap.py -g asfafw2fwesvzsdvaw (...) [18:37:30] [INFO] using search result page #1 no usable links found. What do you want to do? [1] (re)try with DuckDuckGo (default) [2] (re)try with Bing [3] quit > 1 [18:37:34] [INFO] found 26 results for your search dork expression, 16 of them are testable targets [18:37:34] [INFO] found a total of 16 targets URL 1: GET https:... do you want to test this URL? [Y/n/q]
1 parent c082067 commit a6c26fe

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/utils/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,15 +713,15 @@ def _client(url, options=None):
713713
try:
714714
data = None
715715
if options is not None:
716-
data = jsonize(options)
716+
data = jsonize(options).encode("utf-8")
717717
headers = {"Content-Type": "application/json"}
718718

719719
if DataStore.username or DataStore.password:
720720
headers["Authorization"] = "Basic %s" % encodeBase64("%s:%s" % (DataStore.username or "", DataStore.password or ""), binary=False)
721721

722722
req = _urllib.request.Request(url, data, headers)
723723
response = _urllib.request.urlopen(req)
724-
text = response.read()
724+
text = response.read().decode("utf-8")
725725
except:
726726
if options:
727727
logger.error("Failed to load and parse %s" % url)

lib/utils/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _search(dork):
132132
regex = DUCKDUCKGO_REGEX
133133

134134
try:
135-
req = _urllib.request.Request(url, data=data, headers=requestHeaders)
135+
req = _urllib.request.Request(url, data=data.encode("utf-8"), headers=requestHeaders)
136136
conn = _urllib.request.urlopen(req)
137137

138138
requestMsg = "HTTP request:\nGET %s" % url

0 commit comments

Comments
 (0)