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 — feat: 新增防止冻结进程 · VVeakee/SKRoot-linuxKernelRoot@02efc71

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • patch_kernel_root
    • exe
      • patch_kernel_root.exe
    • patch_avc_denied.cpp
    • patch_avc_denied.h
    • patch_base.cpp
    • patch_base.h
    • patch_do_execve.cpp
    • patch_do_execve.h
    • patch_filldir64.cpp
    • patch_filldir64.h
    • patch_freeze_task.cpp
    • patch_freeze_task.h
    • patch_kernel_root.cpp
    • patch_kernel_root.vcxproj.filters
    • patch_kernel_root.vcxproj
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patch_kernel_root/exe/patch_kernel_root.exe‎

Copy file name to clipboard
16 KB
Binary file not shown.
Collapse file

‎patch_kernel_root/patch_avc_denied.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_avc_denied.cpp
+7-40Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,37 @@
11
#include "patch_avc_denied.h"
22
#include "analyze/ARM_asm.h"
33
PatchAvcDenied::PatchAvcDenied(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
4-
const AnalyzeKernel& analyze_kernel) : m_file_buf(file_buf), m_sym(sym), m_analyze_kernel(analyze_kernel) {
4+
const AnalyzeKernel& analyze_kernel) : PatchBase(file_buf, sym, analyze_kernel) {
55

66
}
77

88
PatchAvcDenied::~PatchAvcDenied()
99
{
1010
}
1111

12-
int PatchAvcDenied::get_atomic_usage_len() {
13-
int len = 8;
14-
if (m_analyze_kernel.is_kernel_version_less("6.6.0")) {
15-
len = 4;
16-
}
17-
return len;
18-
}
19-
20-
int PatchAvcDenied::get_securebits_padding() {
21-
if (get_atomic_usage_len() == 8) {
22-
return 4;
23-
}
24-
return 0;
25-
}
26-
27-
std::string PatchAvcDenied::get_cap_ability_max() {
28-
std::string cap;
29-
if (m_analyze_kernel.is_kernel_version_less("5.8.0")) {
30-
cap = "0x3FFFFFFFFF";
31-
}
32-
else if (m_analyze_kernel.is_kernel_version_less("5.9.0")) {
33-
cap = "0xFFFFFFFFFF";
34-
}
35-
else {
36-
cap = "0x1FFFFFFFFFF";
37-
}
38-
return cap;
39-
}
40-
41-
int PatchAvcDenied::get_need_write_cap_cnt() {
42-
int cnt = 0;
43-
if (m_analyze_kernel.is_kernel_version_less("4.3.0")) {
12+
int PatchAvcDenied::get_need_read_cap_cnt() {
13+
int cnt = get_cap_cnt();
14+
if (cnt < 5) {
4415
cnt = 3;
4516
}
46-
else {
47-
cnt = 5;
48-
}
4917
return cnt;
5018
}
5119

5220

5321
size_t PatchAvcDenied::patch_avc_denied(size_t hook_func_start_addr, const std::vector<size_t>& task_struct_offset_cred,
5422
std::vector<patch_bytes_data>& vec_out_patch_bytes_data) {
5523
size_t avc_denied_addr = m_sym.avc_denied;
56-
int atomic_usage_len = get_atomic_usage_len();
57-
int securebits_padding = get_securebits_padding();
24+
int atomic_usage_len = get_cred_atomic_usage_len();
25+
int securebits_padding = get_cred_securebits_padding();
5826
std::string cap_ability_max = get_cap_ability_max();
59-
int cap_cnt = get_need_write_cap_cnt();
27+
int cap_cnt = get_need_read_cap_cnt();
6028

6129
size_t avc_denied_entry_hook_jump_back_addr = avc_denied_addr + 4;
6230
auto next_asm_line_bytes_cnt = (task_struct_offset_cred.size() - 1) * 4;
6331
std::stringstream sstrAsm;
6432
sstrAsm
6533
<< "STP X7, X8, [sp, #-16]!" << std::endl
6634
<< "STP X9, X10, [sp, #-16]!" << std::endl;
67-
6835
sstrAsm << "MRS X7, SP_EL0" << std::endl;
6936
for (auto x = 0; x < task_struct_offset_cred.size(); x++) {
7037
if (x != task_struct_offset_cred.size() - 1) {
Collapse file

‎patch_kernel_root/patch_avc_denied.h‎

Copy file name to clipboard
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#pragma once
22
#include <iostream>
33
#include <vector>
4-
#include "patch_kernel_root.h"
5-
#include "analyze/analyze_kernel.h"
6-
class PatchAvcDenied
4+
#include "patch_base.h"
5+
class PatchAvcDenied : public PatchBase
76
{
87
public:
98
PatchAvcDenied(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
@@ -14,11 +13,5 @@ class PatchAvcDenied
1413
std::vector<patch_bytes_data>& vec_out_patch_bytes_data);
1514

1615
private:
17-
int get_atomic_usage_len();
18-
int get_securebits_padding();
19-
std::string get_cap_ability_max();
20-
int get_need_write_cap_cnt();
21-
const std::vector<char>& m_file_buf;
22-
const KernelSymbolOffset& m_sym;
23-
const AnalyzeKernel& m_analyze_kernel;
16+
int get_need_read_cap_cnt();
2417
};
Collapse file

‎patch_kernel_root/patch_base.cpp‎

Copy file name to clipboard
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "patch_base.h"
2+
#include "analyze/ARM_asm.h"
3+
PatchBase::PatchBase(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
4+
const AnalyzeKernel& analyze_kernel) : m_file_buf(file_buf), m_sym(sym), m_analyze_kernel(analyze_kernel) {
5+
6+
}
7+
8+
PatchBase::~PatchBase()
9+
{
10+
}
11+
12+
int PatchBase::get_cred_atomic_usage_len() {
13+
int len = 8;
14+
if (m_analyze_kernel.is_kernel_version_less("6.6.0")) {
15+
len = 4;
16+
}
17+
return len;
18+
}
19+
20+
int PatchBase::get_cred_securebits_padding() {
21+
if (get_cred_atomic_usage_len() == 8) {
22+
return 4;
23+
}
24+
return 0;
25+
}
26+
27+
std::string PatchBase::get_cap_ability_max() {
28+
std::string cap;
29+
if (m_analyze_kernel.is_kernel_version_less("5.8.0")) {
30+
cap = "0x3FFFFFFFFF";
31+
}
32+
else if (m_analyze_kernel.is_kernel_version_less("5.9.0")) {
33+
cap = "0xFFFFFFFFFF";
34+
}
35+
else {
36+
cap = "0x1FFFFFFFFFF";
37+
}
38+
return cap;
39+
}
40+
41+
int PatchBase::get_cap_cnt() {
42+
int cnt = 0;
43+
if (m_analyze_kernel.is_kernel_version_less("4.3.0")) {
44+
cnt = 4;
45+
} else {
46+
cnt = 5;
47+
}
48+
return cnt;
49+
}
Collapse file

‎patch_kernel_root/patch_base.h‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
#include <iostream>
3+
#include <vector>
4+
#include "patch_kernel_root.h"
5+
#include "analyze/analyze_kernel.h"
6+
class PatchBase
7+
{
8+
public:
9+
PatchBase(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
10+
const AnalyzeKernel& analyze_kernel);
11+
~PatchBase();
12+
protected:
13+
int get_cred_atomic_usage_len();
14+
int get_cred_securebits_padding();
15+
std::string get_cap_ability_max();
16+
int get_cap_cnt();
17+
const std::vector<char>& m_file_buf;
18+
const KernelSymbolOffset& m_sym;
19+
const AnalyzeKernel& m_analyze_kernel;
20+
};
Collapse file

‎patch_kernel_root/patch_do_execve.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_do_execve.cpp
+4-37Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "patch_do_execve.h"
33
#include "analyze/ARM_asm.h"
44
PatchDoExecve::PatchDoExecve(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
5-
const AnalyzeKernel& analyze_kernel) : m_file_buf(file_buf), m_sym(sym), m_analyze_kernel(analyze_kernel) {
5+
const AnalyzeKernel& analyze_kernel) : PatchBase(file_buf, sym, analyze_kernel) {
66

77
}
88
PatchDoExecve::~PatchDoExecve() {}
@@ -39,41 +39,8 @@ std::pair<size_t, size_t> PatchDoExecve::get_do_execve_param() {
3939
return { do_execve_addr, do_execve_key_reg};
4040
}
4141

42-
int PatchDoExecve::get_atomic_usage_len() {
43-
int len = 8;
44-
if (m_analyze_kernel.is_kernel_version_less("6.6.0")) {
45-
len = 4;
46-
}
47-
return len;
48-
}
49-
50-
int PatchDoExecve::get_securebits_padding() {
51-
if (get_atomic_usage_len() == 8) {
52-
return 4;
53-
}
54-
return 0;
55-
}
56-
57-
std::string PatchDoExecve::get_cap_ability_max() {
58-
std::string cap;
59-
if (m_analyze_kernel.is_kernel_version_less("5.8.0")) {
60-
cap = "0x3FFFFFFFFF";
61-
} else if (m_analyze_kernel.is_kernel_version_less("5.9.0")) {
62-
cap = "0xFFFFFFFFFF";
63-
} else {
64-
cap = "0x1FFFFFFFFFF";
65-
}
66-
return cap;
67-
}
68-
6942
int PatchDoExecve::get_need_write_cap_cnt() {
70-
int cnt = 0;
71-
if (m_analyze_kernel.is_kernel_version_less("4.3.0")) {
72-
cnt = 4;
73-
} else {
74-
cnt = 5;
75-
}
76-
return cnt;
43+
return get_cap_cnt();
7744
}
7845

7946
size_t PatchDoExecve::patch_do_execve(const std::string& str_root_key, size_t hook_func_start_addr,
@@ -82,8 +49,8 @@ size_t PatchDoExecve::patch_do_execve(const std::string& str_root_key, size_t ho
8249
std::vector<patch_bytes_data>& vec_out_patch_bytes_data) {
8350

8451
auto [do_execve_addr, do_execve_key_reg] = get_do_execve_param();
85-
int atomic_usage_len = get_atomic_usage_len();
86-
int securebits_padding = get_securebits_padding();
52+
int atomic_usage_len = get_cred_atomic_usage_len();
53+
int securebits_padding = get_cred_securebits_padding();
8754
std::string cap_ability_max = get_cap_ability_max();
8855
int cap_cnt = get_need_write_cap_cnt();
8956

Collapse file

‎patch_kernel_root/patch_do_execve.h‎

Copy file name to clipboard
+2-9Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#pragma once
22
#include <iostream>
33
#include <vector>
4-
#include "patch_kernel_root.h"
5-
#include "analyze/analyze_kernel.h"
6-
class PatchDoExecve
4+
#include "patch_base.h"
5+
class PatchDoExecve : public PatchBase
76
{
87
public:
98
PatchDoExecve(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
@@ -17,11 +16,5 @@ class PatchDoExecve
1716

1817
private:
1918
std::pair<size_t, size_t> get_do_execve_param();
20-
int get_atomic_usage_len();
21-
int get_securebits_padding();
22-
std::string get_cap_ability_max();
2319
int get_need_write_cap_cnt();
24-
const std::vector<char>& m_file_buf;
25-
const KernelSymbolOffset & m_sym;
26-
const AnalyzeKernel& m_analyze_kernel;
2720
};
Collapse file

‎patch_kernel_root/patch_filldir64.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_filldir64.cpp
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "patch_filldir64.h"
22
#include "analyze/ARM_asm.h"
33
PatchFilldir64::PatchFilldir64(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
4-
const AnalyzeKernel& analyze_kernel) : m_file_buf(file_buf), m_sym(sym), m_analyze_kernel(analyze_kernel) {
4+
const AnalyzeKernel& analyze_kernel) : PatchBase(file_buf, sym, analyze_kernel) {
55

66
}
77

@@ -46,7 +46,6 @@ size_t PatchFilldir64::patch_filldir64(size_t root_key_addr_offset, size_t hook_
4646
return 0;
4747
}
4848
size_t nHookFuncSize = strBytes.length() / 2;
49-
5049
char hookOrigCmd[4] = { 0 };
5150
memcpy(&hookOrigCmd, (void*)((size_t)&m_file_buf[0] + filldir64_addr), sizeof(hookOrigCmd));
5251
std::string strHookOrigCmd = bytes_2_hex_str((const unsigned char*)hookOrigCmd, sizeof(hookOrigCmd));
Collapse file

‎patch_kernel_root/patch_filldir64.h‎

Copy file name to clipboard
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
#pragma once
22
#include <iostream>
33
#include <vector>
4-
#include "patch_kernel_root.h"
5-
#include "analyze/analyze_kernel.h"
6-
class PatchFilldir64
4+
#include "patch_base.h"
5+
class PatchFilldir64 : public PatchBase
76
{
87
public:
98
PatchFilldir64(const std::vector<char>& file_buf, const KernelSymbolOffset& sym,
109
const AnalyzeKernel& analyze_kernel);
1110
~PatchFilldir64();
1211

1312
size_t patch_filldir64(size_t root_key_addr_offset, size_t hook_func_start_addr, std::vector<patch_bytes_data>& vec_out_patch_bytes_data);
14-
15-
private:
16-
const std::vector<char>& m_file_buf;
17-
const KernelSymbolOffset& m_sym;
18-
const AnalyzeKernel& m_analyze_kernel;
1913
};

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.