mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-11-24 13:14:01 +03:00
Merge pull request #20 from timoles/response_in_output
Added option to include the raw response within the json output
This commit is contained in:
commit
e742e0fffb
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user