Skip to content

Commit 21a47a6

Browse files
committed
fix error
1 parent d0ece1d commit 21a47a6

1 file changed

Lines changed: 50 additions & 53 deletions

File tree

testRoot/main.cpp

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <cstdio>
2+
#include <sstream>
23
#include <sys/capability.h>
34

45
#include "super_root.h"
@@ -27,11 +28,11 @@ void show_capability_info()
2728
FILE * fp = popen("getenforce", "r");
2829
if (fp)
2930
{
30-
char cmd[512] = { 0 };
31-
fread(cmd, 1, sizeof(cmd), fp);
31+
char shell[512] = { 0 };
32+
fread(shell, 1, sizeof(shell), fp);
3233
pclose(fp);
3334

34-
printf("SELinux status: %s\n", cmd);
35+
printf("SELinux status: %s\n", shell);
3536
}
3637
}
3738
void test_root()
@@ -68,12 +69,20 @@ void test_enable_selinux()
6869
}
6970

7071

71-
void test_run_cmd(char * cmd, bool bKeepAdbRoot = false) {
72-
printf("inject_cmd_remote_process(%s)\n", cmd);
72+
void test_run_adb_shell(char * shell, bool bKeepAdbRoot = false) {
73+
printf("inject_shell_remote_process(%s)\n", shell);
7374
char szResult[0x1000] = { 0 };
74-
ssize_t ret = safe_inject_adb_process_run_cmd_wrapper(ROOT_KEY, cmd, bKeepAdbRoot, szResult, sizeof(szResult));
75-
printf("inject_cmd_remote_process ret val:%zd\n", ret);
76-
printf("inject_cmd_remote_process result:%s\n", szResult);
75+
ssize_t ret = safe_inject_adb_process_run_shell_wrapper(ROOT_KEY, shell, bKeepAdbRoot, szResult, sizeof(szResult));
76+
printf("inject_shell_remote_process ret val:%zd\n", ret);
77+
printf("inject_shell_remote_process result:%s\n", szResult);
78+
}
79+
80+
void test_run_shell(char * shell) {
81+
printf("test_run_shell(%s)\n", shell);
82+
char szResult[0x1000] = { 0 };
83+
ssize_t ret = safe_run_shell(ROOT_KEY, shell, szResult, sizeof(szResult));
84+
printf("test_run_shell ret val:%zd\n", ret);
85+
printf("test_run_shell result:%s\n", szResult);
7786
}
7887

7988
int main(int argc, char *argv[])
@@ -86,8 +95,9 @@ int main(int argc, char *argv[])
8695
"\t2.获取ROOT权限\n"
8796
"\t3.绕过SELinux\n"
8897
"\t4.还原SELinux\n"
89-
"\t5.执行ROOT权限级别的Shell命令\n"
90-
"\t6.赋予ADB最高级别权限\n"
98+
"\t5.执行ROOT Shell命令\n"
99+
"\t6.执行ADBShell命令\n"
100+
"\t7.赋予ADB最高级别权限\n"
91101
"\t新一代root,跟面具完全不同思路,摆脱面具被检测的弱点,完美隐藏root功能,挑战全网root检测手段,兼容安卓APP直接JNI调用,稳定、流畅、不闪退。\n"
92102
"======================================================\n"
93103
);
@@ -97,51 +107,38 @@ int main(int argc, char *argv[])
97107
--argc;
98108

99109

100-
int cmdc;
101-
char *cmdv[6];
102-
103-
while (argc) {
104-
// Clean up
105-
cmdc = 0;
106-
memset(cmdv, 0, sizeof(cmdv));
107-
108-
// Split the commands
109-
for (char *tok = strtok(argv[0], " "); tok; tok = strtok(nullptr, " "))
110-
{
111-
cmdv[cmdc++] = tok;
112-
if (cmdc == 0)
113-
{
114-
continue;
115-
}
116-
}
117-
118-
119-
if (strcmp(cmdv[0], "show") == 0) {
120-
show_capability_info();
121-
}
122-
else if (strcmp(cmdv[0], "root") == 0) {
123-
test_root();
124-
}
125-
else if (strcmp(cmdv[0], "disable") == 0) {
126-
test_disable_selinux();
127-
}
128-
else if (strcmp(cmdv[0], "enable") == 0) {
129-
test_enable_selinux();
130-
}
131-
else if (strcmp(cmdv[0], "cmd") == 0) {
132-
test_run_cmd("id");
133-
//test_run_cmd("id > /sdcard/run.txt");
134-
//test_run_cmd("insmod rwProcMem37.ko > /sdcard/run.txt");
135-
}
136-
else if (strcmp(cmdv[0], "adb") == 0) {
137-
test_run_cmd("id", true);
110+
if (strcmp(argv[0], "show") == 0) {
111+
show_capability_info();
112+
}
113+
else if (strcmp(argv[0], "root") == 0) {
114+
test_root();
115+
}
116+
else if (argc >=2 && strcmp(argv[0], "selinux") == 0 && strcmp(argv[1], "disable") == 0) {
117+
test_disable_selinux();
118+
}
119+
else if (argc >= 2 && strcmp(argv[0], "selinux") == 0 && strcmp(argv[1], "enable") == 0) {
120+
test_enable_selinux();
121+
}
122+
else if (argc >= 2 && strcmp(argv[0], "shell") == 0) {
123+
std::stringstream sstrCmd;
124+
for (int i = 1; i < argc; i++) {
125+
sstrCmd << argv[i];
138126
}
139-
else {
140-
return 1;
127+
test_run_shell((char*)sstrCmd.str().c_str());
128+
}
129+
else if (argc > 2 && strcmp(argv[0], "adb") == 0 && strcmp(argv[1], "shell") == 0) {
130+
std::stringstream sstrCmd;
131+
for (int i = 2; i < argc; i++) {
132+
sstrCmd << argv[i];
141133
}
142-
143-
--argc;
144-
++argv;
134+
test_run_adb_shell((char*)sstrCmd.str().c_str());
135+
}
136+
else if (argc >= 2 && strcmp(argv[0], "adb") == 0 && strcmp(argv[1], "root") == 0) {
137+
test_run_adb_shell("id", true);
145138
}
139+
else {
140+
return 1;
141+
}
142+
146143
return 0;
147144
}

0 commit comments

Comments
 (0)