github.com/HXSecurity/DongTai-agent-go@v0.4.2/core/base/builderWriteString/install.go (about) 1 package builderWriteString 2 3 import ( 4 "bytes" 5 "fmt" 6 "github.com/HXSecurity/DongTai-agent-go/model" 7 "github.com/brahma-adshonor/gohook" 8 "strings" 9 ) 10 11 func init() { 12 model.HookMap["builderWriteString"] = new(BuilderWriteString) 13 } 14 15 type BuilderWriteString struct { 16 } 17 18 func (h *BuilderWriteString) Hook() { 19 var bt strings.Builder 20 err := gohook.HookMethod(bt, "WriteString", WriteString, WriteStringT) 21 if err != nil { 22 fmt.Println(err, "BuilderWriteString") 23 } else { 24 fmt.Println("BuilderWriteString") 25 } 26 } 27 28 func (h *BuilderWriteString) UnHook() { 29 var bt bytes.Buffer 30 gohook.UnHookMethod(bt, "WriteString") 31 }