diff --git a/README.md b/README.md index d308867..5089bd3 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ This will display help for the tool. Here are all the switches it supports. | -verbose | Verbose Mode | httpx -verbose | | -version | Prints current version of the httpx | httpx -version | | -x | Request Method (default 'GET') | httpx -x HEAD | +| -response-in-stdout | Include response in stdout (only works with -json) | httpx -response-in-stdout | # Installation Instructions diff --git a/cmd/httpx/httpx.go b/cmd/httpx/httpx.go index 9f0a071..4e4322d 100644 --- a/cmd/httpx/httpx.go +++ b/cmd/httpx/httpx.go @@ -56,6 +56,7 @@ func main() { scanopts.StoreResponseDirectory = options.StoreResponseDir scanopts.Method = options.Method scanopts.OutputServerHeader = options.OutputServerHeader + scanopts.ResponseInStdout = options.responseInStdout // Try to create output folder if it doesnt exist if options.StoreResponse && options.StoreResponseDir != "" && options.StoreResponseDir != "." { @@ -179,6 +180,7 @@ type scanOptions struct { StoreResponse bool StoreResponseDirectory string OutputServerHeader bool + ResponseInStdout bool } func analyze(hp *httpx.HTTPX, protocol string, domain string, port int, scanopts *scanOptions, output chan Result) { @@ -244,6 +246,11 @@ retry: builder.WriteString(fmt.Sprintf(" [%s]", serverHeader)) } + var serverResponseRaw = "" + if scanopts.ResponseInStdout { + serverResponseRaw = resp.Raw + } + // check for virtual host isvhost := false if scanopts.VHost { @@ -263,7 +270,7 @@ retry: } } - output <- Result{URL: fullURL, ContentLength: resp.ContentLength, StatusCode: resp.StatusCode, Title: title, str: builder.String(), VHost: isvhost, WebServer: serverHeader} + output <- Result{URL: fullURL, ContentLength: resp.ContentLength, StatusCode: resp.StatusCode, Title: title, str: builder.String(), VHost: isvhost, WebServer: serverHeader, Response: serverResponseRaw} } // Result of a scan @@ -276,6 +283,7 @@ type Result struct { err error VHost bool `json:"vhost"` WebServer string `json:"webserver"` + Response string `json:"serverResponse,omitempty"` } // JSON the result diff --git a/cmd/httpx/options.go b/cmd/httpx/options.go index d4ac0b7..be6aabe 100644 --- a/cmd/httpx/options.go +++ b/cmd/httpx/options.go @@ -37,6 +37,7 @@ type Options struct { Verbose bool NoColor bool OutputServerHeader bool + responseInStdout bool FollowHostRedirects bool } @@ -67,6 +68,7 @@ func ParseOptions() *Options { flag.BoolVar(&options.Verbose, "verbose", false, "Verbose Mode") flag.BoolVar(&options.NoColor, "no-color", false, "No Color") flag.BoolVar(&options.OutputServerHeader, "web-server", false, "Prints out the Server header content") + flag.BoolVar(&options.responseInStdout, "response-in-json", false, "Server response directly in the tool output (-json only)") flag.Parse() // Read the inputs and configure the logging