mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-09-11 17:46:08 +03:00
adding response time
This commit is contained in:
parent
85be3d15db
commit
389b50ea9f
@ -130,6 +130,7 @@ func main() {
|
||||
scanopts.OutputIP = options.OutputIP
|
||||
scanopts.OutputCName = options.OutputCName
|
||||
scanopts.OutputCDN = options.OutputCDN
|
||||
scanopts.OutputResponseTime = options.OutputResponseTime
|
||||
// output verb if more than one is specified
|
||||
if len(scanopts.Methods) > 1 && !options.Silent {
|
||||
scanopts.OutputMethod = true
|
||||
@ -352,6 +353,7 @@ type scanOptions struct {
|
||||
OutputIP bool
|
||||
OutputCName bool
|
||||
OutputCDN bool
|
||||
OutputResponseTime bool
|
||||
}
|
||||
|
||||
func analyze(hp *httpx.HTTPX, protocol, domain string, port int, method string, scanopts *scanOptions) Result {
|
||||
@ -544,6 +546,10 @@ retry:
|
||||
builder.WriteString(" [cdn]")
|
||||
}
|
||||
|
||||
if scanopts.OutputResponseTime {
|
||||
builder.WriteString(fmt.Sprintf(" [%s]", resp.Duration))
|
||||
}
|
||||
|
||||
// store responses in directory
|
||||
if scanopts.StoreResponse {
|
||||
domainFile := fmt.Sprintf("%s%s", domain, scanopts.RequestURI)
|
||||
@ -587,6 +593,7 @@ retry:
|
||||
IPs: ips,
|
||||
CNAMEs: cnames,
|
||||
CDN: isCDN,
|
||||
Duration: resp.Duration,
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,6 +621,7 @@ type Result struct {
|
||||
Pipeline bool `json:"pipeline,omitempty"`
|
||||
HTTP2 bool `json:"http2"`
|
||||
CDN bool `json:"cdn"`
|
||||
Duration time.Duration `json:"duration"`
|
||||
}
|
||||
|
||||
// JSON the result
|
||||
@ -684,6 +692,7 @@ type Options struct {
|
||||
Pipeline bool
|
||||
HTTP2Probe bool
|
||||
OutputCDN bool
|
||||
OutputResponseTime bool
|
||||
}
|
||||
|
||||
// ParseOptions parses the command line options for application
|
||||
@ -738,6 +747,7 @@ func ParseOptions() *Options {
|
||||
flag.StringVar(&options.OutputMatchRegex, "match-regex", "", "Match Regex")
|
||||
flag.BoolVar(&options.OutputCName, "cname", false, "Output first cname")
|
||||
flag.BoolVar(&options.OutputCDN, "cdn", false, "Check if domain's ip belongs to known CDN (akamai, cloudflare, ..)")
|
||||
flag.BoolVar(&options.OutputResponseTime, "response-time", false, "Output the response time")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
@ -112,13 +113,15 @@ func New(options *Options) (*HTTPX, error) {
|
||||
|
||||
// Do http request
|
||||
func (h *HTTPX) Do(req *retryablehttp.Request) (*Response, error) {
|
||||
httpresp, err := h.getResponse(req)
|
||||
timeStart := time.Now()
|
||||
|
||||
httpresp, err := h.getResponse(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var resp Response
|
||||
|
||||
resp.Headers = httpresp.Header.Clone()
|
||||
|
||||
// httputil.DumpResponse does not handle websockets
|
||||
@ -167,6 +170,7 @@ func (h *HTTPX) Do(req *retryablehttp.Request) (*Response, error) {
|
||||
}
|
||||
|
||||
resp.CSPData = h.CSPGrab(httpresp)
|
||||
resp.Duration = time.Since(timeStart)
|
||||
|
||||
return &resp, nil
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package httpx
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Response contains the response to a server
|
||||
@ -17,6 +18,7 @@ type Response struct {
|
||||
CSPData *CSPData
|
||||
HTTP2 bool
|
||||
Pipeline bool
|
||||
Duration time.Duration
|
||||
}
|
||||
|
||||
// GetHeader value
|
||||
|
4
go.mod
4
go.mod
@ -12,10 +12,10 @@ require (
|
||||
github.com/projectdiscovery/fdmax v0.0.2
|
||||
github.com/projectdiscovery/gologger v1.0.1
|
||||
github.com/projectdiscovery/mapcidr v0.0.4
|
||||
github.com/projectdiscovery/rawhttp v0.0.0-20200901223513-8a8a0cef2693
|
||||
github.com/projectdiscovery/rawhttp v0.0.1
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.1
|
||||
github.com/remeh/sizedwaitgroup v1.0.0
|
||||
github.com/rs/xid v1.2.1
|
||||
golang.org/x/net v0.0.0-20200925080053-05aa5d4ee321
|
||||
golang.org/x/net v0.0.0-20200927032502-5d4f70055728
|
||||
golang.org/x/text v0.3.3
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -30,6 +30,8 @@ github.com/projectdiscovery/mapcidr v0.0.4 h1:2vBSjkmbQASAcO/m2L/dhdulMVu2y9HdyW
|
||||
github.com/projectdiscovery/mapcidr v0.0.4/go.mod h1:ALOIj6ptkWujNoX8RdQwB2mZ+kAmKuLJBq9T5gR5wG0=
|
||||
github.com/projectdiscovery/rawhttp v0.0.0-20200901223513-8a8a0cef2693 h1:dBBB/UXLVvy/Onb3YxVyg5ApwY8lRCIXt0owUosvNuI=
|
||||
github.com/projectdiscovery/rawhttp v0.0.0-20200901223513-8a8a0cef2693/go.mod h1:RkML6Yq6hf4z2wAUXisa15al4bS+wuJnlhM5ZOfn9k4=
|
||||
github.com/projectdiscovery/rawhttp v0.0.1 h1:g9lzZPNBZsIAscTS2VLgv8RGQJcFXsOOTlzU49mDeBk=
|
||||
github.com/projectdiscovery/rawhttp v0.0.1/go.mod h1:RkML6Yq6hf4z2wAUXisa15al4bS+wuJnlhM5ZOfn9k4=
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.1 h1:V7wUvsZNq1Rcz7+IlcyoyQlNwshuwptuBVYWw9lx8RE=
|
||||
github.com/projectdiscovery/retryablehttp-go v1.0.1/go.mod h1:SrN6iLZilNG1X4neq1D+SBxoqfAF4nyzvmevkTkWsek=
|
||||
github.com/remeh/sizedwaitgroup v1.0.0 h1:VNGGFwNo/R5+MJBf6yrsr110p0m4/OX4S3DCy7Kyl5E=
|
||||
@ -53,6 +55,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200925080053-05aa5d4ee321 h1:lleNcKRbcaC8MqgLwghIkzZ2JBQAb7QQ9MiwRt1BisA=
|
||||
golang.org/x/net v0.0.0-20200925080053-05aa5d4ee321/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200927032502-5d4f70055728 h1:5wtQIAulKU5AbLQOkjxl32UufnIOqgBX72pS0AV14H0=
|
||||
golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
Loading…
Reference in New Issue
Block a user