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

     1  package regexpRegexpReplaceAllString
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/HXSecurity/DongTai-agent-go/model"
     6  	"github.com/brahma-adshonor/gohook"
     7  	"regexp"
     8  )
     9  
    10  func init() {
    11  	model.HookMap["regexpRegexpReplaceAllString"] = new(RegexpRegexpReplaceAllString)
    12  }
    13  
    14  type RegexpRegexpReplaceAllString struct {
    15  }
    16  
    17  func (h *RegexpRegexpReplaceAllString) Hook() {
    18  	var r *regexp.Regexp
    19  	err := gohook.HookMethod(r, "ReplaceAllString", ReplaceAllString, ReplaceAllStringT)
    20  	if err != nil {
    21  		fmt.Println(err, "RegexpRegexpReplaceAllString")
    22  	} else {
    23  		fmt.Println("RegexpRegexpReplaceAllString")
    24  	}
    25  }
    26  
    27  func (h *RegexpRegexpReplaceAllString) UnHook() {
    28  	var r *regexp.Regexp
    29  	err := gohook.UnHookMethod(r, "ReplaceAllString")
    30  	if err != nil {
    31  		fmt.Println(err, "RegexpRegexpReplaceAllString")
    32  	} else {
    33  		fmt.Println("RegexpRegexpReplaceAllString")
    34  	}
    35  }