首页
社区
课程
招聘
[原创]无需刷boot.img修改ro.debuggable
2020-1-20 19:32 3638

[原创]无需刷boot.img修改ro.debuggable

2020-1-20 19:32
3638

本人华为手机android8.0,在搜索了大量修改ro.debuggable的方法后发现这些方法要么已经失效,要么比较繁琐。本来想通过刷boot.img的方法来修改ro.debuggable,奈何华为系统实在是坑,无论是从系统里,还是从全量包里都没有找到boot.img。但这不能打倒我,于是我就开始从android源码下手。在查阅资料后知道,android是在init进程中加载property的, 于是开始分析 在init.c的main函数里,

system/core/init/init.cpp


    property_init();

    // If arguments are passed both on the command line and in DT,
    // properties set in DT always have priority over the command-line ones.
    process_kernel_dt();
    process_kernel_cmdline();

    // Propagate the kernel variables to internal variables
    // used by init as well as the current required properties.
    export_kernel_boot_props();

    // Make the time that init started available for bootstat to log.
    property_set("ro.boottime.init", getenv("INIT_STARTED_AT"));
    property_set("ro.boottime.init.selinux", getenv("INIT_SELINUX_TOOK"));

    // Set libavb version for Framework-only OTA match in Treble build.
    const char* avb_version = getenv("INIT_AVB_VERSION");
    if (avb_version) property_set("ro.boot.avb_version", avb_version);

    // Clean up our environment.
    unsetenv("INIT_SECOND_STAGE");
    unsetenv("INIT_STARTED_AT");
    unsetenv("INIT_SELINUX_TOOK");
    unsetenv("INIT_AVB_VERSION");

    // Now set up SELinux for second stage.
    selinux_initialize(false);
    selinux_restore_context();

    epoll_fd = epoll_create1(EPOLL_CLOEXEC);
    if (epoll_fd == -1) {
        PLOG(ERROR) << "epoll_create1 failed";
        exit(1);
    }

    signal_handler_init();

    property_load_boot_defaults();
    export_oem_lock_status();
    start_property_service();
    set_usb_controller();

    const BuiltinFunctionMap function_map;
    Action::set_function_map(&function_map);

    Parser& parser = Parser::GetInstance();

发现调用了property_load_boot_defaults(),而这个函数就是初始加载ro.debuggable的地方。 这个函数位于/system/core/init/property_service.cpp中
void property_load_boot_defaults() {
    if (!load_properties_from_file("/system/etc/prop.default", NULL)) {
        // Try recovery path
        if (!load_properties_from_file("/prop.default", NULL)) {
            // Try legacy path
            load_properties_from_file("/default.prop", NULL);
        }
    }
    load_properties_from_file("/odm/default.prop", NULL);
    load_properties_from_file("/vendor/default.prop", NULL);

    update_sys_usb_config();
}
到这里就很明显了,系统首先从/system/etc/prop.default加载,如果不存在这个文件,则加载/prop.default,再不存在最后加载/default.prop。因此,只需要修改 /system/etc/prop.default文件中的ro.debuggable为1,然后重启一下手机就可以了。荣耀v8测试成功。
注意不要修改ro.secure,修改可能会导致重启后无法连接adb,出现这种情况,改回来就好了。
 


[培训]二进制漏洞攻防(第3期);满10人开班;模糊测试与工具使用二次开发;网络协议漏洞挖掘;Linux内核漏洞挖掘与利用;AOSP漏洞挖掘与利用;代码审计。

收藏
点赞2
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回