(self, exitfunc, format, extra, encode)
| 581 | pass |
| 582 | |
| 583 | def createMsfShellcode(self, exitfunc, format, extra, encode): |
| 584 | infoMsg = "creating Metasploit Framework multi-stage shellcode " |
| 585 | logger.info(infoMsg) |
| 586 | |
| 587 | self._randStr = randomStr(lowercase=True) |
| 588 | self._shellcodeFilePath = os.path.join(conf.outputPath, "tmpm%s" % self._randStr) |
| 589 | |
| 590 | Metasploit._initVars(self) |
| 591 | self._prepareIngredients(encode=encode) |
| 592 | self._forgeMsfPayloadCmd(exitfunc, format, self._shellcodeFilePath, extra) |
| 593 | |
| 594 | logger.debug("executing local command: %s" % self._payloadCmd) |
| 595 | process = execute(self._payloadCmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False) |
| 596 | |
| 597 | dataToStdout("\r[%s] [INFO] creation in progress " % time.strftime("%X")) |
| 598 | pollProcess(process) |
| 599 | payloadStderr = process.communicate()[1] |
| 600 | |
| 601 | match = re.search(b"(Total size:|Length:|succeeded with size|Final size of exe file:) ([\\d]+)", payloadStderr) |
| 602 | |
| 603 | if match: |
| 604 | payloadSize = int(match.group(2)) |
| 605 | |
| 606 | if extra == "BufferRegister=EAX": |
| 607 | payloadSize = payloadSize // 2 |
| 608 | |
| 609 | debugMsg = "the shellcode size is %d bytes" % payloadSize |
| 610 | logger.debug(debugMsg) |
| 611 | else: |
| 612 | errMsg = "failed to create the shellcode ('%s')" % getText(payloadStderr).replace("\n", " ").replace("\r", "") |
| 613 | raise SqlmapFilePathException(errMsg) |
| 614 | |
| 615 | self._shellcodeFP = open(self._shellcodeFilePath, "rb") |
| 616 | self.shellcodeString = getText(self._shellcodeFP.read()) |
| 617 | self._shellcodeFP.close() |
| 618 | |
| 619 | os.unlink(self._shellcodeFilePath) |
| 620 | |
| 621 | def uploadShellcodeexec(self, web=False): |
| 622 | self.shellcodeexecLocal = os.path.join(paths.SQLMAP_EXTRAS_PATH, "shellcodeexec") |
no test coverage detected