|
54 | 54 | from lib.core.common import resetCookieJar |
55 | 55 | from lib.core.common import runningAsAdmin |
56 | 56 | from lib.core.common import safeExpandUser |
| 57 | +from lib.core.common import safeFilepathEncode |
57 | 58 | from lib.core.common import saveConfig |
58 | 59 | from lib.core.common import setColor |
59 | 60 | from lib.core.common import setOptimize |
@@ -734,8 +735,8 @@ def _setTamperingFunctions(): |
734 | 735 | for script in re.split(PARAMETER_SPLITTING_REGEX, conf.tamper): |
735 | 736 | found = False |
736 | 737 |
|
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()) |
739 | 740 |
|
740 | 741 | try: |
741 | 742 | if not script: |
@@ -770,7 +771,7 @@ def _setTamperingFunctions(): |
770 | 771 | sys.path.insert(0, dirname) |
771 | 772 |
|
772 | 773 | try: |
773 | | - module = __import__(filename[:-3].encode(sys.getfilesystemencoding() or UNICODE_ENCODING)) |
| 774 | + module = __import__(safeFilepathEncode(filename[:-3])) |
774 | 775 | except Exception as ex: |
775 | 776 | raise SqlmapSyntaxException("cannot import tamper module '%s' (%s)" % (filename[:-3], getSafeExString(ex))) |
776 | 777 |
|
@@ -835,7 +836,7 @@ def _setPreprocessFunctions(): |
835 | 836 | for script in re.split(PARAMETER_SPLITTING_REGEX, conf.preprocess): |
836 | 837 | found = False |
837 | 838 |
|
838 | | - script = script.strip().encode(sys.getfilesystemencoding() or UNICODE_ENCODING) |
| 839 | + script = safeFilepathEncode(script.strip()) |
839 | 840 |
|
840 | 841 | try: |
841 | 842 | if not script: |
@@ -867,7 +868,7 @@ def _setPreprocessFunctions(): |
867 | 868 | sys.path.insert(0, dirname) |
868 | 869 |
|
869 | 870 | try: |
870 | | - module = __import__(filename[:-3].encode(sys.getfilesystemencoding() or UNICODE_ENCODING)) |
| 871 | + module = __import__(safeFilepathEncode(filename[:-3])) |
871 | 872 | except Exception as ex: |
872 | 873 | raise SqlmapSyntaxException("cannot import preprocess module '%s' (%s)" % (filename[:-3], getSafeExString(ex))) |
873 | 874 |
|
@@ -922,7 +923,7 @@ def _setWafFunctions(): |
922 | 923 | try: |
923 | 924 | if filename[:-3] in sys.modules: |
924 | 925 | del sys.modules[filename[:-3]] |
925 | | - module = __import__(filename[:-3].encode(sys.getfilesystemencoding() or UNICODE_ENCODING)) |
| 926 | + module = __import__(safeFilepathEncode(filename[:-3])) |
926 | 927 | except ImportError as ex: |
927 | 928 | raise SqlmapSyntaxException("cannot import WAF script '%s' (%s)" % (filename[:-3], getSafeExString(ex))) |
928 | 929 |
|
|
0 commit comments