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

     1  package bufioWriterWrite
     2  
     3  import (
     4  	"bufio"
     5  	"bytes"
     6  	"fmt"
     7  	"github.com/HXSecurity/DongTai-agent-go/model"
     8  	"github.com/brahma-adshonor/gohook"
     9  )
    10  
    11  func init() {
    12  	model.HookMap["bufioWriterWrite"] = new(BufioWriterWrite)
    13  }
    14  
    15  type BufioWriterWrite struct {
    16  }
    17  
    18  func (h *BufioWriterWrite) Hook() {
    19  	var w *bufio.Writer
    20  	err := gohook.HookMethod(w, "Write", Write, WriteT)
    21  	if err != nil {
    22  		fmt.Println(err, "BufioWriterWrite")
    23  	} else {
    24  		fmt.Println("BufioWriterWrite")
    25  	}
    26  }
    27  
    28  func (h *BufioWriterWrite) UnHook() {
    29  	var bt bytes.Buffer
    30  	gohook.UnHookMethod(bt, "BufioWriterWrite")
    31  }