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版本更新4.4.8,解决一加越狱被Oppo内部接口侦测,导致泄露痕迹的问题。 · pigadmin/SKRoot-linuxKernelRoot@1eb1705

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Pro(众测开放中)/src/testModule
    • kernel_module_kit
      • include
        • module_web_ui_http_handler.h
      • lib
        • libkernel_module_kit_static.a
    • module_hide_sh_exec
      • idle_killer.cpp
      • idle_killer.h
      • module_hide_sh_exec.cpp
      • su_interactive.cpp
      • su_interactive.h
      • webroot
        • file-manager.js
        • index.html
        • main.js
        • request.js
        • style.css
        • terminal-core.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Pro(众测开放中)/src/testModule/kernel_module_kit/include/module_web_ui_http_handler.h‎

Copy file name to clipboardExpand all lines: Pro(众测开放中)/src/testModule/kernel_module_kit/include/module_web_ui_http_handler.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ class WebUIHttpHandler : public CivetHandler {
2020
***************************************************************************/
2121
virtual void onPrepareCreate(const char* root_key, const char* module_private_dir, uint32_t port) {}
2222

23+
/***************************************************************************
24+
* WebUI 服务器创建后回调
25+
* 参数: server CivetWeb 服务器实例指针,可用于后续主动关闭服务器
26+
***************************************************************************/
27+
virtual void onServerCreated(CivetServer* server) {}
28+
2329
/***************************************************************************
2430
* 响应处理 GET 请求
2531
* 参数: server CivetWeb 服务器实例指针
Collapse file

‎Pro(众测开放中)/src/testModule/kernel_module_kit/lib/libkernel_module_kit_static.a‎

Copy file name to clipboard
68 Bytes
Binary file not shown.
Collapse file

‎Pro(众测开放中)/src/testModule/module_hide_sh_exec/idle_killer.cpp‎

Copy file name to clipboardExpand all lines: Pro(众测开放中)/src/testModule/module_hide_sh_exec/idle_killer.cpp
+21-5Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ static int64_t now_ns() {
44
using namespace std::chrono;
55
return duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
66
}
7+
78
static int64_t to_ns(std::chrono::seconds s) {
89
using namespace std::chrono;
910
return duration_cast<nanoseconds>(s).count();
@@ -12,22 +13,37 @@ static int64_t to_ns(std::chrono::seconds s) {
1213
void IdleKiller::start(std::chrono::seconds timeout, OnTimeout cb) {
1314
m_timeout_ns = to_ns(timeout);
1415
m_on_timeout = std::move(cb);
16+
1517
touch();
18+
1619
bool expected = false;
17-
if (!m_started.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) return;
20+
if (!m_started.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
21+
return;
22+
}
23+
1824
std::thread([this] {
1925
for (;;) {
2026
const auto last = m_last_activity_ns.load(std::memory_order_acquire);
2127
const auto now = now_ns();
2228

2329
if (last != 0 && (now - last) > m_timeout_ns.load(std::memory_order_acquire)) {
24-
// 先取出回调再执行,避免回调里 _exit 导致奇怪竞态
30+
// 先刷新一次,避免 callback 返回 false 后每秒疯狂触发
31+
touch();
2532
auto cb = m_on_timeout; // copy
26-
if (cb) cb();
27-
return;
33+
bool should_stop_thread = true;
34+
if (cb) {
35+
should_stop_thread = cb();
36+
}
37+
if (should_stop_thread) {
38+
return;
39+
}
40+
continue;
2841
}
2942
std::this_thread::sleep_for(std::chrono::seconds(1));
3043
}
3144
}).detach();
3245
}
33-
void IdleKiller::touch() { m_last_activity_ns.store(now_ns(), std::memory_order_release); }
46+
47+
void IdleKiller::touch() {
48+
m_last_activity_ns.store(now_ns(), std::memory_order_release);
49+
}
Collapse file

‎Pro(众测开放中)/src/testModule/module_hide_sh_exec/idle_killer.h‎

Copy file name to clipboardExpand all lines: Pro(众测开放中)/src/testModule/module_hide_sh_exec/idle_killer.h
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
class IdleKiller {
99
public:
10-
using OnTimeout = std::function<void()>;
10+
// 返回 true:本次超时已经处理完,IdleKiller 线程结束
11+
// 返回 false:本次不杀,继续监控
12+
using OnTimeout = std::function<bool()>;
13+
1114
void start(std::chrono::seconds timeout, OnTimeout cb);
1215
void touch();
16+
1317
private:
14-
std::atomic<bool> m_started{false};
18+
std::atomic<bool> m_started{false};
1519
std::atomic<int64_t> m_last_activity_ns{0};
1620
std::atomic<int64_t> m_timeout_ns{0};
17-
OnTimeout m_on_timeout;
21+
OnTimeout m_on_timeout;
1822
};
Collapse file

‎Pro(众测开放中)/src/testModule/module_hide_sh_exec/module_hide_sh_exec.cpp‎

Copy file name to clipboardExpand all lines: Pro(众测开放中)/src/testModule/module_hide_sh_exec/module_hide_sh_exec.cpp
+64-11Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
#include <sys/stat.h>
99
#include <sys/statvfs.h>
1010
#include <sys/xattr.h>
11+
#include <unistd.h>
12+
#include <signal.h>
13+
#include <time.h>
1114
#include <cerrno>
1215
#include <cstring>
16+
#include <vector>
1317

1418
#include "kernel_module_kit_umbrella.h"
1519

@@ -62,8 +66,18 @@ static std::string read_quick_actions_json() {
6266
return json;
6367
}
6468

65-
static void create_work_dir(const char* module_private_dir) {
66-
fs::path work_dir = fs::path(module_private_dir) / WORK_DIR_NAME;
69+
static void write_terminal_keep_mode(bool enabled) {
70+
kernel_module::write_bool_disk_storage("terminal_keep_mode", enabled);
71+
}
72+
73+
static bool read_terminal_keep_mode() {
74+
bool enabled = false;
75+
kernel_module::read_bool_disk_storage("terminal_keep_mode", enabled);
76+
return enabled;
77+
}
78+
79+
static void create_work_dir(const char* module_private_dir, const char* work_dir_name) {
80+
fs::path work_dir = fs::path(module_private_dir) / work_dir_name;
6781
std::error_code ec;
6882
fs::create_directories(work_dir, ec);
6983
::chmod(work_dir.c_str(), 0777);
@@ -73,7 +87,7 @@ static void create_work_dir(const char* module_private_dir) {
7387

7488
std::string module_on_install(const char* root_key, const char* module_private_dir) {
7589
add_quick_actions({"getenforce", "ls /", "id"});
76-
create_work_dir(module_private_dir);
90+
create_work_dir(module_private_dir, WORK_DIR_NAME);
7791
return "";
7892
}
7993

@@ -91,19 +105,41 @@ static void wait_parent_exit(const std::string& root_key, pid_t ppid) {
91105
}
92106
}
93107

108+
94109
// WebUI HTTP服务器回调函数
95110
class MyWebHttpHandler : public kernel_module::WebUIHttpHandler {
96111
public:
97112
void onPrepareCreate(const char* root_key, const char* module_private_dir, uint32_t port) override {
98113
m_root_key = root_key;
114+
99115
m_hide_dir = (fs::path(module_private_dir) / WORK_DIR_NAME).string();
100-
m_su_interactive.start();
101-
fork_sh_process_daemon();
102-
m_idle_killer.start(std::chrono::seconds(20), [this] {
116+
m_keep_terminal = read_terminal_keep_mode();
117+
m_su_interactive.start(module_private_dir);
118+
if (!m_keep_terminal) {
119+
fork_sh_process_daemon();
120+
}
121+
m_idle_killer.start(std::chrono::seconds(20), [this]() -> bool {
122+
if (m_keep_terminal) {
123+
if (!m_su_interactive.isShellForeground()) {
124+
// 当前 shell 不在前台,说明可能有用户后台程序在跑。
125+
// 这次不杀,IdleKiller 继续监控。
126+
return false;
127+
}
128+
printf("[module_hide_sh_exec] shell foreground, idle kill!\n");
129+
} else {
130+
printf("[module_hide_sh_exec] idle kill!\n");
131+
}
132+
if (m_server) m_server->close();
133+
m_su_interactive.stop(true);
103134
_exit(0);
135+
return true;
104136
});
105137
}
106138

139+
void onServerCreated(CivetServer* server) override {
140+
m_server = server;
141+
}
142+
107143
bool handlePost(CivetServer* server, struct mg_connection* conn, const std::string& path, const std::string& body) override {
108144
//printf("[module_hide_sh_exec] POST request\nPath: %s\nBody: %s\n", path.c_str(), body.c_str());
109145
std::string resp;
@@ -116,6 +152,8 @@ class MyWebHttpHandler : public kernel_module::WebUIHttpHandler {
116152
else if(path == "/getHideDir") resp = handle_get_hide_dir();
117153
else if(path == "/checkFileType") resp = handle_check_file_type(body);
118154
else if(path == "/checkExecMount") resp = handle_check_exec_mount(body);
155+
else if(path == "/getTerminalKeepMode") resp = handle_get_terminal_keep_mode();
156+
else if(path == "/saveTerminalKeepMode") resp = handle_save_terminal_keep_mode(body);
119157
else if(path == "/exitWebui") resp = handle_exit_webui();
120158

121159
kernel_module::webui::send_text(conn, 200, resp);
@@ -127,11 +165,13 @@ class MyWebHttpHandler : public kernel_module::WebUIHttpHandler {
127165
private:
128166
void fork_sh_process_daemon() {
129167
pid_t shell_pid = m_su_interactive.get_shell_pid();
168+
if (shell_pid <= 0) return;
169+
130170
pid_t ppid = getpid();
131171
pid_t child = fork();
132172
if(child == 0) {
133173
wait_parent_exit(m_root_key, ppid);
134-
printf("[module_hide_sh_exec] kill sh!\n");
174+
printf("[module_hide_sh_exec] kill sh: %d\n", shell_pid);
135175
kill(shell_pid, SIGKILL);
136176
_exit(0);
137177
}
@@ -213,23 +253,36 @@ class MyWebHttpHandler : public kernel_module::WebUIHttpHandler {
213253
return is_noexec ? "can not exec" : "can exec";
214254
}
215255

256+
std::string handle_get_terminal_keep_mode() {
257+
return read_terminal_keep_mode() ? "1" : "0";
258+
}
259+
260+
std::string handle_save_terminal_keep_mode(const std::string& body) {
261+
write_terminal_keep_mode(body == "1");
262+
return "OK";
263+
}
264+
216265
std::string handle_exit_webui() {
217-
_exit(0);
218-
return "OK";
266+
if(m_server) m_server->close();
267+
m_su_interactive.stop(true);
268+
_exit(0);
269+
return "OK";
219270
}
220271
private:
221272
std::string m_root_key;
273+
CivetServer* m_server = nullptr;
222274
std::string m_hide_dir;
275+
bool m_keep_terminal = false;
223276
SuInteractive m_su_interactive;
224277
IdleKiller m_idle_killer;
225278
};
226279

227280
// SKRoot 模块名片
228281
// 字段说明见 module_descriptor.h
229282
SKROOT_MODULE_NAME("隐蔽的系统终端")
230-
SKROOT_MODULE_VERSION("3.0.8")
283+
SKROOT_MODULE_VERSION("3.1.0")
231284
SKROOT_MODULE_DESC("提供独立隐蔽的 sh 执行通道,彻底替代终端类 App,避免终端类 App 带来的特征暴露。")
232-
SKROOT_MODULE_AUTHOR("SKRoot")
285+
SKROOT_MODULE_AUTHOR("SKRoot、斓梦语")
233286
SKROOT_MODULE_ID32("zse9vkTjLjWXbafvx8Mlh1MTf8SMTUEL")
234287
SKROOT_MODULE_ON_INSTALL(module_on_install)
235288
SKROOT_MODULE_WEB_UI(MyWebHttpHandler)

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.