forked from allfro/pymetasploit
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from rapid7/FixLogin
Fixed login and bumped version to 2.1 across the board
- Loading branch information
Showing
7 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ def read(fname): | |
setup( | ||
name='pymetasploit', | ||
author='Nadeem Douba', | ||
version='2.0', | ||
version='2.1', | ||
author_email='[email protected]', | ||
description='A full-fledged msfrpc library for Metasploit framework.', | ||
license='GPL', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
__credits__ = [] | ||
|
||
__license__ = 'GPL' | ||
__version__ = '2.0' | ||
__version__ = '2.1' | ||
__maintainer__ = 'Nadeem Douba' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
__credits__ = [] | ||
|
||
__license__ = 'GPL' | ||
__version__ = '2.0' | ||
__version__ = '2.1' | ||
__maintainer__ = 'Nadeem Douba' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
__credits__ = [] | ||
|
||
__license__ = 'GPL' | ||
__version__ = '2.0' | ||
__version__ = '2.1' | ||
__maintainer__ = 'Nadeem Douba' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|
@@ -228,7 +228,7 @@ def call(self, method, *args): | |
self.client.request('POST', self.uri, packb(l), self._headers) | ||
r = self.client.getresponse() | ||
if r.status == 200: | ||
return unpackb(r.read()) | ||
return unpackb(r.read(), raw=False) | ||
raise MsfRpcError('An unknown error has occurred while logging in.') | ||
elif self.authenticated: | ||
l.insert(1, self.sessionid) | ||
|
@@ -311,9 +311,22 @@ def login(self, username, password): | |
""" | ||
if self.sessionid is None: | ||
r = self.call(MsfRpcMethod.AuthLogin, username, password) | ||
# in case r is actually encoded in bytes, this is a safe way to turn it back to string for the try/catch | ||
str_data = {} | ||
for key, val in r.items(): | ||
if isinstance(key, bytes): | ||
key_temp = key.decode() | ||
else: | ||
key_temp = key | ||
if isinstance(val, bytes): | ||
val_temp = val.decode() | ||
else: | ||
val_temp = val | ||
str_data[key_temp] = val_temp | ||
|
||
try: | ||
if r['result'] == 'success': | ||
self.sessionid = r['token'] | ||
if str_data['result'] == 'success': | ||
self.sessionid = str_data['token'] | ||
except KeyError: | ||
raise MsfRpcError('Login failed.') | ||
else: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = [] | ||
|
||
__license__ = 'GPL' | ||
__version__ = '2.0' | ||
__version__ = '2.1' | ||
__maintainer__ = 'Nadeem Douba' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ __copyright__ = 'Copyright 2021, PyMetasploit Project' | |
__credits__ = [] | ||
|
||
__license__ = 'GPL' | ||
__version__ = '2.0' | ||
__version__ = '2.1' | ||
__maintainer__ = 'Nadeem Douba' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ __copyright__ = 'Copyright 2021, PyMetasploit Project' | |
__credits__ = [] | ||
|
||
__license__ = 'GPL' | ||
__version__ = '2.0' | ||
__version__ = '2.1' | ||
__maintainer__ = 'Nadeem Douba' | ||
__email__ = '[email protected]' | ||
__status__ = 'Development' | ||
|