GeezerVison is showing github.com — fix: 修复一些特殊情况下会死机的问题。 · nocteruk/SKRoot-linuxKernelRoot@8ed7456
File treeExpand file treeCollapse file tree Open diff view settings testRoot/kernel_root_kit/src/jni
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard Collapse file Copy file name to clipboardExpand all lines: Lite_version/src/patch_kernel_root/analyze/symbol_analyze.cpp +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,8 +47,8 @@ bool SymbolAnalyze::find_symbol_offset() { | 47 | 47 | m_sym_offset._text = find_addr({{"_text", false}}); | 48 | 48 | m_sym_offset._stext = find_addr({{"_stext", false}}); | 49 | 49 | m_sym_offset.die = find_region({{"die", false}}); | 50 | | - m_sym_offset.arm64_notify_die = find_region({{"arm64_notify_die", false}}); | 51 | | - m_sym_offset.__drm_printfn_coredump = find_region({{"__drm_printfn_coredump", false}}); | | 50 | + m_sym_offset.__drm_puts_coredump = find_region({ {"__drm_puts_coredump", false} }); | | 51 | + m_sym_offset.__drm_printfn_coredump = find_region({ {"__drm_printfn_coredump", false} }); | 52 | 52 |
| 53 | 53 | m_sym_offset.__do_execve_file = find_addr({{"__do_execve_file", false}}); | 54 | 54 | m_sym_offset.do_execveat_common = find_addr({ | @@ -107,7 +107,7 @@ void SymbolAnalyze::printf_symbol_offset() { | 107 | 107 | std::cout << "_text:" << m_sym_offset._text << std::endl; | 108 | 108 | std::cout << "_stext:" << m_sym_offset._stext << std::endl; | 109 | 109 | if (m_sym_offset.die) std::cout << "die:" << m_sym_offset.die.offset << ", size:" << m_sym_offset.die.size << std::endl; | 110 | | - if (m_sym_offset.arm64_notify_die) std::cout << "arm64_notify_die:" << m_sym_offset.arm64_notify_die.offset << ", size:" << m_sym_offset.arm64_notify_die.size << std::endl; | | 110 | + if (m_sym_offset.__drm_puts_coredump) std::cout << "__drm_puts_coredump:" << m_sym_offset.__drm_puts_coredump.offset << ", size:" << m_sym_offset.__drm_printfn_coredump.size << std::endl; | 111 | 111 | if (m_sym_offset.__drm_printfn_coredump) std::cout << "__drm_printfn_coredump:" << m_sym_offset.__drm_printfn_coredump.offset << ", size:" << m_sym_offset.__drm_printfn_coredump.size << std::endl; | 112 | 112 |
| 113 | 113 | std::cout << "__do_execve_file:" << m_sym_offset.__do_execve_file << std::endl; | |
Collapse file Copy file name to clipboardExpand all lines: Lite_version/src/patch_kernel_root/analyze/symbol_analyze.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,7 @@ struct KernelSymbolOffset { | 18 | 18 | size_t _text = 0; | 19 | 19 | size_t _stext = 0; | 20 | 20 | SymbolRegion die = { 0 }; | 21 | | - SymbolRegion arm64_notify_die = { 0 }; | | 21 | + SymbolRegion __drm_puts_coredump = { 0 }; | 22 | 22 | SymbolRegion __drm_printfn_coredump = { 0 }; | 23 | 23 |
| 24 | 24 | size_t __do_execve_file = 0; | |
Collapse file Copy file name to clipboardExpand all lines: Lite_version/src/patch_kernel_root/patch_kernel_root.cpp +6-3Lines changed: 6 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,12 +92,14 @@ PatchKernelResult patch_kernel_handler(const std::vector<char>& file_buf, size_t | 92 | 92 | PATCH_AND_CONSUME(next_empty_region, patchAuditLogStart.patch_audit_log_start(next_empty_region, current_avc_check_bl_func, vec_patch_bytes_data)); | 93 | 93 | auto end_b_location = next_empty_region.offset; | 94 | 94 | patchBase.patch_jump(start_b_location, end_b_location, vec_patch_bytes_data); | 95 | | - } else if (sym.die.offset && sym.arm64_notify_die.offset && sym.__drm_printfn_coredump.offset) { | | 95 | + } else if (sym.die.offset && sym.__drm_puts_coredump.offset && sym.__drm_printfn_coredump.offset) { | | 96 | + PATCH_AND_CONSUME(sym.__drm_printfn_coredump, patch_ret_cmd(file_buf, sym.__drm_printfn_coredump.offset, vec_patch_bytes_data)); | | 97 | + PATCH_AND_CONSUME(sym.__drm_puts_coredump, patch_ret_cmd(file_buf, sym.__drm_puts_coredump.offset, vec_patch_bytes_data)); | 96 | 98 | r.root_key_start = sym.die.offset; | 97 | 99 | PATCH_AND_CONSUME(sym.die, patchDoExecve.patch_do_execve(sym.die, cred_offset, seccomp_offset, vec_patch_bytes_data)); | 98 | 100 | PATCH_AND_CONSUME(sym.die, patchFilldir64.patch_filldir64_root_key_guide(r.root_key_start, sym.die, vec_patch_bytes_data)); | 99 | | - PATCH_AND_CONSUME(sym.die, patchFilldir64.patch_jump(sym.die.offset, sym.arm64_notify_die.offset, vec_patch_bytes_data)); | 100 | | - PATCH_AND_CONSUME(sym.arm64_notify_die, patchFilldir64.patch_filldir64_core(sym.arm64_notify_die, vec_patch_bytes_data)); | | 101 | + PATCH_AND_CONSUME(sym.die, patchFilldir64.patch_jump(sym.die.offset, sym.__drm_puts_coredump.offset, vec_patch_bytes_data)); | | 102 | + PATCH_AND_CONSUME(sym.__drm_puts_coredump, patchFilldir64.patch_filldir64_core(sym.__drm_puts_coredump, vec_patch_bytes_data)); | 101 | 103 | auto current_avc_check_bl_func = sym.__drm_printfn_coredump.offset; | 102 | 104 | PATCH_AND_CONSUME(sym.__drm_printfn_coredump, patchCurrentAvcCheck.patch_current_avc_check_bl_func(sym.__drm_printfn_coredump, cred_offset, vec_patch_bytes_data)); | 103 | 105 | PATCH_AND_CONSUME(sym.__drm_printfn_coredump, patchAvcDenied.patch_avc_denied(sym.__drm_printfn_coredump, current_avc_check_bl_func, vec_patch_bytes_data)); | @@ -161,6 +163,7 @@ int main(int argc, char* argv[]) { | 161 | 163 | return 0; | 162 | 164 | } | 163 | 165 | KernelSymbolOffset sym = symbol_analyze.get_symbol_offset(); | | 166 | + uint64_t anchor_off = sym.die.offset; | 164 | 167 |
| 165 | 168 | std::string t_mode_name; | 166 | 169 | size_t cred_offset = 0; | |
Collapse file Copy file name to clipboardExpand all lines: Lite_version/src/testRoot/kernel_root_kit/src/jni/common/file_utils.h +32-9Lines changed: 32 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | #include <vector> | 4 | 4 | #include <cstdint> | 5 | 5 | #include <fstream> | | 6 | +#include <random> | 6 | 7 | #include <filesystem> | 7 | 8 | #include <sys/stat.h> | 8 | 9 | #include <sys/xattr.h> | @@ -70,17 +71,39 @@ enum class SelinuxFileFlag { | 70 | 71 | }; | 71 | 72 |
| 72 | 73 | static inline bool set_file_selinux_access_mode(const char* file_full_path, SelinuxFileFlag flag) { | 73 | | - if (chmod(file_full_path, 0777) != 0) { | 74 | | - return false; | 75 | | - } | | 74 | + if (chmod(file_full_path, 0777) != 0) return false; | 76 | 75 | const char* selinux_flag = flag == SelinuxFileFlag::SELINUX_SYSTEM_FILE ? SELINUX_SYSTEM_FILE_FLAG : SELINUX_KERNEL_FILE_FLAG; | 77 | | - if (setxattr(file_full_path, | 78 | | - XATTR_NAME_SELINUX, | 79 | | - selinux_flag, | 80 | | - strlen(selinux_flag) + 1, | 81 | | - 0) != 0) { | 82 | | - return false; | | 76 | + if (setxattr(file_full_path, XATTR_NAME_SELINUX, selinux_flag, strlen(selinux_flag) + 1, 0) != 0) return false; | | 77 | + return true; | | 78 | +} | | 79 | + | | 80 | +static bool copy_selinux_context(const char* source_file_path, const char* target_file_path) { | | 81 | + char selinux_context[512] = { 0 }; // adjust the size as per your requirement | | 82 | + // Retrieve the SELinux context from the source file | | 83 | + ssize_t length = getxattr(source_file_path, XATTR_NAME_SELINUX, selinux_context, sizeof(selinux_context)); | | 84 | + if (length == -1) return false; | | 85 | + selinux_context[length] = '\0'; // ensure null termination | | 86 | + // Set the SELinux context to the target file | | 87 | + if (setxattr(target_file_path, XATTR_NAME_SELINUX, selinux_context, strlen(selinux_context) + 1, 0)) return false; | | 88 | + return true; | | 89 | +} | | 90 | + | | 91 | +static bool random_expand_file(const char* file_path) { | | 92 | + std::ofstream file(file_path, std::ios::binary | std::ios::app); | | 93 | + if (!file.is_open()) return false; | | 94 | + std::random_device rd; | | 95 | + std::mt19937 gen(rd()); | | 96 | + // 随机大小:1MB–5MB | | 97 | + std::uniform_int_distribution<size_t> size_dis(1 * 1024 * 1024, 5 * 1024 * 1024); | | 98 | + size_t random_size = size_dis(gen); | | 99 | + std::uniform_int_distribution<unsigned> byte_dis(0, 255); | | 100 | + std::vector<char> buffer(random_size); | | 101 | + for (size_t i = 0; i < random_size; ++i) { | | 102 | + buffer[i] = static_cast<char>(byte_dis(gen)); | 83 | 103 | } | | 104 | + file.write(buffer.data(), buffer.size()); | | 105 | + if (!file) return false; | | 106 | + file.close(); | 84 | 107 | return true; | 85 | 108 | } | 86 | 109 |
| |
Collapse file Copy file name to clipboardExpand all lines: Lite_version/src/testRoot/kernel_root_kit/src/jni/rootkit_command.cpp +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,15 +37,15 @@ KRootErr run_root_cmd_with_cb(const char* str_root_key, const char* cmd, void (* | 37 | 37 |
| 38 | 38 | KRootErr err = KRootErr::OK; | 39 | 39 |
| 40 | | - std::string cmd_add_err_info = cmd; | 41 | | - cmd_add_err_info += " 2>&1"; | | 40 | + std::string cmd_pack = cmd; | | 41 | + cmd_pack += " 2>&1"; | 42 | 42 |
| 43 | 43 | std::string result; | 44 | 44 | fork_pipe_info finfo; | 45 | 45 | if(fork_pipe_child_process(finfo)) { | 46 | 46 | do { | 47 | 47 | BREAK_ON_ERROR(get_root(str_root_key)); | 48 | | - FILE * fp = popen(cmd_add_err_info.c_str(), "r"); | | 48 | + FILE * fp = popen(cmd_pack.c_str(), "r"); | 49 | 49 | if(!fp) { | 50 | 50 | err = KRootErr::ERR_POPEN; | 51 | 51 | break; | |
Collapse file Copy file name to clipboardExpand all lines: Lite_version/src/testRoot/kernel_root_kit/src/jni/rootkit_fork_helper.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,7 @@ bool fork_pipe_child_process(fork_pipe_info & finfo) { | 23 | 23 | ::close(p2c[0]); ::close(p2c[1]); | 24 | 24 | return false; | 25 | 25 | } | 26 | | - | | 26 | + fflush(nullptr); | 27 | 27 | pid_t pid = fork(); | 28 | 28 | if (pid < 0) { | 29 | 29 | ::close(p2c[0]); ::close(p2c[1]); | |
Collapse file Copy file name to clipboardExpand all lines: Lite_version/src/testRoot/kernel_root_kit/src/jni/rootkit_parasite_app.cpp +3-46Lines changed: 3 additions & 46 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | #include <vector> | 9 | 9 | #include <map> | 10 | 10 | #include <filesystem> | 11 | | -#include <random> | 12 | 11 | #include <dirent.h> | 13 | 12 | #include <sys/stat.h> | 14 | 13 | #include <sys/types.h> | @@ -42,48 +41,6 @@ namespace { | 42 | 41 | return p.filename(); | 43 | 42 | } | 44 | 43 |
| 45 | | - static bool random_expand_file(const char* file_path) { | 46 | | - std::ofstream file(file_path, std::ios::binary | std::ios::app); | 47 | | - if (!file.is_open()) { | 48 | | - return false; | 49 | | - } | 50 | | - | 51 | | - std::random_device rd; | 52 | | - std::mt19937 gen(rd()); | 53 | | - // 随机大小:1MB–5MB | 54 | | - std::uniform_int_distribution<size_t> size_dis(1 * 1024 * 1024, 5 * 1024 * 1024); | 55 | | - size_t random_size = size_dis(gen); | 56 | | - std::uniform_int_distribution<unsigned> byte_dis(0, 255); | 57 | | - std::vector<char> buffer(random_size); | 58 | | - for (size_t i = 0; i < random_size; ++i) { | 59 | | - buffer[i] = static_cast<char>(byte_dis(gen)); | 60 | | - } | 61 | | - file.write(buffer.data(), buffer.size()); | 62 | | - if (!file) { | 63 | | - return false; | 64 | | - } | 65 | | - file.close(); | 66 | | - return true; | 67 | | - } | 68 | | - | 69 | | - static bool copy_selinux_context(const char* source_file_path, const char* target_file_path) { | 70 | | - char selinux_context[512] = { 0 }; // adjust the size as per your requirement | 71 | | - | 72 | | - // Retrieve the SELinux context from the source file | 73 | | - ssize_t length = getxattr(source_file_path, XATTR_NAME_SELINUX, selinux_context, sizeof(selinux_context)); | 74 | | - if (length == -1) { | 75 | | - return false; | 76 | | - } | 77 | | - selinux_context[length] = '\0'; // ensure null termination | 78 | | - | 79 | | - // Set the SELinux context to the target file | 80 | | - if (setxattr(target_file_path, XATTR_NAME_SELINUX, selinux_context, strlen(selinux_context) + 1, 0)) { | 81 | | - return false; | 82 | | - } | 83 | | - | 84 | | - return true; | 85 | | - } | 86 | | - | 87 | 44 | static KRootErr _internal_parasite_implant_app(const char* str_root_key, const char* target_pid_cmdline, | 88 | 45 | const char* original_so_full_path, const char* implant_so_full_path) { | 89 | 46 | RETURN_ON_ERROR(get_root(str_root_key)); | @@ -93,7 +50,7 @@ namespace { | 93 | 50 | if(!file_utils::file_exists(implant_so_full_path)) { | 94 | 51 | return KRootErr::ERR_NOT_EXIST_IMPLANT_FILE; | 95 | 52 | } | 96 | | - if (!copy_selinux_context(original_so_full_path, implant_so_full_path)) { | | 53 | + if (!file_utils::copy_selinux_context(original_so_full_path, implant_so_full_path)) { | 97 | 54 | return KRootErr::ERR_COPY_SELINUX; | 98 | 55 | } | 99 | 56 | // Because it is in the same directory as the parasitized so, all you need to do here is fill in the file name of so | @@ -232,7 +189,7 @@ static KRootErr write_web_server_so_file(const char* str_root_key, const char* i | 232 | 189 | if (chmod(implant_so_full_path, 0777)) { | 233 | 190 | return KRootErr::ERR_CHMOD; | 234 | 191 | } | 235 | | - random_expand_file(implant_so_full_path); | | 192 | + file_utils::random_expand_file(implant_so_full_path); | 236 | 193 | return KRootErr::OK; | 237 | 194 | } | 238 | 195 |
| @@ -290,7 +247,7 @@ static KRootErr write_su_env_so_file(const char* str_root_key, const char* impla | 290 | 247 | if (chmod(implant_so_full_path, 0777)) { | 291 | 248 | return KRootErr::ERR_CHMOD; | 292 | 249 | } | 293 | | - random_expand_file(implant_so_full_path); | | 250 | + file_utils::random_expand_file(implant_so_full_path); | 294 | 251 | return KRootErr::OK; | 295 | 252 | } | 296 | 253 |
| |
Collapse file Copy file name to clipboardExpand all lines: README.md +12-13Lines changed: 12 additions & 13 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 43 | 43 | 2. 其中【**注入su到指定进程**】**只支持授权su到64位的APP**,老式32位App不再进行支持。 | 44 | 44 |
| 45 | 45 | ## SKRoot(Lite) 使用流程: | 46 | | -1.下载源码编译或**下载编译产物**: [patch_kernel_root.exe](https://github.com/abcz316/SKRoot-linuxKernelRoot/releases/download/Lite_v2026.3.31/patch_kernel_root.2026-3-31.exe)、 [skroot_lite.apk](https://github.com/abcz316/SKRoot-linuxKernelRoot/releases/download/Lite_v2026.3.31/SKRoot_Lite.2026-3-20.apk) | | 46 | +1.下载源码编译或**下载编译产物**: [patch_kernel_root.exe](https://github.com/abcz316/SKRoot-linuxKernelRoot/releases/download/Lite_v2026.4.2/patch_kernel_root.2026-4-2.exe)、 [skroot_lite.apk](https://github.com/abcz316/SKRoot-linuxKernelRoot/releases/download/Lite_v2026.4.2/SKRoot_Lite.2026-3-20.apk) | 47 | 47 |
| 48 | 48 | 2.将内核kernel文件拖拽置`patch_kernel_root.exe`即可一键自动化流程补丁内核,同时会自动生成Root密匙。 | 49 | 49 |
| | 55 | 55 | *目前正在众测中。如想加入测试组织,请关注TG频道:[t.me/skrootabc](https://t.me/skrootabc)* | 56 | 56 |
| 57 | 57 | ## 更新日志: | 58 | | -2026-3: | 59 | | - * 1.修复部分Linux6.12无法解析的问题。 | 60 | | - * 2.修复Linux 5.15会睡死的问题。 | 61 | | - * 3.修复部分Linux4.x内核无法开机的问题。 | 62 | | - * 4.修复CONFIG_THREAD_INFO_IN_TASK判断错误的问题。 | 63 | | - * 5.增强寄生App功能的稳定性。 | | 58 | +2026-4: | | 59 | + * 1.修复一些特殊情况下会死机的问题。 | 64 | 60 |
| 65 | | -2026-2: | 66 | | - * 1.修复su无法独立后台运行的问题。 | 67 | | - * 2.修复Linux 4.4无法解析的问题。 | 68 | | - | 69 | | -2026-1: | | 61 | +2026: | 70 | 62 | * 1.修复审计日志残留痕迹。 | 71 | | - | | 63 | + * 2.修复su无法独立后台运行的问题。 | | 64 | + * 3.修复Linux 4.4无法解析的问题。 | | 65 | + * 4.修复部分Linux6.12无法解析的问题。 | | 66 | + * 5.修复Linux 5.15会睡死的问题。 | | 67 | + * 6.修复部分Linux4.x内核无法开机的问题。 | | 68 | + * 7.修复CONFIG_THREAD_INFO_IN_TASK判断错误的问题。 | | 69 | + * 8.增强寄生App功能的稳定性。 | | 70 | + | 72 | 71 | 2025: | 73 | 72 | * 1.适配Linux6.12。 | 74 | 73 | * 2.修复su部分命令无法执行的问题。 | |
|