From 3efeef969ebc344c993ce0fc46f557c7d8560525 Mon Sep 17 00:00:00 2001 From: We-unite <3205135446@qq.com> Date: Wed, 31 Jul 2024 11:46:01 +0800 Subject: Use netlink connector to recv pid info, fix exec For some reasons, kernel-connector can catch exec event, but it doesn't tell me about what the process exec and what're its args. So we should use audit to collect these infomations, and complete in the database. However, there's different delays between connector and audit, although they both use netlink socket, as a result of which, exec may comes before fork. we deal with it the same way. But, there's also exec event lost, may because of the check for ppid in exec event, but it's necessary, and if is deleted, too much irrelavent infomation would flood into database, i've tried. So make it there, just go forward. Besides, what's newly discovered is that pthread_create also use clone syscall, but if pid 1 has a thread 2, the exec info will say that pid 2 execs. So i shouldn't ignore connector msg that childPid ne childTgid. This is my first attempt to use git-submodule function in my own pro- ject, also golang local package. Congratulations! Now, fight to fix about file operations. Hope that there wouldn't be too many fucking bugs. --- src/organize.go | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'src/organize.go') diff --git a/src/organize.go b/src/organize.go index d7a1df1..238509f 100644 --- a/src/organize.go +++ b/src/organize.go @@ -47,7 +47,6 @@ func orgnaze() { break } rawEvent = raw.(libaudit.RawAuditMessage) - fmt.Printf("type=%v msg=%s\n", rawEvent.Type, rawEvent.Data) switch rawEvent.Type { case auparse.AUDIT_SYSCALL: @@ -100,24 +99,6 @@ func syscallRaw(rawEvent libaudit.RawAuditMessage) { } switch syscallTable[event.syscall] { - case "clone": - if exit == 0 || event.pid > exit { - // exit=0是给新进程的返回,没用 - // pid>exit,证明有问题,抛弃 - break - } else { - eventTable.Store(eventId, &Event{ - tag: NEWPID, - timestamp: event.timestamp, - syscall: event.syscall, - exit_code: 0, - ppid: event.pid, - pid: exit, - argc: 0, - argv: make([]string, 0), - cwd: "", - }) - } case "execve": eventTable.Store(eventId, &Event{ tag: EXECVE, @@ -130,18 +111,6 @@ func syscallRaw(rawEvent libaudit.RawAuditMessage) { argv: make([]string, 0), cwd: "", }) - case "exit", "exit_group": - eventTable.Store(eventId, &Event{ - tag: PIDEXIT, - timestamp: event.timestamp, - syscall: event.syscall, - exit_code: a[0], - ppid: event.ppid, - pid: event.pid, - argc: 0, - argv: make([]string, 0), - cwd: "", - }) case "open": // 检查打开的权限 if a[1]&(syscall.O_APPEND|syscall.O_WRONLY|syscall.O_RDWR|syscall.O_TRUNC) == 0 { -- cgit v1.2.3-70-g09d2