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 — 优化交互逻辑 · Cubeeeee/SKRoot-linuxKernelRoot@df51bc8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • PermissionManager/app/src/main
    • cpp
      • root.cpp
    • java/com/linux/permissionmanager
      • MainActivity.java
    • res/layout
      • activity_main.xml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎PermissionManager/app/src/main/cpp/root.cpp‎

Copy file name to clipboardExpand all lines: PermissionManager/app/src/main/cpp/root.cpp
+29-20Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ string getCapabilityInfo()
5353
sstrCapInfo << "cap effective:" << hex <<cap_data->effective << "," << std::endl
5454
<<"cap permitted:"<< hex << cap_data->permitted<< "," << std::endl
5555
<<"cap inheritable:"<< hex <<cap_data->inheritable<< std::endl;
56-
sstrCapInfo << "native check SELinux status:"<< (kernel_root::is_disable_selinux_status() ? "0" : "1") <<"\n";
57-
5856
FILE * fp = popen("getenforce", "r");
5957
if (fp)
6058
{
@@ -68,31 +66,43 @@ string getCapabilityInfo()
6866
return sstrCapInfo.str();
6967
}
7068

71-
extern "C" JNIEXPORT jint JNICALL
72-
Java_com_linux_permissionmanager_MainActivity_getUid(
73-
JNIEnv* env,
74-
jobject /* this */) {
75-
return getuid();
76-
}
77-
7869
extern "C" JNIEXPORT jstring JNICALL
79-
Java_com_linux_permissionmanager_MainActivity_getCapabilityInfo(
80-
JNIEnv* env,
81-
jobject /* this */) {
82-
83-
return env->NewStringUTF(getCapabilityInfo().c_str());
84-
}
85-
86-
extern "C" JNIEXPORT jint JNICALL
87-
Java_com_linux_permissionmanager_MainActivity_getRoot(
70+
Java_com_linux_permissionmanager_MainActivity_testRoot(
8871
JNIEnv* env,
8972
jobject /* this */,
9073
jstring rootKey) {
9174
const char *str1 = env->GetStringUTFChars(rootKey, 0);
9275
string strRootKey= str1;
9376
env->ReleaseStringUTFChars(rootKey, str1);
9477

95-
return kernel_root::get_root(strRootKey.c_str());
78+
std::string result;
79+
fork_pipe_info finfo;
80+
ssize_t err = 0;
81+
if(fork_pipe_child_process(finfo)) {
82+
err = kernel_root::get_root(strRootKey.c_str());
83+
result = "getRoot:";
84+
result += std::to_string(err);
85+
result += "\n\n";
86+
if(err == 0) {
87+
result += getCapabilityInfo();
88+
result += "\n\n";
89+
}
90+
write_errcode_to_father(finfo, err);
91+
write_string_to_father(finfo, result);
92+
_exit(0);
93+
return 0;
94+
}
95+
err = 0;
96+
if(!wait_fork_child_process(finfo)) {
97+
err = -1120001;
98+
} else {
99+
if(!read_errcode_from_child(finfo, err)) {
100+
err = -1120002;
101+
} else if(!read_string_from_child(finfo, result)) {
102+
err = -1120003;
103+
}
104+
}
105+
return env->NewStringUTF(result.c_str());
96106
}
97107

98108
extern "C" JNIEXPORT jstring JNICALL
@@ -242,7 +252,6 @@ Java_com_linux_permissionmanager_MainActivity_autoSuEnvInject(
242252
return env->NewStringUTF(sstr.str().c_str());
243253
}
244254
}
245-
246255
pid_t pid;
247256
err = safe_wait_and_find_cmdline_process(strRootKey.c_str(), strTargetProcessCmdline.c_str(), 60*1000, pid);
248257

Collapse file

‎PermissionManager/app/src/main/java/com/linux/permissionmanager/MainActivity.java‎

Copy file name to clipboardExpand all lines: PermissionManager/app/src/main/java/com/linux/permissionmanager/MainActivity.java
+5-28Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
public class MainActivity extends AppCompatActivity {
4949

50-
private String rootKey = "wxqI1MByBPNTLPwgzEsoVE9RRvvZIZNJ4XKEZnnYaPjHUURy";
50+
private String rootKey = "mUBcNll4mhenWlvYEWZF4yOHm5aOPklyq0LAUIAbV0L7R0Ub";
5151
private String suBasePath = "/data/local/tmp";
5252
private String lastInputCmd = "id";
5353

@@ -86,26 +86,15 @@ public void onClick(DialogInterface dialog, int which) {
8686
mEdit.putString("rootKey", rootKey);
8787
mEdit.commit();
8888
}
89-
90-
;
9189
});
9290
builder.show();
9391

9492

95-
Button show_myself_info_btn = findViewById(R.id.show_myself_info_btn);
96-
show_myself_info_btn.setOnClickListener(new View.OnClickListener() {
97-
@Override
98-
public void onClick(View v) {
99-
showConsoleMsg(getCapabilityInfo());
100-
}
101-
});
102-
103-
Button get_root_btn = findViewById(R.id.get_root_btn);
104-
get_root_btn.setOnClickListener(new View.OnClickListener() {
93+
Button test_root_btn = findViewById(R.id.test_root_btn);
94+
test_root_btn.setOnClickListener(new View.OnClickListener() {
10595
@Override
10696
public void onClick(View v) {
107-
int ret = getRoot(rootKey);
108-
showConsoleMsg("getRoot: " + ret);
97+
showConsoleMsg(testRoot(rootKey));
10998
}
11099
});
111100

@@ -168,10 +157,6 @@ public void onClick(DialogInterface dialog, int which) {
168157
su_env_install_btn.setOnClickListener(new View.OnClickListener() {
169158
@Override
170159
public void onClick(View v) {
171-
if(getUid() == 0) {
172-
showConsoleMsg("【错误】请重新打开APP,在普通权限下点击此按钮,不要将APP提升为ROOT");
173-
return;
174-
}
175160
//1.获取su工具文件路径
176161
String suOriginalFilePath = WirteSuToolsFilePath("su", MainActivity.this);
177162
showConsoleMsg("su origin path:"+ suOriginalFilePath);
@@ -196,10 +181,6 @@ public void onClick(View v) {
196181
su_env_inject_btn.setOnClickListener(new View.OnClickListener() {
197182
@Override
198183
public void onClick(View v) {
199-
if(getUid() == 0) {
200-
showConsoleMsg("【错误】请重新打开APP,在普通权限下点击此按钮,不要将APP提升为ROOT");
201-
return;
202-
}
203184
showSelectAppWindow();
204185
}
205186
});
@@ -437,11 +418,7 @@ public static String WirteSuToolsFilePath(String suName, Context context) {
437418
return suFilePath;
438419
}
439420

440-
public native int getUid();
441-
442-
public native String getCapabilityInfo();
443-
444-
public native int getRoot(String rootKey);
421+
public native String testRoot(String rootKey);
445422

446423
public native String runRootCmd(String rootKey, String cmd);
447424

Collapse file

‎PermissionManager/app/src/main/res/layout/activity_main.xml‎

Copy file name to clipboardExpand all lines: PermissionManager/app/src/main/res/layout/activity_main.xml
+7-16Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,28 @@
5151
android:text="菜单功能列表:"
5252
/>
5353

54-
55-
<Button
56-
android:id="@+id/show_myself_info_btn"
57-
android:layout_width="wrap_content"
58-
android:layout_height="wrap_content"
59-
60-
android:text="1.显示自身权限信息"
61-
/>
62-
6354
<Button
6455
android:layout_marginTop="5dp"
65-
android:id="@+id/get_root_btn"
56+
android:id="@+id/test_root_btn"
6657
android:layout_width="wrap_content"
6758
android:layout_height="wrap_content"
68-
android:text="2.获取ROOT权限"
59+
android:text="1.测试ROOT权限"
6960
/>
7061

7162
<Button
7263
android:layout_marginTop="5dp"
7364
android:id="@+id/run_root_cmd_btn"
7465
android:layout_width="wrap_content"
7566
android:layout_height="wrap_content"
76-
android:text="3.执行ROOT命令"
67+
android:text="2.执行ROOT命令"
7768
/>
7869

7970
<Button
8071
android:layout_marginTop="5dp"
8172
android:id="@+id/run_init_process_cmd_btn"
8273
android:layout_width="wrap_content"
8374
android:layout_height="wrap_content"
84-
android:text="4.执行原生内核命令"
75+
android:text="3.执行原生内核命令"
8576
/>
8677

8778

@@ -90,15 +81,15 @@
9081
android:id="@+id/su_env_install_btn"
9182
android:layout_width="wrap_content"
9283
android:layout_height="wrap_content"
93-
android:text="5.安装部署su"
84+
android:text="4.安装部署su"
9485
/>
9586

9687
<Button
9788
android:layout_marginTop="5dp"
9889
android:id="@+id/su_env_inject_btn"
9990
android:layout_width="wrap_content"
10091
android:layout_height="wrap_content"
101-
android:text="6.注入su到指定进程"
92+
android:text="5.注入su到指定进程"
10293
/>
10394

10495
<Button
@@ -107,7 +98,7 @@
10798
android:id="@+id/clean_su_btn"
10899
android:layout_width="wrap_content"
109100
android:layout_height="wrap_content"
110-
android:text="7.完全卸载清理su"
101+
android:text="6.完全卸载清理su"
111102
/>
112103

113104
</LinearLayout>

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.