Skip to content

Commit 9822b90

Browse files
author
piexlmax
committed
add httpHeaderGet hook
1 parent 6d8ca43 commit 9822b90

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

core/http/httpHeaderGet/install.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package httpHeaderGet
2+
3+
import (
4+
"fmt"
5+
"github.com/HXSecurity/DongTai-agent-go/model"
6+
"github.com/brahma-adshonor/gohook"
7+
"net/http"
8+
)
9+
10+
func init() {
11+
model.HookMap["httpHeaderGet"] = new(HttpHeaderGet)
12+
}
13+
14+
type HttpHeaderGet struct {
15+
}
16+
17+
func (h *HttpHeaderGet) Hook() {
18+
var header http.Header
19+
err := gohook.HookMethod(header, "Get", Get, GetT)
20+
if err != nil {
21+
fmt.Println(err, "HttpHeaderGet")
22+
} else {
23+
fmt.Println("HttpHeaderGet")
24+
}
25+
}
26+
27+
func (h *HttpHeaderGet) UnHook() {
28+
var header *http.Header
29+
gohook.UnHookMethod(header, "Get")
30+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package httpHeaderGet
2+
3+
import (
4+
"github.com/HXSecurity/DongTai-agent-go/model/request"
5+
"github.com/HXSecurity/DongTai-agent-go/utils"
6+
"net/http"
7+
"strings"
8+
)
9+
10+
func Get(header http.Header, key string) string {
11+
values := GetT(header, key)
12+
skipMap := make(map[string]bool)
13+
skipMap["net/http.(*persistConn).roundTrip"] = true
14+
skipMap["net/http.(*chunkWriter).writeHeader"] = true
15+
skipMap["net/http.(*Client).makeHeadersCopier"] = true
16+
skipMap["net/http.(*persistConn).readLoop"] = true
17+
skipMap["net/http.(*Request).requiresHTTP1"] = true
18+
skipMap["net/http.isProtocolSwitchHeader"] = true
19+
if strings.Index(utils.LoadFunc(2), "github.com/parnurzeal/gorequest") > -1 {
20+
return values
21+
}
22+
if skipMap[utils.LoadFunc(2)] {
23+
return values
24+
}
25+
request.FmtHookPool(request.PoolReq{
26+
Args: request.Collect(key),
27+
Reqs: request.Collect(values),
28+
Source: true,
29+
OriginClassName: "http.(Header)",
30+
MethodName: "Get",
31+
ClassName: "http.(Header)",
32+
})
33+
return values
34+
}
35+
36+
func GetT(header http.Header, key string) string {
37+
return ""
38+
}

0 commit comments

Comments
 (0)