misc update

This commit is contained in:
sandeep 2021-10-02 06:56:30 +05:30
parent 995037f9b2
commit af42eef28d

View File

@ -197,93 +197,108 @@ func ParseOptions() *Options {
options := &Options{}
flagSet := goflags.NewFlagSet()
flagSet.SetDescription(`httpx is a fast and multi-purpose HTTP toolkit allow to run multiple probers using [retryablehttp](https://github.com/projectdiscovery/retryablehttp-go) library, it is designed to maintain the result reliability with increased threads.`)
flagSet.SetDescription(`httpx is a fast and multi-purpose HTTP toolkit allow to run multiple probers using retryablehttp library, it is designed to maintain the result reliability with increased threads.`)
createGroup(flagSet, "input", "Target",
flagSet.BoolVar(&options.VHostInput, "vhost-input", false, "Get a list of vhosts as input"),
flagSet.Var(&options.CustomHeaders, "H", "Custom Header to send with request"),
flagSet.Var(&options.CustomPorts, "ports", "Port ranges to scan (nmap syntax: eg 1,2-10,11)"),
flagSet.StringVar(&options.HTTPProxy, "http-proxy", "", "HTTP Proxy, eg http://127.0.0.1:8080"),
flagSet.StringVar(&options.InputFile, "l", "", "Input file containing list of hosts to process"),
flagSet.StringVar(&options.Methods, "x", "", "Request Methods to use, use 'all' to probe all HTTP methods"),
createGroup(flagSet, "input", "Input",
flagSet.StringVarP(&options.InputFile,"list", "l", "", "Input file containing list of hosts to process"),
flagSet.StringVar(&options.InputRawRequest, "request", "", "File containing raw request"),
)
createGroup(flagSet, "Probes", "Probes",
flagSet.BoolVarP(&options.StatusCode,"status-code", "sc", false, "Display HTTP response status code"),
flagSet.BoolVarP(&options.TechDetect,"tech-detect", "tech", false, "Perform wappalyzer based technology detection"),
flagSet.BoolVarP(&options.ContentLength,"content-length", "cl", false, "Display HTTP response content length"),
flagSet.BoolVarP(&options.OutputServerHeader,"web-server","server", false, "Display server header"),
flagSet.BoolVarP(&options.OutputContentType,"content-type", "ct", false, "Display content-type header"),
flagSet.BoolVarP(&options.OutputResponseTime,"response-time", "rt", false, "Display the response time"),
flagSet.BoolVar(&options.ExtractTitle, "title", false, "Display page title"),
flagSet.BoolVar(&options.Location, "location", false, "Display location header"),
flagSet.BoolVar(&options.OutputMethod, "method", false, "Display request method"),
flagSet.BoolVar(&options.OutputWebSocket, "websocket", false, "Display server using websocket"),
flagSet.BoolVar(&options.OutputIP, "ip", false, "Display Host IP"),
flagSet.BoolVar(&options.OutputCName, "cname", false, "Display Host cname"),
flagSet.BoolVar(&options.OutputCDN, "cdn", false, "Display CDN"),
flagSet.BoolVar(&options.Probe, "probe", false, "Display probe status"),
)
createGroup(flagSet, "matchers", "Matchers",
flagSet.StringVarP(&options.OutputMatchStatusCode,"match-code", "mc", "", "Match response with specific status code (-mc 200,302)"),
flagSet.StringVarP(&options.OutputMatchContentLength,"match-length", "ml", "", "Match response with specific content length (-ml 102)"),
flagSet.StringVarP(&options.OutputMatchString, "match-string", "ms","", "Match response with specific string"),
flagSet.StringVarP(&options.OutputMatchRegex, "match-regex", "mr","", "Match response with specific regex"),
flagSet.StringVarP(&options.OutputExtractRegex, "extract-regex", "er","", "Display response content with matched regex"),
)
createGroup(flagSet, "filters", "Filters",
flagSet.StringVarP(&options.OutputFilterStatusCode,"filter-code", "fc", "", "Filter response with specific status code (-fc 403,401)"),
flagSet.StringVarP(&options.OutputFilterContentLength,"filter-length", "fl", "", "Filter response with specific content length (-fl 23)"),
flagSet.StringVarP(&options.OutputFilterString, "filter-string", "fs", "", "Filter response with specific string"),
flagSet.StringVarP(&options.OutputFilterRegex, "filter-regex", "fe","", "Filter response with specific regex"),
)
createGroup(flagSet, "rate-limit", "Rate-Limit",
flagSet.IntVarP(&options.Threads, "threads","t", 50, "Number of threads"),
flagSet.IntVarP(&options.RateLimit,"rate-limit","rl", 150, "Maximum requests to send per second"),
)
createGroup(flagSet, "Misc", "Miscellaneous",
flagSet.BoolVar(&options.TLSProbe, "tls-probe", false, "Send HTTP probes on the extracted TLS domains"),
flagSet.BoolVar(&options.TLSGrab, "tls-grab", false, "Perform TLS(SSL) data grabbing"),
flagSet.BoolVar(&options.CSPProbe, "csp-probe", false, "Send HTTP probes on the extracted CSP domains"),
flagSet.BoolVar(&options.Pipeline, "pipeline", false, "HTTP1.1 Pipeline probe"),
flagSet.BoolVar(&options.HTTP2Probe, "http2", false, "HTTP2 probe"),
flagSet.BoolVar(&options.VHost, "vhost", false, "Check for VHOSTs"),
flagSet.VarP(&options.CustomPorts,"ports","p", "Port ranges to scan (nmap syntax: eg 1,2-10,11)"),
flagSet.StringVar(&options.RequestURI, "path", "", "Request path/file (example '/api')"),
flagSet.StringVar(&options.RequestURIs, "paths", "", "Command separated paths or file containing one path per line (example '/api/v1,/apiv2')"),
)
createGroup(flagSet, "configs", "Configurations",
flagSet.IntVarP(&options.MaxResponseBodySizeToSave, "response-size-to-save", "rsts", math.MaxInt32, "Max response size to save in bytes"),
flagSet.IntVarP(&options.MaxResponseBodySizeToRead,"response-size-to-read", "rstr", math.MaxInt32, "Max response size to read in bytes"),
flagSet.Var(&options.Allow, "allow", "Allow list of IP/CIDR's to process (file or comma separated)"),
flagSet.Var(&options.Deny, "deny", "Deny list of IP/CIDR's to process (file or comma separated)"),
flagSet.BoolVar(&options.RandomAgent, "random-agent", true, "Use randomly selected HTTP User-Agent header value"),
flagSet.VarP(&options.CustomHeaders,"header", "H", "Custom Header to send with request"),
flagSet.StringVarP(&options.HTTPProxy,"proxy", "http-proxy", "", "HTTP Proxy, eg http://127.0.0.1:8080"),
flagSet.BoolVar(&options.Unsafe, "unsafe", false, "Send raw requests skipping golang normalization"),
flagSet.BoolVar(&options.Resume, "resume", false, "Resume scan using resume.cfg"),
flagSet.BoolVarP(&options.NoColor,"no-color", "nc", false, "Disable colored output"),
flagSet.BoolVarP(&options.NoFallback,"no-fallback", "nf", false, "Probe both protocol (HTTPS and HTTP)"),
flagSet.BoolVarP(&options.NoFallbackScheme,"no-fallback-scheme", "nfs", false, "Probe with input protocol scheme"),
flagSet.BoolVarP(&options.FollowRedirects,"follow-redirects", "fr", false, "Follow HTTP Redirects"),
flagSet.BoolVarP(&options.FollowHostRedirects,"follow-host-redirects","fhr", false, "Only Follow redirects on the same host"),
flagSet.IntVarP(&options.MaxRedirects,"max-redirects","maxr", 10, "Max number of redirects to follow per host"),
flagSet.BoolVar(&options.VHostInput, "vhost-input", false, "Get a list of vhosts as input"),
flagSet.StringVar(&options.Methods, "x", "", "Request Methods to use, use 'all' to probe all HTTP methods"),
flagSet.StringVar(&options.RequestBody, "body", "", "Content to send in body with HTTP request"),
)
createGroup(flagSet, "template", "Template",
flagSet.BoolVar(&options.TLSGrab, "tls-grab", false, "Perform TLS(SSL) data grabbing"),
flagSet.BoolVar(&options.TechDetect, "tech-detect", false, "Perform wappalyzer based technology detection"),
flagSet.IntVar(&options.Threads, "threads", 50, "Number of threads"),
createGroup(flagSet, "Optimizations", "Optimizations",
flagSet.IntVar(&options.Retries, "retries", 0, "Number of retries"),
flagSet.IntVar(&options.Timeout, "timeout", 5, "Timeout in seconds"),
flagSet.BoolVar(&options.VHost, "vhost", false, "Check for VHOSTs"),
flagSet.BoolVar(&options.FollowRedirects, "follow-redirects", false, "Follow HTTP Redirects"),
flagSet.BoolVar(&options.FollowHostRedirects, "follow-host-redirects", false, "Only Follow redirects on the same host"),
flagSet.IntVar(&options.MaxRedirects, "max-redirects", 10, "Max number of redirects to follow per host"),
flagSet.BoolVar(&options.TLSProbe, "tls-probe", false, "Send HTTP probes on the extracted TLS domains"),
flagSet.BoolVar(&options.CSPProbe, "csp-probe", false, "Send HTTP probes on the extracted CSP domains"),
flagSet.BoolVar(&options.Unsafe, "unsafe", false, "Send raw requests skipping golang normalization"),
flagSet.BoolVar(&options.Pipeline, "pipeline", false, "HTTP1.1 Pipeline probe"),
flagSet.BoolVar(&options.HTTP2Probe, "http2", false, "HTTP2 probe"),
flagSet.BoolVar(&options.NoFallback, "no-fallback", false, "Probe both protocol (HTTPS and HTTP)"),
flagSet.BoolVar(&options.NoFallbackScheme, "no-fallback-scheme", false, "Probe with input protocol scheme"),
flagSet.BoolVar(&options.RandomAgent, "random-agent", true, "Use randomly selected HTTP User-Agent header value"),
flagSet.Var(&options.Allow, "allow", "Allow list of IP/CIDR's to process (file or comma separated)"),
flagSet.Var(&options.Deny, "deny", "Deny list of IP/CIDR's to process (file or comma separated)"),
flagSet.IntVar(&options.MaxResponseBodySizeToSave, "response-size-to-save", math.MaxInt32, "Max response size to save in bytes (default - unlimited)"),
flagSet.IntVar(&options.MaxResponseBodySizeToRead, "response-size-to-read", math.MaxInt32, "Max response size to read in bytes (default - unlimited)"),
flagSet.BoolVar(&options.Resume, "resume", false, "Resume scan using resume.cfg"),
flagSet.BoolVar(&options.ExcludeCDN, "exclude-cdn", false, "Skip full port scans for CDNs (only checks for 80,443)"),
flagSet.IntVar(&options.HostMaxErrors, "max-host-error", 30, "Max error count per host before skipping remaining path/s"),
flagSet.IntVarP(&options.HostMaxErrors,"max-host-error", "maxhr", 30, "Max error count per host before skipping remaining path/s"),
flagSet.BoolVarP(&options.ExcludeCDN,"exclude-cdn", "ec", false, "Skip full port scans for CDNs (only checks for 80,443)"),
)
createGroup(flagSet, "filters", "Filtering",
flagSet.StringVar(&options.OutputMatchStatusCode, "mc", "", "Match response with specific status code (-mc 200,302)"),
flagSet.StringVar(&options.OutputMatchContentLength, "ml", "", "Match response with specific content length (-ml 102)"),
flagSet.StringVar(&options.OutputFilterStatusCode, "fc", "", "Filter response with specific status code (-fc 403,401)"),
flagSet.StringVar(&options.OutputFilterContentLength, "fl", "", "Filter response with specific content length (-fl 23)"),
flagSet.StringVar(&options.OutputFilterString, "filter-string", "", "Filter response with specific string"),
flagSet.StringVar(&options.OutputMatchString, "match-string", "", "Match response with specific string"),
flagSet.StringVar(&options.OutputFilterRegex, "filter-regex", "", "Filter response with specific regex"),
flagSet.StringVar(&options.OutputMatchRegex, "match-regex", "", "Match response with specific regex"),
flagSet.StringVar(&options.OutputExtractRegex, "extract-regex", "", "Display response content with matched regex"),
)
createGroup(flagSet, "rate-limit", "Rate-limit",
flagSet.IntVar(&options.RateLimit, "rate-limit", 150, "Maximum requests to send per second"),
createGroup(flagSet, "debug", "Debug",
flagSet.BoolVar(&options.Silent, "silent", false, "Silent mode"),
flagSet.BoolVar(&options.Verbose, "verbose", false, "Verbose Mode"),
flagSet.BoolVar(&options.Version, "version", false, "Show version of httpx"),
flagSet.BoolVar(&options.Debug, "debug", false, "Debug mode"),
flagSet.BoolVar(&options.ShowStatistics, "stats", false, "Enable statistic on keypress (terminal may become unresponsive till the end)"),
)
createGroup(flagSet, "output", "Output",
flagSet.StringVar(&options.Output, "o", "", "File to write output to (optional)"),
flagSet.BoolVar(&options.StatusCode, "status-code", false, "Display HTTP response status code"),
flagSet.BoolVar(&options.ExtractTitle, "title", false, "Display page title"),
flagSet.BoolVar(&options.Location, "location", false, "Display location header"),
flagSet.BoolVar(&options.ContentLength, "content-length", false, "Display HTTP response content length"),
flagSet.StringVarP(&options.Output,"output", "o", "", "File to write output to (optional)"),
flagSet.BoolVar(&options.StoreResponse, "sr", false, "Store HTTP response to directory (default 'output')"),
flagSet.StringVar(&options.StoreResponseDir, "srd", "output", "Custom directory to store HTTP responses"),
flagSet.BoolVar(&options.JSONOutput, "json", false, "Display output in JSON format"),
flagSet.BoolVar(&options.CSVOutput, "csv", false, "Display output in CSV format"),
flagSet.BoolVar(&options.OutputMethod, "method", false, "Display request method"),
flagSet.BoolVar(&options.Silent, "silent", false, "Silent mode"),
flagSet.BoolVar(&options.Version, "version", false, "Show version of httpx"),
flagSet.BoolVar(&options.Verbose, "verbose", false, "Verbose Mode"),
flagSet.BoolVar(&options.NoColor, "no-color", false, "Disable colored output"),
flagSet.BoolVar(&options.OutputServerHeader, "web-server", false, "Display server header"),
flagSet.BoolVar(&options.OutputWebSocket, "websocket", false, "Display server using websocket"),
flagSet.BoolVar(&options.responseInStdout, "response-in-json", false, "Show Raw HTTP response In Output (-json only) (deprecated)"),
flagSet.BoolVar(&options.responseInStdout, "include-response", false, "Show Raw HTTP response In Output (-json only)"),
flagSet.BoolVarP(&options.responseInStdout, "include-response", "irr",false, "Show Raw HTTP response In Output (-json only)"),
flagSet.BoolVar(&options.chainInStdout, "include-chain", false, "Show Raw HTTP Chain In Output (-json only)"),
flagSet.BoolVar(&options.OutputContentType, "content-type", false, "Display content-type header"),
flagSet.BoolVar(&options.OutputIP, "ip", false, "Display Host IP"),
flagSet.StringVar(&options.InputRawRequest, "request", "", "File containing raw request"),
flagSet.BoolVar(&options.Debug, "debug", false, "Debug mode"),
flagSet.BoolVar(&options.OutputCName, "cname", false, "Display Host cname"),
flagSet.BoolVar(&options.OutputCDN, "cdn", false, "Display CDN"),
flagSet.BoolVar(&options.OutputResponseTime, "response-time", false, "Display the response time"),
flagSet.BoolVar(&options.ShowStatistics, "stats", false, "Enable statistic on keypress (terminal may become unresponsive till the end)"),
flagSet.BoolVar(&options.StoreChain, "store-chain", false, "Save chain to file (default 'output')"),
flagSet.BoolVar(&options.Probe, "probe", false, "Display probe status"),
flagSet.BoolVar(&options.CSVOutput, "csv", false, "Display output in CSV format"),
)
_ = flagSet.Parse()
// Read the inputs and configure the logging