This commit is contained in:
2019-12-07 14:22:10 -05:00
parent 3e5974b9b5
commit 413de9fb6d
8 changed files with 147 additions and 78 deletions

View File

@@ -5,34 +5,14 @@
#include "checkm8.h"
#include "libusb_helpers.h"
int complete_stage(int stage_function(struct libusb_device_bundle *bundle))
int complete_stage(struct libusb_device_bundle *bundle, int stage_function(struct libusb_device_bundle *bundle))
{
int ret;
libusb_open(bundle->device, &bundle->handle);
libusb_set_auto_detach_kernel_driver(bundle->handle, 1);
libusb_context *usb_ctx = NULL;
struct libusb_device_bundle usb_bundle;
int ret = stage_function(bundle);
libusb_close(bundle->handle);
libusb_init(&usb_ctx);
get_test_device(usb_ctx, &usb_bundle);
if(usb_bundle.handle == NULL)
{
libusb_exit(usb_ctx);
printf("Could not find device\n");
return 1;
}
ret = libusb_set_auto_detach_kernel_driver(usb_bundle.handle, 1);
if(ret > 0)
{
printf("%s\n", libusb_error_name(ret));
return ret;
}
ret = stage_function(&usb_bundle);
libusb_close(usb_bundle.handle);
libusb_exit(usb_ctx);
return ret;
}
@@ -115,22 +95,30 @@ int check_function(struct libusb_device_bundle *bundle)
int exploit_device()
{
int ret = complete_stage(stage1_function);
libusb_context *usb_ctx = NULL;
struct libusb_device_bundle usb_bundle;
libusb_init(&usb_ctx);
get_test_device(usb_ctx, &usb_bundle);
int ret = complete_stage(&usb_bundle, stage1_function);
if(ret == 0)
{
ret = complete_stage(stage2_function);
ret = complete_stage(&usb_bundle, stage2_function);
usleep(500000);
}
if(ret == 0)
{
ret = complete_stage(stage3_function);
ret = complete_stage(&usb_bundle, stage3_function);
usleep(500000);
}
if(ret == 0)
{
ret = complete_stage(check_function);
ret = complete_stage(&usb_bundle, check_function);
}
libusb_exit(usb_ctx);
return ret;
}