Repository navigation
Expand file tree
/
Copy pathtestRoot.h
More file actions
59 lines (51 loc) · 1.88 KB
/
Copy pathtestRoot.h
File metadata and controls
59 lines (51 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _TEST_ROOT_H_
#define _TEST_ROOT_H_
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/capability.h>
#include <unistd.h>
#include <sstream>
#include <thread>
#include <vector>
#include "kernel_root_kit/kernel_root_kit_umbrella.h"
#include "su/su_hide_path_utils.h"
static std::string get_capability_info() {
__uid_t now_uid, now_euid, now_suid;
__gid_t now_gid, now_egid, now_sgid;
if (getresuid(&now_uid, &now_euid, &now_suid)) {
return "FAILED getresuid()";
}
if (getresgid(&now_gid, &now_egid, &now_sgid)) {
return "FAILED getresgid()";
}
std::stringstream sstrCapInfo;
sstrCapInfo<< "Current process information:\n";
sstrCapInfo<< "uid:"<<now_uid <<"," << std::endl <<"euid:"<< now_euid <<"," << std::endl
<<"suid:"<< now_suid <<"," << std::endl <<"gid:"<< now_gid <<"," << std::endl
<<"egid:"<< now_egid <<"," << std::endl <<"sgid:"<< now_sgid <<"\n";
struct __user_cap_header_struct cap_header_data;
cap_user_header_t cap_header = &cap_header_data;
struct __user_cap_data_struct cap_data_data;
cap_user_data_t cap_data = &cap_data_data;
cap_header->pid = getpid();
cap_header->version = _LINUX_CAPABILITY_VERSION_3; //_1、_2、_3
if (capget(cap_header, cap_data) < 0) {
return "FAILED capget()";
// perror("FAILED capget()");
//exit(1);
}
sstrCapInfo << "cap effective:" << std::hex <<cap_data->effective << "," << std::endl
<<"cap permitted:"<< std::hex << cap_data->permitted<< "," << std::endl
<<"cap inheritable:"<< std::hex <<cap_data->inheritable<< std::endl;
FILE * fp = popen("getenforce", "r");
if (fp) {
char cmd[512] = { 0 };
fread(cmd, 1, sizeof(cmd), fp);
pclose(fp);
sstrCapInfo<< "read system SELinux status:"<< cmd;
}
return sstrCapInfo.str();
}
#endif /* _TEST_ROOT_H_ */