Example #1
0
def only_payload_process(host, port, exec_name, exec_list, exec_path, testcase_path, test_path):

    path_prefix = "test_generation/"
    exec_path_value = path_prefix + "execution.xml"
    if exec_path != "":
        exec_path_value = exec_path

    testcase_path_value = path_prefix + "testcase.xml"
    if testcase_path != "":
        testcase_path_value = testcase_path

    test_path_value = path_prefix + "test.xml"
    if test_path != "":
        test_path_value = test_path

    xml_tree = xml_parser(test_path_value, testcase_path_value, exec_path_value)
    xml_tree.calc_tests(exec_name)

    print "[*] Number of tests: " + str(xml_tree.get_number_of_elements())
    xml_tree.print_tree()
    emu = usb_emulator([host, port], 0)
    payloads = xml_tree.get_data_chunk(config.NUMBER_OF_JOBS_PER_PROCESS_NM)
    random.shuffle(payloads)
    while payloads is not None:
        for e in payloads:
            print e
            emu.setup_payload(e)
            emu.execute()
            time.sleep(config.SLEEP_BETWEEN_TESTS)
        payloads = xml_tree.get_data_chunk(config.NUMBER_OF_JOBS_PER_PROCESS_NM)
    print "[*] Done..."
Example #2
0
def execute_object_process(object_file, host="", port=0, target=None):
    config.SERIAL_READ_RETRIES = config.SERIAL_READ_RETRIES_EXECUTE_MODE
    config.PROCESS_SLOW_START_THRESHOLD = config.PROCESS_SLOW_START_THRESHOLD_EXECUTE_MODE
    config.PROCESS_SLOW_START_THRESHOLD_FAIL_COUNTER = config.PROCESS_SLOW_START_THRESHOLD_FAIL_COUNTER_EXECUTE_MODE
    config.PROCESS_FAIL_REPAIR_COUNTER = config.PROCESS_FAIL_REPAIR_COUNTER_EXECUTE_MODE

    payloads = testcase_loader(object_file)
    if host == "" or port == 0:
        if target is not None:
            try:
                os.remove("log/vusbf_log_execute")
            except:
                pass
            multi_processing(1, target, "", "", "", "", "", False, None, payloads=payloads, file_name="execute")
            print "[*] Output:"
            print ""
            for line in open("log/vusbf_log_execute"):
                print line,
    else:
        for e in payloads.payloads:
            print e
            emu = usb_emulator([host, port], 0)
            emu.setup_payload(e)
            emu.execute()
Example #3
0
        bInterfaceProtocol     = 0,
        iInterface             = 0, # string index
        endpoints              = [],
)

config = USBConfigurationDescriptor(
        interfaces = [interface]
)

usbDevDescriptor = USBDeviceDescriptor(
        bDeviceClass     = 0,
        bDeviceSubClass  = 0,
        bDeviceProtocol  = 0,
        bMaxPacketSize   = 64,
        idVendor         = 0x0763,
        idProduct        = 0x1002,
        configurations   = [ config ]
        )


usbDev = USBDevice(usbDevDescriptor)

emu = usb_emulator(["127.0.0.1", 1235], 0)
emu.connect_device(usbDev)

data = lsusbDescriptionParser("dev_desc/multi_flash.txt").parse()
payload = data[0]
if_info_packet = data[3]
ep_info_packet = data[4]
connect_packet = data[2]