GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 新增安全性判断,防止无法开机 · namelin2/SKRoot-linuxKernelRoot@aee8152

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • patch_kernel_root
    • ArmAsmHelper.h
    • patch_kernel_root.cpp
    • patch_kernel_root.exe
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patch_kernel_root/ArmAsmHelper.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/ArmAsmHelper.h
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ std::string AsmToBytes(const std::string& strArm64Asm) {
5252
}
5353
if (!line.length()) { continue; }
5454
if (line.length() == 1 && line == "\n") { continue; }
55+
if (line.find("Error") != -1) {
56+
in.close();
57+
return {};
58+
}
5559
if (line.find("AARCH64 GAS") != -1) { continue; }
5660

5761
std::stringstream ssGetMidBuf;
Collapse file

‎patch_kernel_root/patch_kernel_root.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_kernel_root.cpp
+27-4Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ size_t path_do_execve(const char* file_buf, const string& str_root_key, size_t
158158
string strAsmCode = sstrAsm.str();
159159
cout << endl << strAsmCode << endl;
160160
string strBytes = AsmToBytes(strAsmCode);
161+
if(!strBytes.length()) {
162+
return 0;
163+
}
161164
nHookFuncSize = strBytes.length() / 2;
162165
char hookOrigCmd[4] = { 0 };
163166
memcpy(&hookOrigCmd, (void*)((size_t)file_buf + do_execve_entry_addr), sizeof(hookOrigCmd));
@@ -167,6 +170,9 @@ size_t path_do_execve(const char* file_buf, const string& str_root_key, size_t
167170
stringstream sstrAsm2;
168171
sstrAsm2 << "B #" << hook_func_start_addr - do_execve_entry_addr << endl;
169172
string strBytes2 = AsmToBytes(sstrAsm2.str());
173+
if(!strBytes2.length()) {
174+
return 0;
175+
}
170176
vec_out_patch_bytes_data.push_back({ strBytes2, do_execve_entry_addr });
171177
hook_func_start_addr += nHookFuncSize;
172178
return hook_func_start_addr;
@@ -209,6 +215,10 @@ size_t path_avc_denied(const char* file_buf, size_t hook_func_start_addr, size_t
209215
string strAsmCode = sstrAsm.str();
210216
cout << endl << strAsmCode << endl;
211217
string strBytes = AsmToBytes(strAsmCode);
218+
if(!strBytes.length()) {
219+
return 0;
220+
}
221+
212222
size_t nHookFuncSize = strBytes.length() / 2;
213223
char hookOrigCmd[4] = { 0 };
214224
memcpy(&hookOrigCmd, (void*)((size_t)file_buf + avc_denied_entry_addr), sizeof(hookOrigCmd));
@@ -218,6 +228,10 @@ size_t path_avc_denied(const char* file_buf, size_t hook_func_start_addr, size_t
218228
stringstream sstrAsm2;
219229
sstrAsm2 << "B #" << hook_func_start_addr - avc_denied_entry_addr << endl;
220230
string strBytes2 = AsmToBytes(sstrAsm2.str());
231+
if(!strBytes2.length()) {
232+
return 0;
233+
}
234+
221235
vec_out_patch_bytes_data.push_back({ strBytes2, avc_denied_entry_addr });
222236
return hook_func_start_addr + nHookFuncSize;
223237
}
@@ -337,10 +351,19 @@ int main(int argc, char* argv[]) {
337351
cin >> str_root_key;
338352
}
339353
vector<patch_bytes_data> vec_patch_bytes_data;
340-
hook_func_start_addr = path_do_execve(image, str_root_key, hook_func_start_addr, do_execve_entry_addr,
341-
task_struct_offset_cred, task_struct_offset_seccomp, vec_patch_bytes_data);
342-
path_avc_denied(image, hook_func_start_addr, avc_denied_entry_addr, task_struct_offset_cred, vec_patch_bytes_data);
343-
354+
hook_func_start_addr = path_do_execve(image, str_root_key, hook_func_start_addr, do_execve_entry_addr, task_struct_offset_cred, task_struct_offset_seccomp, vec_patch_bytes_data);
355+
if(hook_func_start_addr == 0) {
356+
cout << "生成汇编代码失败!请检查输入的参数!" << endl;
357+
system("pause");
358+
return 0;
359+
}
360+
361+
if(path_avc_denied(image, hook_func_start_addr, avc_denied_entry_addr, task_struct_offset_cred, vec_patch_bytes_data) == 0) {
362+
cout << "生成汇编代码失败!请检查输入的参数!" << endl;
363+
system("pause");
364+
return 0;
365+
}
366+
344367
cout << "#获取ROOT权限的密匙:" << str_root_key.c_str() << endl << endl;
345368

346369
size_t need_write_modify_in_file = 0;
Collapse file

‎patch_kernel_root/patch_kernel_root.exe‎

Copy file name to clipboard
74.5 KB
Binary file not shown.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — 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.