|
25 | 25 | from lib.core.common import isTechniqueAvailable |
26 | 26 | from lib.core.common import isWindowsDriveLetterPath |
27 | 27 | from lib.core.common import normalizePath |
| 28 | +from lib.core.common import openFile |
28 | 29 | from lib.core.common import parseFilePaths |
29 | 30 | from lib.core.common import posixToNtSlashes |
30 | 31 | from lib.core.common import randomInt |
|
34 | 35 | from lib.core.compat import xrange |
35 | 36 | from lib.core.convert import encodeHex |
36 | 37 | from lib.core.convert import getBytes |
| 38 | +from lib.core.convert import getText |
37 | 39 | from lib.core.data import conf |
38 | 40 | from lib.core.data import kb |
39 | 41 | from lib.core.data import logger |
@@ -274,9 +276,9 @@ def webInit(self): |
274 | 276 | directories = _ |
275 | 277 |
|
276 | 278 | backdoorName = "tmpb%s.%s" % (randomStr(lowercase=True), self.webPlatform) |
277 | | - backdoorContent = decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "backdoors", "backdoor.%s_" % self.webPlatform)) |
| 279 | + backdoorContent = getText(decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "backdoors", "backdoor.%s_" % self.webPlatform))) |
278 | 280 |
|
279 | | - stagerContent = decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform)) |
| 281 | + stagerContent = getText(decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform))) |
280 | 282 |
|
281 | 283 | for directory in directories: |
282 | 284 | if not directory: |
@@ -330,9 +332,9 @@ def webInit(self): |
330 | 332 | handle, filename = tempfile.mkstemp() |
331 | 333 | os.close(handle) |
332 | 334 |
|
333 | | - with open(filename, "w+b") as f: |
334 | | - _ = decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform)) |
335 | | - _ = _.replace(SHELL_WRITABLE_DIR_TAG, getBytes(directory.replace('/', '\\\\') if Backend.isOs(OS.WINDOWS) else directory)) |
| 335 | + with openFile(filename, "w+b") as f: |
| 336 | + _ = getText(decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform))) |
| 337 | + _ = _.replace(SHELL_WRITABLE_DIR_TAG, directory.replace('/', '\\\\') if Backend.isOs(OS.WINDOWS) else directory) |
336 | 338 | f.write(_) |
337 | 339 |
|
338 | 340 | self.unionWriteFile(filename, self.webStagerFilePath, "text", forceCheck=True) |
|
0 commit comments