Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2741a93
Updated standard port
Jul 2, 2014
f2a77fd
fix bad chars in prompt
timwr Dec 3, 2015
d021b55
Create msfrpcdHandler.py
kyle-fd May 25, 2016
bb87472
Update msfrpc.py
kyle-fd May 26, 2016
9e65d75
Python 3 compatibility
nnamon Jun 5, 2016
4aac15d
Removed print
nnamon Jun 5, 2016
deeee19
changed httplib to http.client for python3
fallenbeck Jul 15, 2016
0a9b41e
Removed check for DisablePayloadHandler in msfrpc.
Sep 5, 2016
c8b6909
Merge remote-tracking branch 'remotes/kyle-fd/master'
peterclemenko Apr 26, 2017
693fc68
Merge remote-tracking branch 'remotes/fallenbeck/master'
peterclemenko Apr 26, 2017
28b199f
Merge remote-tracking branch 'remotes/72616e646f6d/master'
peterclemenko Apr 26, 2017
4b8f745
Merge remote-tracking branch 'remotes/ploq/master'
peterclemenko Apr 26, 2017
9616b58
Merge remote-tracking branch 'remotes/nnamon/master'
peterclemenko Apr 26, 2017
71f70bb
deleted bak files
peterclemenko Apr 26, 2017
5aca68c
fixed whitespace mismatch
peterclemenko Jul 17, 2017
e493c36
Don't try to set property attributes.
Jul 17, 2017
02673ad
remove ds store files
Jul 17, 2017
8ced22c
Merge pull request #2 from Mikaayenson/pull_request_module_info_fix
Mikaayenson Aug 5, 2017
337b7ef
Merge branch 'pr/3'
Mikaayenson Aug 5, 2017
12916fe
removing github desktop garbage
Mikaayenson Aug 5, 2017
3aef4ce
remove ds
Mikaayenson Aug 5, 2017
7ebfeb5
remove github desktop garbage
Mikaayenson Aug 5, 2017
d5c827f
changed http.client to httplib for py2
Mar 3, 2018
f3a082b
fixed attributeerror and console listings
Mar 3, 2018
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
6 changes: 3 additions & 3 deletions src/metasploit/msfconsole.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

from threading import Timer, Lock
from msfrpc import ShellSession
from .msfrpc import ShellSession

__author__ = 'Nadeem Douba'
__copyright__ = 'Copyright 2012, PyMetasploit Project'
Expand Down Expand Up @@ -66,13 +66,13 @@ def _poller(self):
if self.callback is not None:
self.callback(d)
else:
print d['data']
print(d['data'])
else:
if d:
if self.callback is not None:
self.callback(dict(data=d, prompt=self.prompt))
else:
print d
print(d)
Timer(0.5, self._poller).start()

def execute(self, command):
Expand Down
8 changes: 5 additions & 3 deletions src/metasploit/msfrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,8 +1328,10 @@ def __init__(self, rpc, mtype, mname):
self.modulename = mname
self.rpc = rpc
self._info = rpc.call(MsfRpcMethod.ModuleInfo, mtype, mname)
property_attributes = ["advanced", "evasion", "options", "required", "runoptions"]
for k in self._info:
setattr(self, k, self._info.get(k))
if k not in propery_attributes):
setattr(self, k, self._info.get(k))
self._moptions = rpc.call(MsfRpcMethod.ModuleOptions, mtype, mname)
self._roptions = []
self._aoptions = []
Expand Down Expand Up @@ -1944,7 +1946,7 @@ def list(self):
"""
A list of active consoles.
"""
return self.rpc.call(MsfRpcMethod.ConsoleList)
return self.rpc.call(MsfRpcMethod.ConsoleList)['consoles']

def console(self, cid=None):
"""
Expand All @@ -1953,7 +1955,7 @@ def console(self, cid=None):
Optional Keyword Arguments:
- cid : the console identifier.
"""
s = self.list
s = [x['id'] for x in self.list['consoles']]
if cid is None:
return MsfConsole(self.rpc)
if cid not in s:
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')
2 changes: 1 addition & 1 deletion src/metasploit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def parseargs():
p.add_option("-p", dest="port", help="Connect to the specified port instead of 55553", metavar="opt", default=55553)
o, a = p.parse_args()
if o.password is None:
print '[-] Error: a password must be specified (-P)\n'
print('[-] Error: a password must be specified (-P)\n')
p.print_help()
exit(-1)
return o
3 changes: 1 addition & 2 deletions src/scripts/pymsfconsole
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ class MsfConsole(InteractiveConsole):
def callback(self, d):
stdout.write('\n%s' % d['data'])
if not self.fl:
stdout.write('\n%s' % d['prompt'])
stdout.write('\n%s' % d['prompt'].replace("\x01\x02", ""))
stdout.flush()
else:
self.fl = False


if __name__ == '__main__':
o = parseargs()
try:
Expand Down