def device_profile_delete(id): provider = Provider() device_profile_manager = provider.device_profiles() device_profile_manager.delete(id) flash('Device profile deleted', 'success') return redirect(url_for('config.device_profiles'))
def device_profile_save(id): provider = Provider() device_profile_manager = provider.device_profiles() name = request.form['name'].strip() if 'name' in request.form else '' enabled = True if 'enabled' in request.form else False devices = request.form.getlist('devices', int) if len(name) == 0: flash('Profile name cannot be empty', 'error') return redirect(url_for('config.device_profile_edit', id=id)) elif len(devices) == 0: flash('Please select at least one device', 'error') return redirect(url_for('config.device_profile_edit', id=id)) for device_id in devices: if not device_profile_manager.is_valid_device(device_id): flash('Invalid device selected', 'error') return redirect(url_for('config.device_profile_edit', id=id)) profile = device_profile_manager.save(id, name, devices, enabled) if not profile: flash('Could not save profile', 'error') return redirect(url_for('config.device_profile_edit', id=id)) flash('Device profile created', 'success') return redirect(url_for('config.device_profiles'))
def setup_hashcat(session_id): provider = Provider() sessions = provider.sessions() hashcat = provider.hashcat() system = provider.system() device_profiles = provider.device_profiles() if not sessions.can_access(current_user, session_id): flash('Access Denied', 'error') return redirect(url_for('home.index')) user_id = 0 if current_user.admin else current_user.id session = sessions.get(user_id=user_id, session_id=session_id)[0] supported_hashes = hashcat.get_supported_hashes() # We need to process the array in a way to make it easy for JSON usage. supported_hashes = hashcat.compact_hashes(supported_hashes) if len(supported_hashes) == 0: home_directory = system.get_system_user_home_directory() flash('Could not get the supported hashes from hashcat', 'error') flash('If you have compiled hashcat from source, make sure %s/.hashcat directory exists and is writable' % home_directory, 'error') return render_template( 'sessions/setup/hashcat.html', session=session, hashes_json=json.dumps(supported_hashes, indent=4, sort_keys=True, default=str), guess_hashtype=sessions.guess_hashtype(session.user_id, session.id, session.hashcat.contains_usernames), has_device_profiles=device_profiles.has_enabled_profiles(), device_profiles=device_profiles.get_device_profiles() )
def device_profile_edit(id): provider = Provider() device_profile_manager = provider.device_profiles() return render_template( 'config/system/device_profiles/edit.html', supported_devices=device_profile_manager.get_supported_devices(), profile=device_profile_manager.get_profile(id))
def setup_hashcat_save(session_id): provider = Provider() sessions = provider.sessions() hashcat = provider.hashcat() device_profiles = provider.device_profiles() if not sessions.can_access(current_user, session_id): flash('Access Denied', 'error') return redirect(url_for('home.index')) hash_type = request.form['hash-type'].strip() optimised_kernel = int(request.form.get('optimised_kernel', 0)) workload = int(request.form.get('workload', 2)) mode = int(request.form['mode'].strip()) device_profile_id = int(request.form.get('device_profile', 0)) if mode != 0 and mode != 3: # As all the conditions below depend on the mode, if it's wrong return to the previous page immediately. flash('Invalid attack mode selected', 'error') return redirect(url_for('sessions.setup_hashcat', session_id=session_id)) elif workload not in [1, 2, 3, 4]: flash('Invalid workload selected', 'error') return redirect(url_for('sessions.setup_hashcat', session_id=session_id)) elif device_profiles.has_enabled_profiles() and device_profile_id <= 0: flash('Invalid device profile selected', 'error') return redirect(url_for('sessions.setup_hashcat', session_id=session_id)) elif device_profiles.has_enabled_profiles() and not device_profiles.is_profile_enabled(device_profile_id): flash('The selected device profile is invalid or disabled', 'error') return redirect(url_for('sessions.setup_hashcat', session_id=session_id)) has_errors = False if not hashcat.is_valid_hash_type(hash_type): has_errors = True flash('Invalid hash type selected', 'error') if has_errors: return redirect(url_for('sessions.setup_hashcat', session_id=session_id)) sessions.set_hashcat_setting(session_id, 'mode', mode) sessions.set_hashcat_setting(session_id, 'hashtype', hash_type) sessions.set_hashcat_setting(session_id, 'optimised_kernel', optimised_kernel) sessions.set_hashcat_setting(session_id, 'workload', workload) sessions.set_hashcat_setting(session_id, 'device_profile_id', device_profile_id) redirect_to = 'wordlist' if mode == 0 else 'mask' return redirect(url_for('sessions.setup_' + redirect_to, session_id=session_id))