Esempio n. 1
0
def evaluate_command(cmd):
    if fuzz_channel == 'b':
        return bluetooth_fuzz(cmd, blue_address, port)
    elif fuzz_channel == 'u':
        return usb_fuzz(cmd, device, port)
    elif fuzz_channel == 't':  # only for test purpose
        print(cmd)
        return test_fuzz(cmd)
    else:
        print(
            '\nInvalid fuzzer channel! Restart execution and follow the instructions\n'
        )
        sys.exit()
Esempio n. 2
0
def fuzz_command(commands, device):
    for x in range(RESTART_TRESHOLD):
        fuzzing_cmd = utilityFunctions.copy_list(commands)
        commands_population = fuzzing_cmd
        print ('\nRestart counter: ', x)
        for i in range(ATTEMPTS):
            print ('\n - Iteration counter: ', i)
            results = []
            for cmd in commands_population:
                #print cmd
                #res = [random.random()*5, 0]
                res = usb_fuzz('AT'+cmd, device)
                time, flag = res[0], res[1]
                cmd_result = hyperparameters['time_weight'] * time + hyperparameters['flag_weight'] * flag
                results.append([cmd_result, cmd])
                if flag == 1:
                    save_command(cmd, device)

            selected_commands = select_population(results)
            commands_population = update_commands_population(selected_commands)
        print ('__________________________________________________\n')