Commit Graph

36 Commits

Author SHA1 Message Date
AG
ecd32d0d5d
Feature fail http to https for known status code and substrings (#308)
* Add `--fail-http-to-https` to retry as HTTPS when --retry-https is used and certain known responses are encountered indicating HTTPS should be used

* Apache: HTTP/400, substring "You're speaking plain HTTP to an SSL-enabled server port"
* NGINX: HTTP/400, substring "The plain HTTP request was sent to HTTPS port"

* Add additional substring observed indicating http->https

* Add another observed substring, adjust whitespace

* Use go-ism for slicing implicitly from index 0

Co-authored-by: Adam Greene <copyright@mzpqnxow.com>
2021-06-06 11:31:36 -07:00
AG
3c55bbe861
Specify arbitrary HTTP headers (#284)
* Add support for specifying arbitrary HTTP headers

* * (Minor, Comment) Fix incorrect comment, replace with more helpful (and accurate) comment
* (Minor, Linting) Rename raw_hash => rawHash, 4 occurences (linter)
* (Minor, Linting) Rename s -> scanner, 1 occurence (linter)
* (Sanity Checking) Prevent duplicate custom headers
* (Sanity Checking) Prevent attempts to set known immutable headers (host, content-length)

* Add --custom-header-delimeter for convenience, in practice, quoting the header values that contain comma can be problematic

* Make the separator consistent for both custom-headers-names and custom-headers-values. It's just weird having them be different :>

* Spelling delimiter correctly would probably help...

* Update modules/http/scanner.go

Co-authored-by: engn33r <engn33r@users.noreply.github.com>

Co-authored-by: Adam Greene <copyright@mzpqnxow.com>
Co-authored-by: Zakir Durumeric <zakird@gmail.com>
Co-authored-by: engn33r <engn33r@users.noreply.github.com>
2021-06-06 11:17:33 -07:00
AG
5e9507cacf
[BUGFIX] Set SNI on each redirect to avoid handshake failures / incorrect server name (#306)
* Set SNI explicitly, in case it's a redirect (fix for #300)

* Fix the SNI issue correctly, using the host portion of addr, while respecting --server-name and --no-sni

* Clean up double error logging pointed out by dadrien

* Comply with RFC4366, do not set SNI server name for IP address

Co-authored-by: Adam Greene <copyright@mzpqnxow.com>
https://github.com/zmap/zgrab2/pull/306
2021-04-09 13:36:07 -06:00
Benjamin Wireman
d9ed4f141d
improves http body decoding and enforces max length (#295)
https://github.com/zmap/zgrab2/pull/295
2021-02-03 10:56:32 -05:00
Tim Schumacher
66c842d234 Put body_length behind flag to zschema 2020-09-18 11:01:46 -04:00
Tim Schumacher
c034bb26a1 Use hash setting on getCheckRedirect 2020-09-17 17:14:23 -04:00
Tim Schumacher
fc82b6b673 Capture BodyTextLength 2020-09-17 15:01:27 -04:00
Tim Schumacher
a7ad9a27d2 Combine to single option 2020-09-17 14:08:02 -04:00
Tim Schumacher
40ebf2ae9c Spelling 2020-09-17 13:21:03 -04:00
Tim Schumacher
7c61e14cfc Fix test 2020-09-17 12:15:07 -04:00
Tim Schumacher
f96339b30b Add BodyHashAlgorithm option 2020-09-17 11:31:31 -04:00
Tim Schumacher
8f4f1bb1ec Types 2020-09-17 11:08:26 -04:00
Tim Schumacher
30e6cdb73f Add BodyHash field with hash type prefix 2020-09-17 11:04:27 -04:00
Tim Schumacher
4775cf85f4 Add option to compute http BodySHA256 on decoded BodyText 2020-09-17 10:13:52 -04:00
Jeff Cody
76d09b59c5
http/tls: Add option to override SignatureAndHashes
So that we can advertise a slightly more expansive default set of
signature/hash algorithms in the signature_algorithms extension of
the TLS Client Hello, provide an option to use a pre-defined override.

This also splits up the TLS connection helper in tls.go, so that the
tls.Config can be modified by a scanner module.
2020-05-08 17:32:33 -04:00
bwireman
8395d72fee use DetermineEncoding To try and translate page to UTF8 if possible 2020-03-21 10:51:04 -04:00
Jeff Cody
0bd36c5267
modules/http: Add option to suppress errors when max redirects exceeded (#253)
If the --max-redirects value is exceeded, we return
SCAN_APPLICATION_ERROR with "Too many redirect" as the error message.

Add an option to suppress this error, and return success even if we
exceed the maximum specified number of redirects.
2020-02-28 13:56:18 -05:00
Jeff Cody
909643c227
HTTP Module: Keep scanner.config immutable during scans (#245)
The Scanner.config struct is a configuration for all instances of
Scanner.  Scanner.Scan() is called concurrently by multiple worker
goroutines; while Scanner is dereferenced before the call, the config
struct is a pointer, and so modifications to it will affect all other
running scans done with that Scanner.

Make sure we treat it as immutable during anything invoked by
Scanner.Scan() in the http module.

https://github.com/zmap/zgrab2/pull/245
2020-02-19 14:31:12 -05:00
David Adrian
11425ac78b
Add Description() to ScanModule (#248)
This abstracts more of the help text into the ScanModule definition,
removing some more of the need for `zgrab2.AddCommand()`

https://github.com/zmap/zgrab2/pull/248
2020-02-18 10:24:04 -05:00
Jeff Cody
82da88e34d
Let HTTP scanner use the custom resolver
If both an IP address and a domain are specified for a scan, have the
HTTP scanner use a fake resolver in the DialContext, so that we always
scan the intended IP and Domain name pair.

However, make sure redirects still function as normal, so only use our
fake resolver if the domain name matches the original targeted domain
name.

In addition, the custom resolver is only used if the network specified
is one that supports domain names.
2020-01-31 14:40:36 -05:00
Jeff Cody
d12c70e5de Honor port override when composing URL (#233)
Commit a38194a added an optional port override as part of the
scan target.  The HTTP and IPP modules, however, still compose
the URL (and select http vs https) by ignoring the override.

This checks for the override, and if present uses the scan target
port.  Otherwise, it falls back to the config port.

https://github.com/zmap/zgrab2/pull/233
2019-11-20 10:14:18 -05:00
Benjamin VanderSloot
93f30ef698 Use Target Domain name in SNI when using HTTP
Previous addition of GetTLSConfigForTarget (811eb38) did not modify
HTTP module to use SNI. This let to the very cryptic unknown-error:
remote error: internal error. Some servers give Fatal alerts when
they don't get an SNI extension. Discovered on a `Pagely-ARES/1.3.21`
Server
2019-03-01 21:29:22 -05:00
Justin Bastress
8c71100b9e gofmt it 2018-10-08 11:27:06 -04:00
cy
2e94480cce
To ensure that the HTTP connection is not blocked! 2018-10-05 14:59:28 +08:00
cy
d5258bdc6e
To ensure that the HTTP connection is not blocked!
https://github.com/zmap/zgrab2/issues/171
2018-10-05 14:51:14 +08:00
Justin Bastress
900b0d5912 add bytelimit tests 2018-09-27 14:00:26 -04:00
Justin Bastress
45a4cb0e90 re #163 -- add outer whole-connection timeout to TimeoutConnection, and add scan-target-wide timeout to HTTP scanner (adding a max time spent across redirects, too) 2018-09-05 14:33:59 -04:00
Alex Holland
4f046b3085 Implement timeout to accept float value (#111)
* Implement timeout as a float value vs int

* remove unnecessary second multiplier

* whoops, missed one

* Switch type to time.Duration

* Fixup integration tests, change default and description

* Whoops, bad merge

* fix build
2018-07-02 13:00:45 -04:00
J. Alex Halderman
cd2070d3bc mend 2018-06-26 13:57:28 -04:00
J. Alex Halderman
9df97e03cf Add support for tags and triggers. 2018-06-26 13:51:10 -04:00
Justin Bastress
e77866dfea loglevel fixes 2018-05-11 11:43:08 -04:00
Justin Bastress
3254857b58 Add a dialer for the non-TLS case in HTTP, so that --timeout is honored even if --use-https is not set (issue #109) 2018-05-01 13:33:21 -04:00
Justin Bastress
42ae30babe add --retry-https flag to work with unknown HTTP/HTTPS servers; remove unused request.tls field from zschema (only used for HTTP servers, caused zschema errors because of ListOf(ListOf())) 2018-04-05 14:19:58 -04:00
Justin Bastress
087337935b clean up connections before exiting 2018-03-21 17:16:58 -04:00
Justin Bastress
17a5c0e85c Scanner modules return the protocol ID, scan returns the protocol in the results. 2018-03-12 13:36:11 -04:00
justinbastress
2766a7ae08
Port http from zgrab (#31) 2018-02-09 13:45:50 -05:00