fix code for 24-27

This commit is contained in:
yunwei37
2023-05-31 01:12:44 +08:00
committed by 云微
parent 48fae08f08
commit ad567ea830
16 changed files with 88 additions and 47 deletions

View File

@@ -6,4 +6,5 @@ package.json
package.yaml
ecli
bootstrap
textreplace2
pidhide

View File

@@ -24,7 +24,7 @@ INCLUDES := -I$(OUTPUT) -I../../libbpf/include/uapi -I$(dir $(VMLINUX))
CFLAGS := -g -Wall
ALL_LDFLAGS := $(LDFLAGS) $(EXTRA_LDFLAGS)
APPS = textreplace2 # minimal minimal_legacy uprobe kprobe fentry usdt sockfilter tc ksyscall
APPS = pidhide # minimal minimal_legacy uprobe kprobe fentry usdt sockfilter tc ksyscall
CARGO ?= $(shell which cargo)
ifeq ($(strip $(CARGO)),)

View File

@@ -1,3 +1,19 @@
# 使用 eBPF 隐藏进程或文件信息
TODO
## 隐藏 PID
编译:
```bash
make
```
使用方式:
```sh
sudo ./pidhide --pid-to-hide 2222
```
这个程序将匹配这个 pid 的进程隐藏,使得像 `ps` 这样的工具无法看到。
它通过挂接 `getdents64` 系统调用来工作,因为 `ps` 是通过查找 `/proc/` 的每个子文件夹来工作的。PidHide 解除了与 PID 匹配的文件夹的链接,因此 `ps` 只能看到它之前和之后的文件夹。

View File

@@ -12,6 +12,7 @@
// Used when replacing text
#define FILENAME_LEN_MAX 50
#define TEXT_LEN_MAX 20
#define max_pid_len 10
// Simple message structure to get events from eBPF Programs
// in the kernel to user spcae

View File

@@ -52,7 +52,6 @@ const volatile int target_ppid = 0;
// These store the string represenation
// of the PID to hide. This becomes the name
// of the folder in /proc/
const int max_pid_len = 10;
const volatile int pid_to_hide_len = 0;
const volatile char pid_to_hide[max_pid_len];