allfro / pymetasploit

A full-fledged msfrpc library for Metasploit framework.
297 stars 141 forks source link

socket.error is not solving #6

Closed lokesh1095 closed 6 years ago

lokesh1095 commented 8 years ago

when i try to run command client = MsfRpcClient('lokesh1095') i get following error. i tried many things but error is persistent. cant solve it. any help??

Traceback (most recent call last):
  File "/root/Documents/attckByMSF.py", line 6, in <module>
    client = MsfRpcClient('mypassword')
  File "/root/Documents/pymetasploit-master/src/metasploit/msfrpc.py", line 213, in **init**
    self.login(kwargs.get('username', 'msf'), password)
  File "/root/Documents/pymetasploit-master/src/metasploit/msfrpc.py", line 315, in login
    r = self.call(MsfRpcMethod.AuthLogin, username, password)
  File "/root/Documents/pymetasploit-master/src/metasploit/msfrpc.py", line 230, 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 1270, in connect
    HTTPConnection.connect(self)
  File "/usr/lib/python2.7/httplib.py", line 836, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 575, in create_connection
    raise err
socket.error: [Errno 111] Connection refused
JohnTroony commented 8 years ago

Do you have Metasploit service running? service metasploit start

devcoinfet commented 6 years ago

yes I do have metasploit service running I have updated to the suggested version and I see nothing but this Error above as well

DanMcInerney commented 6 years ago

This library was just working for me after adding the try/excepts for the ssl library from another issue. Now 100% of the time I'm getting connection refused as well. Restart metasploit, tried running metasploit as a daemon, and it's just constantly saying connection refused.

I can confirm metasploit is running and msfrpcd is running as well.

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
ruby    17384 root    9u  IPv4 243289      0t0  TCP *:55553 (LISTEN)
DanMcInerney commented 6 years ago

OK well, apparently adding the port option to MsfRpcClient will fix this.

client = MsfRpcClient(password, port=55553) # works.
client = MsfRpcClient(password) # does not

What's weird is that in the code it says port will default to 55553 so I have no idea why adding that parameter with the value it already has by default makes it work.

devcoinfet commented 6 years ago

I, can Share my Solution via Email. As well I'm 90% done with my Tool just had a few issues IRL that required my attention. I'd say no more than a week check my github it will be there its called th3surg30n

thanks for all Your help guys.

On Sat, Mar 3, 2018 at 1:26 PM, Dan McInerney notifications@github.com wrote:

OK well, apparently adding the port option to MsfRpcClient will fix this.

client = MsfRpcClient(password, port=55553) works. client = MsfRpcClient(password) does not.

What's weird is that in the code it says port will default to 55553 so I have no idea why adding that parameter with the value it already has by default makes it work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/allfro/pymetasploit/issues/6#issuecomment-370181064, or mute the thread https://github.com/notifications/unsubscribe-auth/AhJZgXYPMB4WEWnMwPZk0I9mBNhiTg19ks5tawp4gaJpZM4IcPSZ .