Skip to content

Commit

Permalink
Implemented sessions management, Fixed #8
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dalirius committed Jun 24, 2024
1 parent 5ce5407 commit f004b4b
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion smbclientng/core/SessionsManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,40 @@ def switch_session(self, session_id):
else:
return False

def delete_session(self, session_id):
"""
Deletes a session with the given session ID.
Args:
session_id (int): The ID of the session to delete.
Returns:
bool: True if the session was successfully deleted, False otherwise.
"""

if session_id in self.sessions.keys():
self.sessions[session_id]["smbSession"].close_smb_session()
del self.sessions[session_id]
if self.current_session_id == session_id:
self.current_session = None
self.current_session_id = None
return True
return False

def process_command_line(self, arguments):
"""
Processes command line arguments to manage SMB sessions.
This function parses the command line arguments provided to the application and determines the appropriate action to take,
such as creating, accessing, deleting, or listing SMB sessions, or executing a command in one or more sessions.
Args:
arguments (list of str): The command line arguments.
Returns:
None
"""

parser = ModuleArgumentParser(add_help=True, description="")

# Access
Expand Down Expand Up @@ -159,7 +192,6 @@ def process_command_line(self, arguments):
if options.session_id is not None:
if options.session_id in self.sessions.keys():
print("[+] Executing '%s to session #%d" % (options.command, options.session_id))
self.switch_session(session_id=options.session_id)
else:
print("[!] No session with id #%d" % options.session_id)
elif options.all == True:
Expand Down

0 comments on commit f004b4b

Please sign in to comment.