Honor port override when composing URL #233
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How to Test
Verify existing behavior works (no regression):
A)
echo hostname | zgrab2 http --use-https -p 443
B)
echo hostname | zgrab2 http --use-https
Run
A
should end in success, and also grab the TLS cert.Run
B
should end in error, as it attempted against the default port 80 (assuming of course https is not running on this port on the host).Verify new behavior
This is a bit trickier, you need a different framework other than
cmd/zgrab2
that initializes the module, and performs a scan. However, if that is done, then if theScanTarget
contains a port number, it should override both the default and cmdline passes ports, and use the port specified inScanTarget