File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed
Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments