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

Skip to content

Commit aecaa27

Browse files
committed
Minor refactoring
1 parent eb62397 commit aecaa27

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

lib/core/common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,15 @@ def normalizePath(filepath):
18091809

18101810
return retVal
18111811

1812+
def safeFilepathEncode(filepath):
1813+
retVal = filepath
1814+
1815+
if filepath and isinstance(filepath, unicode):
1816+
retVal = filepath.encode(sys.getfilesystemencoding() or UNICODE_ENCODING)
1817+
1818+
return retVal
1819+
1820+
18121821
def safeExpandUser(filepath):
18131822
"""
18141823
Patch for a Python Issue18171 (http://bugs.python.org/issue18171)

lib/core/option.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from lib.core.common import resetCookieJar
5555
from lib.core.common import runningAsAdmin
5656
from lib.core.common import safeExpandUser
57+
from lib.core.common import safeFilepathEncode
5758
from lib.core.common import saveConfig
5859
from lib.core.common import setColor
5960
from lib.core.common import setOptimize
@@ -734,8 +735,8 @@ def _setTamperingFunctions():
734735
for script in re.split(PARAMETER_SPLITTING_REGEX, conf.tamper):
735736
found = False
736737

737-
path = paths.SQLMAP_TAMPER_PATH.encode(sys.getfilesystemencoding() or UNICODE_ENCODING)
738-
script = script.strip().encode(sys.getfilesystemencoding() or UNICODE_ENCODING)
738+
path = safeFilepathEncode(paths.SQLMAP_TAMPER_PATH)
739+
script = safeFilepathEncode(script.strip())
739740

740741
try:
741742
if not script:
@@ -770,7 +771,7 @@ def _setTamperingFunctions():
770771
sys.path.insert(0, dirname)
771772

772773
try:
773-
module = __import__(filename[:-3].encode(sys.getfilesystemencoding() or UNICODE_ENCODING))
774+
module = __import__(safeFilepathEncode(filename[:-3]))
774775
except Exception as ex:
775776
raise SqlmapSyntaxException("cannot import tamper module '%s' (%s)" % (filename[:-3], getSafeExString(ex)))
776777

@@ -835,7 +836,7 @@ def _setPreprocessFunctions():
835836
for script in re.split(PARAMETER_SPLITTING_REGEX, conf.preprocess):
836837
found = False
837838

838-
script = script.strip().encode(sys.getfilesystemencoding() or UNICODE_ENCODING)
839+
script = safeFilepathEncode(script.strip())
839840

840841
try:
841842
if not script:
@@ -867,7 +868,7 @@ def _setPreprocessFunctions():
867868
sys.path.insert(0, dirname)
868869

869870
try:
870-
module = __import__(filename[:-3].encode(sys.getfilesystemencoding() or UNICODE_ENCODING))
871+
module = __import__(safeFilepathEncode(filename[:-3]))
871872
except Exception as ex:
872873
raise SqlmapSyntaxException("cannot import preprocess module '%s' (%s)" % (filename[:-3], getSafeExString(ex)))
873874

@@ -922,7 +923,7 @@ def _setWafFunctions():
922923
try:
923924
if filename[:-3] in sys.modules:
924925
del sys.modules[filename[:-3]]
925-
module = __import__(filename[:-3].encode(sys.getfilesystemencoding() or UNICODE_ENCODING))
926+
module = __import__(safeFilepathEncode(filename[:-3]))
926927
except ImportError as ex:
927928
raise SqlmapSyntaxException("cannot import WAF script '%s' (%s)" % (filename[:-3], getSafeExString(ex)))
928929

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

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

txt/checksum.md5

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py
3030
fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py
3131
ed7874be0d2d3802f3d20184f2b280d5 lib/core/agent.py
3232
a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py
33-
bebd1593691dd465304e09a9b1c62a71 lib/core/common.py
33+
35d8ff12885e0a068c9bff647b51062e lib/core/common.py
3434
de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py
3535
abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py
3636
f89512ef3ebea85611c5dde6c891b657 lib/core/datatype.py
@@ -43,14 +43,14 @@ f89512ef3ebea85611c5dde6c891b657 lib/core/datatype.py
4343
fb6be55d21a70765e35549af2484f762 lib/core/__init__.py
4444
18c896b157b03af716542e5fe9233ef9 lib/core/log.py
4545
947f41084e551ff3b7ef7dda2f25ef20 lib/core/optiondict.py
46-
aa327bbad1d25b60cd2a95b4846241eb lib/core/option.py
46+
3d950fa87b0affe86322ebeea67840b3 lib/core/option.py
4747
fe370021c6bc99daf44b2bfc0d1effb3 lib/core/patch.py
4848
4b12aa67fbf6c973d12e54cf9cb54ea0 lib/core/profiling.py
4949
d5ef43fe3cdd6c2602d7db45651f9ceb lib/core/readlineng.py
5050
7d8a22c582ad201f65b73225e4456170 lib/core/replication.py
5151
3179d34f371e0295dd4604568fb30bcd lib/core/revision.py
5252
d6269c55789f78cf707e09a0f5b45443 lib/core/session.py
53-
c5129be9a3bf208a709866d00fb71a29 lib/core/settings.py
53+
abff68fd8e863af65ce39b56d460a173 lib/core/settings.py
5454
4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py
5555
10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py
5656
d9483455ff80d33a55db46ae2fa34a05 lib/core/target.py

0 commit comments

Comments
 (0)