github.com/HXSecurity/DongTai-agent-go@v0.4.2/core/gorm/gormDBExec/install.go (about) 1 package gormDBExec 2 3 import ( 4 "fmt" 5 "github.com/HXSecurity/DongTai-agent-go/model" 6 "github.com/brahma-adshonor/gohook" 7 "gorm.io/gorm" 8 ) 9 10 func init() { 11 model.HookMap["gormDBExec"] = new(GormDBExec) 12 } 13 14 type GormDBExec struct { 15 } 16 17 func (h *GormDBExec) Hook() { 18 db := &gorm.DB{} 19 err := gohook.HookMethod(db, "Exec", Exec, ExecT) 20 if err != nil { 21 fmt.Println(err, "gormExec") 22 } else { 23 fmt.Println("gormExec") 24 } 25 } 26 27 func (h *GormDBExec) UnHook() { 28 db := &gorm.DB{} 29 gohook.UnHookMethod(db, "Exec") 30 }