diff --git a/core/module_protocols/smb.py b/core/module_protocols/smb.py new file mode 100644 index 00000000..fc09c8e0 --- /dev/null +++ b/core/module_protocols/smb.py @@ -0,0 +1,68 @@ +import copy +import smbprotocol +from core.utility import process_conditions +from core.utility import get_dependent_results_from_database +from core.utility import replace_dependent_values + +class NettackSMB: + def smb_brute_force(self, host, ports, usernames, passwords, timeout): + smb_client = smbprotocol.SMBClient(host, int(ports)) + try: + smb_client.login(usernames, passwords, timeout=int(timeout)) + smb_client.logout() + return { + "host": host, + "username": usernames, + "password": passwords, + "port": ports + } + except smbprotocol.exceptions.AuthenticationError as _: + pass + return {} + +class Engine: + def run( + sub_step, + module_name, + target, + scan_unique_id, + options, + process_number, + module_thread_number, + total_module_thread_number, + request_number_counter, + total_number_of_requests + ): + backup_method = copy.deepcopy(sub_step['method']) + backup_response = copy.deepcopy(sub_step['response']) + del sub_step['method'] + del sub_step['response'] + if 'dependent_on_temp_event' in backup_response: + temp_event = get_dependent_results_from_database( + target, + module_name, + scan_unique_id, + backup_response['dependent_on_temp_event'] + ) + sub_step = replace_dependent_values( + sub_step, + temp_event + ) + action = NettackSMB() + response = action.smb_brute_force(**sub_step) + sub_step['method'] = backup_method + sub_step['response'] = backup_response + sub_step['response']['conditions_results'] = response + return process_conditions( + sub_step, + module_name, + target, + scan_unique_id, + options, + response, + process_number, + module_thread_number, + total_module_thread_number, + request_number_counter, + total_number_of_requests + ) diff --git a/modules/brute/smb.yaml b/modules/brute/smb.yaml new file mode 100644 index 00000000..81a6477b --- /dev/null +++ b/modules/brute/smb.yaml @@ -0,0 +1,40 @@ +info: + name: smb_brute + author: OWASP Nettacker Team + severity: 3 + description: smb Bruteforcer + reference: + profiles: + - brute + - brute_force + - smb + +payloads: + - library: smb + steps: + - method: smb_brute_force + timeout: 3 + host: "{target}" + ports: + - 445 + - 139 + usernames: + - root + - admin + - user + - test + passwords: + nettacker_fuzzer: + input_format: '{{passwords}}' + prefix: + suffix: + interceptors: + data: + passwords: fuzzer_function_read_file_as_array('passwords/top_1000_common_passwords.txt') + response: + condition_type: or + conditions: + successful_login: + regex: "" + reverse: false +