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 — 新版本:新增安全位securebits与seccomp清除功能 · sekaiacg/SKRoot-linuxKernelRoot@7c1de38

File tree

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

‎patch_kernel_root/patch_kernel_root.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_kernel_root.cpp
+30-17Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ string generate_random_root_key() {
6060
size_t path_do_execve(const char* file_buf, const string& str_root_key, size_t hook_func_start_addr,
6161
size_t do_execve_entry_addr,
6262
size_t task_struct_offset_cred,
63+
size_t task_struct_offset_seccomp,
6364
vector<patch_bytes_data>& vec_out_patch_bytes_data) {
6465

6566
size_t do_execve_entry_hook_jump_back_addr = do_execve_entry_addr + 4;
@@ -79,38 +80,40 @@ size_t path_do_execve(const char* file_buf, const string& str_root_key, size_t
7980
<< "STP X11, X12, [sp, #-16]!" << endl
8081
<< "MOV X7, 0xFFFFFFFFFFFFF001" << endl
8182
<< "CMP X1, X7" << endl
82-
<< "BCS #112" << endl
83+
<< "BCS #120" << endl
8384
<< "LDR X7, [X1]" << endl
84-
<< "CBZ X7, #104" << endl
85+
<< "CBZ X7, #112" << endl
8586
<< "ADR X8, #-84" << endl
8687
<< "MOV X9, #0" << endl
8788
<< "LDRB W10, [X7, X9]" << endl
88-
<< "CBZ W10, #88" << endl
89+
<< "CBZ W10, #96" << endl
8990
<< "LDRB W11, [X8, X9]" << endl
90-
<< "CBZ W11, #80" << endl
91+
<< "CBZ W11, #88" << endl
9192
<< "CMP W10, W11" << endl
92-
<< "B.NE #72" << endl
93+
<< "B.NE #80" << endl
9394
<< "ADD X9, X9, 1" << endl
9495
<< "CMP X9, #" << str_root_key.length() << endl
9596
<< "BLT #-32" << endl
9697
<< "MRS X8, SP_EL0" << endl
97-
<< "LDR X8, [X8, #" << task_struct_offset_cred << "]" << endl
98+
<< "LDR X10, [X8, #" << task_struct_offset_cred << "]" << endl
9899
<< "MOV X7, #4" << endl
99100
<< "MOV W9, WZR" << endl
100-
<< "STR W9, [X8, X7]" << endl
101+
<< "STR W9, [X10, X7]" << endl
101102
<< "ADD X7, X7, 4" << endl
102-
<< "CMP X7, #36" << endl
103+
<< "CMP X7, #40" << endl
103104
<< "BLT #-12" << endl
104-
<< "ADD X7, X7, 4" << endl
105-
<< "MOV X9, 0xFFFFFFFFFFFFFFFF" << endl
106-
<< "STR X9, [X8, X7]" << endl
107-
<< "ADD X7, X7, 8" << endl
105+
<< "MOV W9, 0xFFFFFFFF" << endl
108106
<< "CMP X7, #80" << endl
109-
<< "BLT #-12" << endl
107+
<< "BLT #-24" << endl
108+
<< "LDXR W10, [X8]" << endl
109+
<< "BIC W10, W10,#0xFFF" << endl
110+
<< "STXR W11, W10, [X8]" << endl
111+
<< "STR WZR, [X8, #" << task_struct_offset_seccomp << "]" << endl
112+
<< "STR XZR, [X8, #" << task_struct_offset_seccomp + 8 << "]" << endl
110113
<< "LDP X11, X12, [sp], #16" << endl
111114
<< "LDP X9, X10, [sp], #16" << endl
112115
<< "LDP X7, X8, [sp], #16" << endl
113-
<< "B #" << do_execve_entry_hook_jump_back_addr - (hook_func_start_addr + 0x94) << endl;
116+
<< "B #" << do_execve_entry_hook_jump_back_addr - (hook_func_start_addr + 0x9C) << endl;
114117
string strAsmCode = sstrAsm.str();
115118
cout << endl << strAsmCode << endl;
116119
string strBytes = AsmToBytes(strAsmCode);
@@ -234,10 +237,19 @@ int main(int argc, char* argv[]) {
234237

235238
size_t task_struct_offset_cred = -1;
236239
while (task_struct_offset_cred % 8) {
237-
cout << "请输入task_struct结构体里cred的十六进制偏移值(从setresuid的头部能看到):" << endl;
240+
cout << "请输入task_struct结构体里cred的十六进制偏移值(从proc_pid_status里能看到):" << endl;
238241
cin >> hex >> task_struct_offset_cred;
239242
if (task_struct_offset_cred % 8) {
240-
cout << "信息输入有误" << endl;
243+
cout << "输入的信息有错误" << endl;
244+
}
245+
}
246+
247+
size_t task_struct_offset_seccomp = -1;
248+
while (task_struct_offset_seccomp % 8) {
249+
cout << "请输入task_struct结构体里seccomp的十六进制偏移值(从proc_pid_status里能看到):" << endl;
250+
cin >> hex >> task_struct_offset_seccomp;
251+
if (task_struct_offset_seccomp % 8) {
252+
cout << "输入的信息有错误" << endl;
241253
}
242254
}
243255

@@ -252,7 +264,8 @@ int main(int argc, char* argv[]) {
252264
cin >> str_root_key;
253265
}
254266
vector<patch_bytes_data> vec_patch_bytes_data;
255-
hook_func_start_addr = path_do_execve(image, str_root_key, hook_func_start_addr, do_execve_entry_addr, task_struct_offset_cred, vec_patch_bytes_data);
267+
hook_func_start_addr = path_do_execve(image, str_root_key, hook_func_start_addr, do_execve_entry_addr,
268+
task_struct_offset_cred, task_struct_offset_seccomp, vec_patch_bytes_data);
256269
path_avc_denied(image, hook_func_start_addr, avc_denied_entry_addr, task_struct_offset_cred, vec_patch_bytes_data);
257270

258271
cout << "#获取ROOT权限的密匙:" << str_root_key.c_str() << endl << endl;

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.