Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9db749e

Browse filesBrowse files
unkn0wNameunkn0wName
authored andcommitted
兼容输入信息的格式
1 parent 3249ad6 commit 9db749e
Copy full SHA for 9db749e

1 file changed

+41-14Lines changed: 41 additions & 14 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patch_kernel_root/patch_kernel_root.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_kernel_root.cpp
+41-14Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <string>
66
#include <sstream>
77
#include <vector>
8+
#include <algorithm>
89
#include "ArmAsmHelper.h"
910

1011

@@ -128,7 +129,6 @@ size_t path_do_execve(const char* file_buf, const string& str_root_key, size_t
128129
string strBytes2 = AsmToBytes(sstrAsm2.str());
129130
vec_out_patch_bytes_data.push_back({ strBytes2, do_execve_entry_addr });
130131
hook_func_start_addr += nHookFuncSize;
131-
cout << "#下一段HOOK函数起始可写位置:" << hex << hook_func_start_addr << endl << endl;
132132
return hook_func_start_addr;
133133
}
134134

@@ -202,6 +202,20 @@ bool write_file_bytes(const char* file_path, long offset, const char* bytes, int
202202
return true;
203203
}
204204

205+
size_t get_input_hex_number() {
206+
std::string input;
207+
cin >> input;
208+
transform(input.begin(), input.end(), input.begin(), ::tolower);
209+
if (input.length() > 2 && input.substr(0, 1) == "0x") {
210+
input = input.substr(2);
211+
}
212+
std::stringstream convert;
213+
convert << hex << input;
214+
size_t val;
215+
convert >> val;
216+
return val;
217+
}
218+
205219
int main(int argc, char* argv[]) {
206220
++argv;
207221
--argc;
@@ -223,36 +237,49 @@ int main(int argc, char* argv[]) {
223237
return 0;
224238
}
225239

240+
226241
//cout << "请输入空闲代码的位置:(即存放执行HOOK代码的位置):" << endl;
227242
size_t hook_func_start_addr = 0x300;
228-
//cin >> hex >> hook_func_start_addr;
243+
//hook_func_start_addr = get_input_hex_number();
244+
245+
size_t do_execve_entry_addr = -1;
246+
while (do_execve_entry_addr <= 0 || do_execve_entry_addr % 8) {
247+
cout << "请输入do_execve函数的入口位置:" << endl;
248+
do_execve_entry_addr = get_input_hex_number();
249+
if (do_execve_entry_addr<=0 || do_execve_entry_addr % 8) {
250+
cout << "输入的信息有错误" << endl;
251+
}
252+
}
229253

230-
size_t do_execve_entry_addr = 0;
231-
cout << "请输入do_execve函数的入口位置:" << endl;
232-
cin >> hex >> do_execve_entry_addr;
254+
size_t avc_denied_entry_addr = -1;
255+
while (avc_denied_entry_addr <= 0 || avc_denied_entry_addr % 8) {
256+
cout << "请输入avc_denied函数的入口位置:" << endl;
257+
avc_denied_entry_addr = get_input_hex_number();
258+
if (avc_denied_entry_addr <= 0 || avc_denied_entry_addr % 8) {
259+
cout << "输入的信息有错误" << endl;
260+
}
233261

234-
size_t avc_denied_entry_addr = 0;
235-
cout << "请输入avc_denied函数的入口位置:" << endl;
236-
cin >> hex >> avc_denied_entry_addr;
262+
}
237263

238264
size_t task_struct_offset_cred = -1;
239-
while (task_struct_offset_cred % 8) {
265+
while (task_struct_offset_cred <= 0 || task_struct_offset_cred % 8) {
240266
cout << "请输入task_struct结构体里cred的十六进制偏移值(从proc_pid_status里能看到):" << endl;
241-
cin >> hex >> task_struct_offset_cred;
242-
if (task_struct_offset_cred % 8) {
267+
task_struct_offset_cred = get_input_hex_number();
268+
if (task_struct_offset_cred <= 0 || task_struct_offset_cred % 8) {
243269
cout << "输入的信息有错误" << endl;
244270
}
245271
}
246272

247273
size_t task_struct_offset_seccomp = -1;
248-
while (task_struct_offset_seccomp % 8) {
274+
while (task_struct_offset_seccomp <= 0 || task_struct_offset_seccomp % 8) {
249275
cout << "请输入task_struct结构体里seccomp的十六进制偏移值(从proc_pid_status里能看到):" << endl;
250-
cin >> hex >> task_struct_offset_seccomp;
251-
if (task_struct_offset_seccomp % 8) {
276+
task_struct_offset_seccomp = get_input_hex_number();
277+
if (task_struct_offset_seccomp <= 0 || task_struct_offset_seccomp % 8) {
252278
cout << "输入的信息有错误" << endl;
253279
}
254280
}
255281

282+
256283
string str_root_key;
257284
size_t create_new_root_key = 0;
258285
cout << "是否需要自动随机生成ROOT密匙(1需要;2不需要):" << endl;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.