0

I am using the pyMetasploit module for the remote access of metasploit msfconsole using the example as shown in the link https://github.com/allfro/pymetasploit and I downloaded the metasploit from https://github.com/rapid7/metasploit-framework/wiki/Nightly-Installers

when I tried to connect I'm getting the SSL certificate error, how to resolve this ?

the RPC listener is created using the below command

 msfrpcd -P password -n -f -a 127.0.0.1



 from metasploit.msfrpc import MsfRpcClient

 client = MsfRpcClient('password')

i got error as

 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/home/user1/.local/lib/python2.7/site-packages/metasploit/msfrpc.py", line 207, in __init__
  self.login(kwargs.get('username', 'msf'), password)
 File "/home/user1/.local/lib/python2.7/site-packages/metasploit/msfrpc.py", line 309, in login
  r = self.call(MsfRpcMethod.AuthLogin, username, password)
 File "/home/user1/.local/lib/python2.7/site-packages/metasploit/msfrpc.py", line 224, in call
  self.client.request('POST', self.uri, packb(l), self._headers)
 File "/usr/lib/python2.7/httplib.py", line 1057, in request
  self._send_request(method, url, body, headers)
 File "/usr/lib/python2.7/httplib.py", line 1097, in _send_request
  self.endheaders(body)
 File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders
  self._send_output(message_body)
 File "/usr/lib/python2.7/httplib.py", line 897, in _send_output
  self.send(msg)
 File "/usr/lib/python2.7/httplib.py", line 859, in send
  self.connect()
 File "/usr/lib/python2.7/httplib.py", line 1278, in connect
  server_hostname=server_hostname)
 File "/usr/lib/python2.7/ssl.py", line 353, in wrap_socket
  _context=self)
 File "/usr/lib/python2.7/ssl.py", line 601, in __init__
  self.do_handshake()
 File "/usr/lib/python2.7/ssl.py", line 830, in do_handshake
  self._sslobj.do_handshake()
shivakumar
  • 47
  • 2
  • 5

1 Answers1

0

by referring the link: https://github.com/allfro/pymetasploit/issues/10 I found the below code it worked for me.

 import ssl
 try:
     _create_unverified_https_context = ssl._create_unverified_context
 except AttributeError:
     pass
 else:
     ssl._create_default_https_context = _create_unverified_https_context

 from metasploit.msfrpc import MsfRpcClient
 client = MsfRpcClient('password')
shivakumar
  • 47
  • 2
  • 5