@@ -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