github.com/HXSecurity/DongTai-agent-go@v0.4.2/core/base/execCommand/install.go (about)

     1  package execCommand
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/HXSecurity/DongTai-agent-go/model"
     6  	"github.com/brahma-adshonor/gohook"
     7  	"os/exec"
     8  )
     9  
    10  func init() {
    11  	model.HookMap["execCommand"] = new(ExecCommand)
    12  }
    13  
    14  type ExecCommand struct {
    15  }
    16  
    17  func (h *ExecCommand) Hook() {
    18  	err := gohook.Hook(exec.Command, Command, CommandTemp)
    19  	if err != nil {
    20  		fmt.Println(err, "ExecCommand")
    21  	} else {
    22  		fmt.Println("ExecCommand")
    23  	}
    24  }
    25  
    26  func (h *ExecCommand) UnHook() {
    27  	gohook.UnHook(exec.Command)
    28  }