From 706c36abf4c965debab0ba551de2a5d6e889b1ac Mon Sep 17 00:00:00 2001 From: jweny Date: Wed, 11 Aug 2021 16:14:29 +0800 Subject: [PATCH] [Debug] fix target connect func --- pkg/util/request.go | 69 ++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/pkg/util/request.go b/pkg/util/request.go index 439cf2d..164f085 100644 --- a/pkg/util/request.go +++ b/pkg/util/request.go @@ -357,36 +357,37 @@ func VerifyPortConnection(targetAddr string) bool { return true } -func VerifyTargetConnection(originalReq *http.Request) bool { - fastReq := fasthttp.AcquireRequest() - fastResp := fasthttp.AcquireResponse() - oriData, err := GetOriginalReqBody(originalReq) - if err != nil { - return false - } - err = CopyRequest(originalReq, fastReq, oriData) - if err != nil { - return false - } - timeout := conf.GlobalConfig.HttpConfig.HttpTimeout - // 检测原始请求 - err = fasthttpClient.DoTimeout(fastReq, fastResp, time.Duration(timeout)*time.Second) - if err != nil { - // 检测原始请求 + index.php - uri := string(fastReq.RequestURI()) - if uri != "" && strings.HasSuffix(uri, "/") { - uri = fmt.Sprint(uri, "index.php") - } else { - uri = fmt.Sprint(uri, "/index.php") - } - fastReq.SetRequestURI(uri) - err = fasthttpClient.DoTimeout(fastReq, fastResp, time.Duration(timeout)*time.Second) - if err != nil { - return false - } - } - return true -} +// 以后接被动扫描插件的时候用 +//func VerifyTargetConnection(originalReq *http.Request) bool { +// fastReq := fasthttp.AcquireRequest() +// fastResp := fasthttp.AcquireResponse() +// oriData, err := GetOriginalReqBody(originalReq) +// if err != nil { +// return false +// } +// err = CopyRequest(originalReq, fastReq, oriData) +// if err != nil { +// return false +// } +// timeout := conf.GlobalConfig.HttpConfig.HttpTimeout +// // 检测原始请求 +// err = fasthttpClient.DoTimeout(fastReq, fastResp, time.Duration(timeout)*time.Second) +// if err != nil { +// // 检测原始请求 + index.php +// uri := string(fastReq.RequestURI()) +// if uri != "" && strings.HasSuffix(uri, "/") { +// uri = fmt.Sprint(uri, "index.php") +// } else { +// uri = fmt.Sprint(uri, "/index.php") +// } +// fastReq.SetRequestURI(uri) +// err = fasthttpClient.DoTimeout(fastReq, fastResp, time.Duration(timeout)*time.Second) +// if err != nil { +// return false +// } +// } +// return true +//} func VerifyInputTarget(target string) (bool, string) { // 连通性校验改到这里 @@ -438,14 +439,6 @@ func GenOriginalReq(target string) (*http.Request, error) { originalReq.Header.Set("User-Agent", conf.GlobalConfig.HttpConfig.Headers.UserAgent) originalReq.Header.Set("Accept-Language","en") originalReq.Header.Set("Connection","close") - - // 检查fixUrl连通性 - verify = VerifyTargetConnection(originalReq) - if !verify { - errMsg := fmt.Errorf("util/requests.go:GenOriginalReq %s can not connect", fixTarget) - log.Error(errMsg) - return nil, errMsg - } return originalReq, nil }