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: 调整目录结构,兼容Pro版(模块版) · VVeakee/SKRoot-linuxKernelRoot@a839058

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • patch_kernel_root
    • analyze
      • base_func.h
    • patch_kernel_root.cpp
  • testRoot/jni/kernel_root_kit/core
    • rootkit_simple_encryptor.h
    • rootkit_umbrella.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patch_kernel_root/analyze/base_func.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/base_func.h
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ static bool write_file_bytes(const char* file_path, size_t offset, const char* b
9494
return true;
9595
}
9696

97-
static size_t align8(size_t addr) {
98-
if (addr % 8 != 0) {
99-
addr = (addr + 7) & ~static_cast<size_t>(7); // Align to next 8-byte boundary
97+
static size_t align8(size_t value) {
98+
if (value % 8 != 0) {
99+
value = (value + 7) & ~static_cast<size_t>(7); // Align to next 8-byte boundary
100100
}
101-
return addr;
101+
return value;
102102
}
Collapse file

‎patch_kernel_root/patch_kernel_root.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_kernel_root.cpp
+54-46Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,57 @@ bool parser_seccomp_offset(const std::vector<char> &file_buf, size_t start, std:
2121
return find_current_task_next_register_offset(file_buf, start, mode_name, v_seccomp);
2222
}
2323

24+
void cfi_bypass(const std::vector<char>& file_buf, KernelSymbolOffset &sym, std::vector<patch_bytes_data>& vec_patch_bytes_data) {
25+
if (sym.__cfi_check.offset) {
26+
PATCH_AND_CONSUME(sym.__cfi_check, patch_ret_cmd(file_buf, sym.__cfi_check.offset, vec_patch_bytes_data));
27+
}
28+
if (sym.__cfi_check_fail) {
29+
patch_ret_cmd(file_buf, sym.__cfi_check_fail, vec_patch_bytes_data);
30+
}
31+
if (sym.__cfi_slowpath_diag) {
32+
patch_ret_cmd(file_buf, sym.__cfi_slowpath_diag, vec_patch_bytes_data);
33+
}
34+
if (sym.__cfi_slowpath) {
35+
patch_ret_cmd(file_buf, sym.__cfi_slowpath, vec_patch_bytes_data);
36+
}
37+
if (sym.__ubsan_handle_cfi_check_fail_abort) {
38+
patch_ret_cmd(file_buf, sym.__ubsan_handle_cfi_check_fail_abort, vec_patch_bytes_data);
39+
}
40+
if (sym.__ubsan_handle_cfi_check_fail) {
41+
patch_ret_cmd(file_buf, sym.__ubsan_handle_cfi_check_fail, vec_patch_bytes_data);
42+
}
43+
if (sym.report_cfi_failure) {
44+
patch_ret_1_cmd(file_buf, sym.report_cfi_failure, vec_patch_bytes_data);
45+
}
46+
}
47+
48+
void no_use_patch(const std::vector<char>& file_buf, KernelSymbolOffset &sym, std::vector<patch_bytes_data>& vec_patch_bytes_data) {
49+
if (sym.drm_dev_printk.offset) {
50+
PATCH_AND_CONSUME(sym.drm_dev_printk, patch_ret_cmd(file_buf, sym.drm_dev_printk.offset, vec_patch_bytes_data));
51+
}
52+
if (sym.dev_printk.offset) {
53+
PATCH_AND_CONSUME(sym.dev_printk, patch_ret_cmd(file_buf, sym.dev_printk.offset, vec_patch_bytes_data));
54+
}
55+
if (sym.register_die_notifier.offset) {
56+
PATCH_AND_CONSUME(sym.register_die_notifier, patch_ret_0_cmd(file_buf, sym.register_die_notifier.offset, vec_patch_bytes_data));
57+
}
58+
if (sym.unregister_die_notifier.offset) {
59+
PATCH_AND_CONSUME(sym.unregister_die_notifier, patch_ret_0_cmd(file_buf, sym.unregister_die_notifier.offset, vec_patch_bytes_data));
60+
}
61+
}
62+
63+
void write_all_patch(const char* file_path, std::vector<patch_bytes_data>& vec_patch_bytes_data) {
64+
for (auto& item : vec_patch_bytes_data) {
65+
std::shared_ptr<char> spData(new (std::nothrow) char[item.str_bytes.length() / 2], std::default_delete<char[]>());
66+
hex2bytes((uint8_t*)item.str_bytes.c_str(), (uint8_t*)spData.get());
67+
if (!write_file_bytes(file_path, item.write_addr, spData.get(), item.str_bytes.length() / 2)) {
68+
std::cout << "写入文件发生错误" << std::endl;
69+
}
70+
}
71+
if (vec_patch_bytes_data.size()) {
72+
std::cout << "Done." << std::endl;
73+
}
74+
}
2475

2576
int main(int argc, char* argv[]) {
2677
++argv;
@@ -122,42 +173,8 @@ int main(int argc, char* argv[]) {
122173
}
123174

124175
std::vector<patch_bytes_data> vec_patch_bytes_data;
125-
//cfi bypass
126-
if (sym.__cfi_check.offset) {
127-
PATCH_AND_CONSUME(sym.__cfi_check, patch_ret_cmd(file_buf, sym.__cfi_check.offset, vec_patch_bytes_data));
128-
}
129-
if (sym.__cfi_check_fail) {
130-
patch_ret_cmd(file_buf, sym.__cfi_check_fail, vec_patch_bytes_data);
131-
}
132-
if (sym.__cfi_slowpath_diag) {
133-
patch_ret_cmd(file_buf, sym.__cfi_slowpath_diag, vec_patch_bytes_data);
134-
}
135-
if (sym.__cfi_slowpath) {
136-
patch_ret_cmd(file_buf, sym.__cfi_slowpath, vec_patch_bytes_data);
137-
}
138-
if (sym.__ubsan_handle_cfi_check_fail_abort) {
139-
patch_ret_cmd(file_buf, sym.__ubsan_handle_cfi_check_fail_abort, vec_patch_bytes_data);
140-
}
141-
if (sym.__ubsan_handle_cfi_check_fail) {
142-
patch_ret_cmd(file_buf, sym.__ubsan_handle_cfi_check_fail, vec_patch_bytes_data);
143-
}
144-
if (sym.report_cfi_failure) {
145-
patch_ret_1_cmd(file_buf, sym.report_cfi_failure, vec_patch_bytes_data);
146-
}
147-
148-
// ignore patch
149-
if (sym.drm_dev_printk.offset) {
150-
PATCH_AND_CONSUME(sym.drm_dev_printk, patch_ret_cmd(file_buf, sym.drm_dev_printk.offset, vec_patch_bytes_data));
151-
}
152-
if (sym.dev_printk.offset) {
153-
PATCH_AND_CONSUME(sym.dev_printk, patch_ret_cmd(file_buf, sym.dev_printk.offset, vec_patch_bytes_data));
154-
}
155-
if (sym.register_die_notifier.offset) {
156-
PATCH_AND_CONSUME(sym.register_die_notifier, patch_ret_0_cmd(file_buf, sym.register_die_notifier.offset, vec_patch_bytes_data));
157-
}
158-
if (sym.unregister_die_notifier.offset) {
159-
PATCH_AND_CONSUME(sym.unregister_die_notifier, patch_ret_0_cmd(file_buf, sym.unregister_die_notifier.offset, vec_patch_bytes_data));
160-
}
176+
cfi_bypass(file_buf, sym, vec_patch_bytes_data);
177+
no_use_patch(file_buf, sym, vec_patch_bytes_data);
161178

162179
KernelVersionParser kernel_ver(file_buf);
163180
PatchDoExecve patchDoExecve(file_buf, sym);
@@ -235,16 +252,7 @@ int main(int argc, char* argv[]) {
235252
std::cout << "#是否需要立即写入修改到文件?(1需要;2不需要):" << std::endl;
236253
std::cin >> need_write_modify_in_file;
237254
if (need_write_modify_in_file == 1) {
238-
for (auto& item : vec_patch_bytes_data) {
239-
std::shared_ptr<char> spData(new (std::nothrow) char[item.str_bytes.length() / 2], std::default_delete<char[]>());
240-
hex2bytes((uint8_t*)item.str_bytes.c_str(), (uint8_t*)spData.get());
241-
if (!write_file_bytes(file_path, item.write_addr, spData.get(), item.str_bytes.length() / 2)) {
242-
std::cout << "写入文件发生错误" << std::endl;
243-
}
244-
}
245-
}
246-
if (vec_patch_bytes_data.size()) {
247-
std::cout << "Done." << std::endl;
255+
write_all_patch(file_path, vec_patch_bytes_data);
248256
}
249257
system("pause");
250258
return 0;
Collapse file

‎testRoot/jni/kernel_root_kit/core/rootkit_simple_encryptor.h‎

Copy file name to clipboardExpand all lines: testRoot/jni/kernel_root_kit/core/rootkit_simple_encryptor.h
+19-8Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,57 @@ namespace {
3030

3131
}
3232

33-
static std::string simple_encrypt(const std::string& plain) {
34-
const size_t N = plain.size();
33+
static std::string simple_encrypt_with_key(const std::string& plain, char key) {
34+
size_t N = plain.size();
3535
if (N == 0) {
3636
throw std::invalid_argument("Plaintext cannot be empty");
3737
}
38-
int ki = random_index();
39-
char key = alphabet62[ki];
38+
int ki = idx_of(key);
4039
std::string cipher;
4140
cipher.reserve(N + 1);
4241
cipher.push_back(key);
4342
for (size_t i = 0; i < N; ++i) {
4443
int pi = idx_of(plain[i]);
45-
int ci = (pi + ki + (int)i) % BASE62;
44+
int ci = (pi + ki + static_cast<int>(i)) % BASE62;
4645
cipher.push_back(alphabet62[ci]);
4746
}
4847
return cipher;
4948
}
5049

51-
static std::string simple_decrypt(const std::string& cipher) {
50+
static std::string simple_encrypt(const std::string& plain) {
51+
int ki = random_index();
52+
char key = alphabet62[ki];
53+
return simple_encrypt_with_key(plain, key);
54+
}
55+
56+
static std::string simple_decrypt_with_key(const std::string& cipher, char key) {
5257
const size_t L = cipher.size();
5358
if (L <= 1) {
5459
throw std::invalid_argument("Ciphertext length must be > 1");
5560
}
5661
size_t N = L - 1;
5762

58-
char key = cipher[0];
5963
int ki = idx_of(key);
6064

6165
std::string plain;
6266
plain.reserve(N);
6367

6468
for (size_t i = 0; i < N; ++i) {
6569
int ci = idx_of(cipher[i + 1]);
66-
int pi = (ci - ki - (int)i) % BASE62;
70+
int pi = (ci - ki - static_cast<int>(i)) % BASE62;
6771
if (pi < 0) pi += BASE62;
6872
plain.push_back(alphabet62[pi]);
6973
}
7074
return plain;
7175
}
7276

77+
static std::string simple_decrypt(const std::string& cipher) {
78+
if (cipher.size() <= 1) {
79+
throw std::invalid_argument("Ciphertext length must be > 1");
80+
}
81+
return simple_decrypt_with_key(cipher, cipher[0]);
82+
}
83+
7384
static std::string to_base62(std::size_t num) {
7485
if (num == 0) {
7586
return std::string(1, alphabet62[0]);
Collapse file

‎testRoot/jni/kernel_root_kit/core/rootkit_umbrella.h‎

Copy file name to clipboardExpand all lines: testRoot/jni/kernel_root_kit/core/rootkit_umbrella.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
#include "rootkit_process_cmdline.h"
88
#include "rootkit_su_install_helper.h"
99
#include "rootkit_parasite_app.h"
10+
#include "rootkit_simple_encryptor.h"

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.