From 20dbeb2f38684c65ff0a4b99012c161295708e88 Mon Sep 17 00:00:00 2001 From: AL-LCL Date: Fri, 19 May 2023 11:01:49 +0200 Subject: NeoRAT --- domestic/modules/socket_handler.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 domestic/modules/socket_handler.py (limited to 'domestic/modules/socket_handler.py') diff --git a/domestic/modules/socket_handler.py b/domestic/modules/socket_handler.py new file mode 100644 index 0000000..7f8c57e --- /dev/null +++ b/domestic/modules/socket_handler.py @@ -0,0 +1,33 @@ +import socket + +from domestic.utility.status_message import * +from domestic.utility.write_error import * +from domestic.global_state import * + + +def bind_socket(ip, port, module_type, stdout=True): + try: + state['sockets']['modules'][module_type][0] = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + state['sockets']['modules'][module_type][0].bind((ip, int(port))) + state['sockets']['modules'][module_type][0].listen() + except Exception as err: + write_error(err) + state['sockets']['modules'][module_type][0] = None + raise Exception('Socket binding error') + else: + if stdout: + status_message(f'{module_type.capitalize()} address successfully bound', 'success') + +def close_client(index, module_type, write_stdout=True): + state['sockets']['modules'][module_type][1][int(index)][0].close() + + if write_stdout: + status_message(f'{module_type.capitalize()} client successfully closed', 'success') + +def unbind_socket(module_type): + for _ in range(len(state['sockets']['modules'][module_type][1])): + close_client('0', module_type, False) + + state['sockets']['modules'][module_type][0].close() + state['sockets']['modules'][module_type][0] = None + status_message(f'{module_type.capitalize()} address successfully closed', 'success') \ No newline at end of file -- cgit v1.2.3