Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/metasploit/msfrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,15 @@ def execute(self, **kwargs):
if isinstance(self, ExploitModule):
payload = kwargs.get('payload')
runopts['TARGET'] = self.target
"""
Define Runtime Options set as part of the execution argument
- For use when a payload requires additional options that can
- not be set as part of the exploit, for instance LHOST and LPORT
- for a meterpreter/reverse_tcp session. Add more lines for extra
- options
"""
if kwargs.get('LHOST'): runopts['LHOST'] = kwargs.get('LHOST')
if kwargs.get('LPORT'): runopts['LPORT'] = kwargs.get('LPORT')
if 'DisablePayloadHandler' in runopts and runopts['DisablePayloadHandler']:
pass
elif payload is None:
Expand Down
28 changes: 28 additions & 0 deletions src/metasploit/msfrpcdHandler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Handles the MetaSploit Framework Remote Procedure Call Daemon (MSFRPCD) for *nix machines

import os, psutil, signal, time

def msfrpcdStart(password):
if checkMsfrpcdRunning(): return "MetaSploit Framework Remote Procedure Call Daemon is already running."
else:
response = os.system("msfrpcd -P "+password+" -n -a 127.0.0.1")
time.sleep(10)
if checkMsfrpcdRunning(): return "MetaSploit Framework Remote Procedure Call Daemon running."
else: return "There was an issue: MetaSploit Framework Remote Procedure Call Daemon did not start."

def checkMsfrpcdRunning():
for socket in psutil.net_connections():
if socket.laddr[1] == 55553: return socket.pid

def msfrpcdRestart(password):
pid = checkMsfrpcdRunning()
if pid:
os.kill(socket.pid, signal.SIGKILL)
print "Old MSFRPCD process killed."
response = os.system("msfrpcd -P "+password+" -n -a 127.0.0.1")
time.sleep(10)
if checkMsfrpcdRunning(): return "MetaSploit Framework Remote Procedure Call Daemon running."
else: return "There was an issue: MetaSploit Framework Remote Procedure Call Daemon did not start."

if __name__ == "__main__":
print msfrpcdStart('pass123')