GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — SKRoot-linuxKernelRoot/patch_kernel_root/patch_filldir64.cpp at master · VVeakee/SKRoot-linuxKernelRoot Expand file tree/ Copy pathpatch_filldir64.cppMore file actions 88 lines (83 loc) · 3.73 KB / Copy pathpatch_filldir64.cppFile metadata and controls88 lines (83 loc) · 3.73 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 #include "patch_filldir64.h" #include "analyze/base_func.h" #include "3rdparty/aarch64_asm_helper.h" using namespace asmjit; using namespace asmjit::a64; using namespace asmjit::a64::Predicate; PatchFilldir64::PatchFilldir64(const std::vector<char>& file_buf, size_t filldir64) : PatchBase(file_buf), m_filldir64(filldir64) {} PatchFilldir64::~PatchFilldir64() {} size_t PatchFilldir64::patch_filldir64_root_key_guide(size_t root_key_mem_addr, const SymbolRegion& hook_func_start_region, std::vector<patch_bytes_data>& vec_out_patch_bytes_data) { size_t hook_func_start_addr = hook_func_start_region.offset; if (hook_func_start_addr == 0) { return 0; } std::cout << "Start hooking addr: " << std::hex << hook_func_start_addr << std::endl << std::endl; aarch64_asm_info asm_info = init_aarch64_asm(); auto& a = asm_info.a; int root_key_adr_offset = root_key_mem_addr - (hook_func_start_addr + a->offset()); aarch64_asm_adr_x(a, x11, root_key_adr_offset); std::cout << print_aarch64_asm(asm_info) << std::endl; auto [sp_bytes, data_size] = aarch64_asm_to_bytes(asm_info); if (!sp_bytes) { return 0; } std::string str_bytes = bytes2hex((const unsigned char*)sp_bytes.get(), data_size); size_t shellcode_size = str_bytes.length() / 2; if (shellcode_size > hook_func_start_region.size) { std::cout << "[发生错误] patch_filldir64 failed: not enough kernel space." << std::endl; return 0; } vec_out_patch_bytes_data.push_back({ str_bytes, hook_func_start_addr }); patch_jump(m_filldir64, hook_func_start_addr, vec_out_patch_bytes_data); return shellcode_size; } size_t PatchFilldir64::patch_filldir64_core(const SymbolRegion& hook_func_start_region, std::vector<patch_bytes_data>& vec_out_patch_bytes_data) { size_t hook_func_start_addr = hook_func_start_region.offset; if (hook_func_start_addr == 0) { return 0; } std::cout << "Start hooking addr: " << std::hex << hook_func_start_addr << std::endl << std::endl; size_t filldir64_entry_hook_jump_back_addr = m_filldir64 + 4; aarch64_asm_info asm_info = init_aarch64_asm(); auto& a = asm_info.a; Label label_end = a->newLabel(); Label label_cycle_name = a->newLabel(); a->cmp(w2, Imm(16)); a->b(CondCode::kNE, label_end); a->mov(x12, Imm(0)); a->bind(label_cycle_name); a->ldrb(w13, ptr(x1, x12)); a->ldrb(w14, ptr(x11, x12)); a->cmp(w13, w14); a->b(CondCode::kNE, label_end); a->add(x12, x12, Imm(1)); a->cmp(x12, Imm(16)); a->b(CondCode::kLT, label_cycle_name); if (m_kernel_ver_parser.is_kernel_version_less("6.1.0")) { a->mov(x0, xzr); } else { a->mov(x0, Imm(1)); } a->ret(x30); a->bind(label_end); a->mov(x0, x0); aarch64_asm_b(a, (int32_t)(filldir64_entry_hook_jump_back_addr - (hook_func_start_addr + a->offset()))); std::cout << print_aarch64_asm(asm_info) << std::endl; auto [sp_bytes, data_size] = aarch64_asm_to_bytes(asm_info); if (!sp_bytes) { return 0; } std::string str_bytes = bytes2hex((const unsigned char*)sp_bytes.get(), data_size); size_t shellcode_size = str_bytes.length() / 2; if (shellcode_size > hook_func_start_region.size) { std::cout << "[发生错误] patch_filldir64 failed: not enough kernel space." << std::endl; return 0; } char hookOrigCmd[4] = { 0 }; memcpy(&hookOrigCmd, (void*)((size_t)&m_file_buf[0] + m_filldir64), sizeof(hookOrigCmd)); std::string strHookOrigCmd = bytes2hex((const unsigned char*)hookOrigCmd, sizeof(hookOrigCmd)); int end_order_len = a->offset() - 2 * 4; str_bytes = str_bytes.substr(0, (end_order_len) * 2) + strHookOrigCmd + str_bytes.substr((end_order_len + 4) * 2); if (shellcode_size > hook_func_start_region.size) { std::cout << "[发生错误] patch_filldir64 failed: not enough kernel space." << std::endl; return 0; } vec_out_patch_bytes_data.push_back({ str_bytes, hook_func_start_addr }); return shellcode_size; } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |