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

Skip to content

Commit 10be8a1

Browse files
committed
Fixes #3652
1 parent c4f09a8 commit 10be8a1

5 files changed

Lines changed: 22 additions & 12 deletions

File tree

lib/core/common.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,14 +2151,20 @@ def shellExec(cmd):
21512151
"""
21522152
Executes arbitrary shell command
21532153
2154-
>>> shellExec('echo 1').strip() == b'1'
2154+
>>> shellExec('echo 1').strip() == '1'
21552155
True
21562156
"""
21572157

2158+
retVal = ""
2159+
21582160
try:
2159-
return subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] or ""
2161+
retVal = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] or ""
21602162
except Exception as ex:
2161-
return six.text_type(ex)
2163+
retVal = getSafeExString(ex)
2164+
finally:
2165+
retVal = getText(retVal)
2166+
2167+
return retVal
21622168

21632169
def clearConsoleLine(forceOutput=False):
21642170
"""

lib/core/revision.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import re
1010
import subprocess
1111

12+
from lib.core.common import getText
13+
1214
def getRevisionNumber():
1315
"""
1416
Returns abbreviated commit hash number as retrieved with "git rev-parse --short HEAD"
@@ -50,7 +52,7 @@ def getRevisionNumber():
5052
try:
5153
process = subprocess.Popen("git rev-parse --verify HEAD", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
5254
stdout, _ = process.communicate()
53-
match = re.search(r"(?i)[0-9a-f]{32}", stdout or "")
55+
match = re.search(r"(?i)[0-9a-f]{32}", getText(stdout or ""))
5456
retVal = match.group(0) if match else None
5557
except:
5658
pass

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.80"
21+
VERSION = "1.3.5.81"
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)

lib/core/testing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def _thread():
8080
):
8181
cmd = "%s %s -u http://%s:%d/?id=1 --batch %s" % (sys.executable, os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.py"), address, port, options)
8282
output = shellExec(cmd)
83-
output = getUnicode(output)
8483

8584
if not all(check in output for check in checks):
8685
dataToStdout("---\n\n$ %s\n" % cmd)

lib/core/update.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from lib.core.common import dataToStdout
1818
from lib.core.common import getSafeExString
1919
from lib.core.common import getLatestRevision
20+
from lib.core.common import getText
2021
from lib.core.common import pollProcess
2122
from lib.core.common import readInput
2223
from lib.core.data import conf
@@ -106,23 +107,25 @@ def update():
106107
dataToStdout("\r[%s] [INFO] update in progress" % time.strftime("%X"))
107108

108109
try:
109-
process = subprocess.Popen("git checkout . && git pull %s HEAD" % GIT_REPOSITORY, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=paths.SQLMAP_ROOT_PATH.encode(sys.getfilesystemencoding() or UNICODE_ENCODING))
110+
process = subprocess.Popen("git checkout . && git pull %s HEAD" % GIT_REPOSITORY, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=paths.SQLMAP_ROOT_PATH.encode(sys.getfilesystemencoding() or UNICODE_ENCODING))
110111
pollProcess(process, True)
111-
stdout, stderr = process.communicate()
112+
output, _ = process.communicate()
112113
success = not process.returncode
113114
except (IOError, OSError) as ex:
114115
success = False
115-
stderr = getSafeExString(ex)
116+
output = getSafeExString(ex)
117+
finally:
118+
output = getText(output)
116119

117120
if success:
118-
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", getRevisionNumber()))
121+
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in output else "updated to", getRevisionNumber()))
119122
else:
120-
if "Not a git repository" in stderr:
123+
if "Not a git repository" in output:
121124
errMsg = "not a valid git repository. Please checkout the 'sqlmapproject/sqlmap' repository "
122125
errMsg += "from GitHub (e.g. 'git clone --depth 1 %s sqlmap')" % GIT_REPOSITORY
123126
logger.error(errMsg)
124127
else:
125-
logger.error("update could not be completed ('%s')" % re.sub(r"\W+", " ", stderr).strip())
128+
logger.error("update could not be completed ('%s')" % re.sub(r"\W+", " ", output).strip())
126129

127130
if not success:
128131
if IS_WIN:

0 commit comments

Comments
 (0)