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

Skip to content

Commit e48181e

Browse files
committed
another attempt to fix the stall during regression test
1 parent 138a846 commit e48181e

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

extra/shutils/regressiontest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def main():
7777
if stderr:
7878
failure_email("Update of sqlmap failed with error:\n\n%s" % stderr)
7979

80-
regressionproc = subprocess.Popen("python /opt/sqlmap/sqlmap.py --live-test", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
80+
regressionproc = subprocess.Popen("python /opt/sqlmap/sqlmap.py --live-test", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False)
8181
stdout, stderr = regressionproc.communicate()
8282

8383
if stderr:

lib/takeover/metasploit.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def _runMsfCliSmbrelay(self):
380380
logger.info(infoMsg)
381381

382382
logger.debug("executing local command: %s" % self._cliCmd)
383-
self._msfCliProc = execute(self._cliCmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
383+
self._msfCliProc = execute(self._cliCmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
384384

385385
def _runMsfCli(self, exitfunc):
386386
self._forgeMsfCliCmd(exitfunc)
@@ -390,7 +390,7 @@ def _runMsfCli(self, exitfunc):
390390
logger.info(infoMsg)
391391

392392
logger.debug("executing local command: %s" % self._cliCmd)
393-
self._msfCliProc = execute(self._cliCmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
393+
self._msfCliProc = execute(self._cliCmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
394394

395395
def _runMsfShellcodeRemote(self):
396396
infoMsg = "running Metasploit Framework shellcode "
@@ -481,7 +481,7 @@ def _controlMsfCmd(self, proc, func):
481481
if len(inp) > 0:
482482
try:
483483
send_all(proc, inp)
484-
except IOError:
484+
except (EOFError, IOError):
485485
# Probably the child has exited
486486
pass
487487
else:
@@ -490,7 +490,7 @@ def _controlMsfCmd(self, proc, func):
490490
if stdin_fd in ready_fds[0]:
491491
try:
492492
send_all(proc, blockingReadFromFD(stdin_fd))
493-
except IOError:
493+
except (EOFError, IOError):
494494
# Probably the child has exited
495495
pass
496496

@@ -528,10 +528,8 @@ def _controlMsfCmd(self, proc, func):
528528
elif conf.liveTest and time.time() - start_time > METASPLOIT_SESSION_TIMEOUT:
529529
proc.kill()
530530

531-
except EOFError:
532-
returncode = proc.wait()
533-
534-
return returncode
531+
except (EOFError, IOError):
532+
return proc.returncode
535533

536534
def createMsfShellcode(self, exitfunc, format, extra, encode):
537535
infoMsg = "creating Metasploit Framework multi-stage shellcode "
@@ -545,7 +543,7 @@ def createMsfShellcode(self, exitfunc, format, extra, encode):
545543
self._forgeMsfPayloadCmd(exitfunc, format, self._shellcodeFilePath, extra)
546544

547545
logger.debug("executing local command: %s" % self._payloadCmd)
548-
process = execute(self._payloadCmd, shell=True, stdout=None, stderr=PIPE)
546+
process = execute(self._payloadCmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
549547

550548
dataToStdout("\r[%s] [INFO] creation in progress " % time.strftime("%X"))
551549
pollProcess(process)

0 commit comments

Comments
 (0)