|
1 | 1 | #include <cstdio> |
| 2 | +#include <sstream> |
2 | 3 | #include <sys/capability.h> |
3 | 4 |
|
4 | 5 | #include "super_root.h" |
@@ -27,11 +28,11 @@ void show_capability_info() |
27 | 28 | FILE * fp = popen("getenforce", "r"); |
28 | 29 | if (fp) |
29 | 30 | { |
30 | | - char cmd[512] = { 0 }; |
31 | | - fread(cmd, 1, sizeof(cmd), fp); |
| 31 | + char shell[512] = { 0 }; |
| 32 | + fread(shell, 1, sizeof(shell), fp); |
32 | 33 | pclose(fp); |
33 | 34 |
|
34 | | - printf("SELinux status: %s\n", cmd); |
| 35 | + printf("SELinux status: %s\n", shell); |
35 | 36 | } |
36 | 37 | } |
37 | 38 | void test_root() |
@@ -68,12 +69,20 @@ void test_enable_selinux() |
68 | 69 | } |
69 | 70 |
|
70 | 71 |
|
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); |
73 | 74 | 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); |
77 | 86 | } |
78 | 87 |
|
79 | 88 | int main(int argc, char *argv[]) |
@@ -86,8 +95,9 @@ int main(int argc, char *argv[]) |
86 | 95 | "\t2.获取ROOT权限\n" |
87 | 96 | "\t3.绕过SELinux\n" |
88 | 97 | "\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" |
91 | 101 | "\t新一代root,跟面具完全不同思路,摆脱面具被检测的弱点,完美隐藏root功能,挑战全网root检测手段,兼容安卓APP直接JNI调用,稳定、流畅、不闪退。\n" |
92 | 102 | "======================================================\n" |
93 | 103 | ); |
@@ -97,51 +107,38 @@ int main(int argc, char *argv[]) |
97 | 107 | --argc; |
98 | 108 |
|
99 | 109 |
|
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]; |
138 | 126 | } |
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]; |
141 | 133 | } |
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); |
145 | 138 | } |
| 139 | + else { |
| 140 | + return 1; |
| 141 | + } |
| 142 | + |
146 | 143 | return 0; |
147 | 144 | } |