Commit Graph

509 Commits

Author SHA1 Message Date
David Adrian 320f7aa144
Add ModuleSet object (#247)
Eventually this can be used to replace AddCommand, allowing the use of a
non-global config object.

https://github.com/zmap/zgrab2/pull/247
2020-02-18 10:23:43 -05:00
Julian Kornberger f5b169cbd4
Trim SMTP response (#237)
this avoids to have \r\n in the error message
2020-02-03 16:52:37 -08:00
Meteorite c3ef8dcd8b
add option to stop scanning host after first successful protocol (#242) 2020-02-03 16:45:08 -08:00
Jeff Cody d9885ed26c
Merge pull request #240 from zmap/jcody/http-custom-resolver
Add the ability to use a custom (fake) DNS resolver
2020-02-02 21:04:06 -05:00
Jeff Cody 0b6845eed8
Update header comment for fake_resolver.go 2020-01-31 23:08:58 -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 3bb649f175
Add custom fake resolver
This adds a custom resolver, that will always resolve to the specified
ip address.  The intended usage is for when doing name-based scans,
but have a specified IP address as well.  This will provide a resolver
that can be added to a Dialer, that will cause all DNS lookups to match
the specified IP address.
2020-01-29 18:55:05 -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
Zakir Durumeric 4c1161b29e
Cablej master (#232)
* Add support to HTTP for setting local interface

* Add net import

* use correct flag

* better CLI flag name

* Remove logged `\n`

* Remove extranneous if statement
2019-11-19 08:31:15 -08:00
thegwan dd478522e9
Merge pull request #228 from thegwan/helloonly-fix
prevent running key exchange if hello-only flag set
2019-11-02 11:51:07 -07:00
thegwan 31645233a5 reduce code duplication 2019-10-23 17:45:40 +00:00
David Adrian 86e24ff81f Attempt to fix CI 2019-10-22 20:25:54 +00:00
thegwan 422cdc7b9f prevent running key exchange if hello-only flag set 2019-10-21 08:31:57 +00:00
David Adrian 8427a23db1
Add support for importing the ZGrab2 main (#224)
Move ZGrab2's main function to a library, and call it in cmd/zgrab2
after importing all of our modules. Consumes of ZGrab2 as a library can
use the same approach to provide custom sets of modules, without having
to hack the build system or reimplement main.

https://github.com/zmap/zgrab2/pull/224
2019-09-25 08:51:31 -04:00
David Adrian dda796c8da
Add support for Go modules (#223)
This pins dependencies via go mod init. Regular builds should still
work, so this won't affect CI. It overrides the default set of deps for
ZFlags, to point to v1.4.0-beta.1. This gets the ParseCommandLine
function.
2019-09-24 13:55:05 -04:00
cy 0b6d1d994d fixed bug for io.EOF on fox moudle (#207)
fox read with  io.EOF ,but the data  has been returned

https://github.com/zmap/zgrab2/pull/207
2019-09-23 20:51:09 -04:00
Benjamin Wireman 30aaee1c25
Merge pull request #218 from zmap/redis_schema_fix
fix schema in redis for nonexistent_response being required
2019-09-06 11:58:16 -04:00
bwireman 27e6033b03 fix schema in redis for nonexistent_response being required 2019-09-06 11:00:30 -04:00
David Adrian 99e5b4c7e3
Merge pull request #216 from zmap/jcody/scantarget-port
Allow applications to specify port via `ScanTarget{}`
2019-08-21 15:07:14 -07:00
Jeff Cody fb49609733
Remove `GetPort()` from modules
The previous patch allows the port to be specified in the
`ScanTarget{}`.

Since the port option in the Config may not be the port currently being
scanned, delete the `GetPort()` function provided by each module.

The `GetPort()` function is also not used.  While we could just change
the meaning of this function, to mean "Return the port in the Config",
it is probably better to go ahead and just remove all references to it
as there are no users.
2019-08-21 14:55:14 -04:00
Jeff Cody a38194a7fd
Add `port` to ScanTarget{} that overrides Config
The port field is tied to the configuration of each instance of
`Scanner` struct.  However, applications using zgrab2 scan modules may
want to specify specific ports to scan, without needing to initialize a
whole new module.

This patch adds a pointer to a uint describing a port to `ScanTarget{}`.
If that is nil, the specified port will override the port in the Config.
2019-08-21 14:53:56 -04:00
Zakir Durumeric 28cde1a5a6
Add SSH Client Hello Only flag (#215) 2019-08-15 17:01:24 -07:00
Ricky Diaz Gomez 24d44b6282
Merge pull request #211 from zmap/ricky/redis
ricky/redis scanner
2019-07-09 11:01:45 -04:00
Ricky Diaz Gomez e23894590d Redis: Removed the tests that test the --mappings and --custom-commands
flags for the Redis scanner.
2019-07-08 10:23:18 -04:00
Ricky Diaz Gomez cbb32a2abd
Merge pull request #208 from zmap/ricky/redis
[CEN-1492] ricky/redis
2019-06-28 16:48:52 -04:00
Ricky Diaz Gomez 98b142ec2e Redis: Made major, minor, and patchlevel be pointers to ints so that they're correctly omitted 2019-06-28 16:30:12 -04:00
Ricky Diaz Gomez 67fbf1facb Redis: Store the major, minor, and patchlevel as ints as well as the whole version as a string 2019-06-28 15:54:11 -04:00
Ricky Diaz Gomez 7c651c0be5 Redis: Updated setting suffix -- zero value is already empty string 2019-06-25 12:57:40 -04:00
Ricky Diaz Gomez 31788624f2 Redis: Added max file size check 2019-06-25 11:57:47 -04:00
Ricky Diaz Gomez 4bae7a74dd Redis: Quoted the docker-run.sh file path within test.sh 2019-06-25 10:57:46 -04:00
Ricky Diaz Gomez 41df4251b6 Redis: Removed break statement when iterating through INFO response 2019-06-21 16:37:55 -04:00
Ricky Diaz Gomez 2495ff6a8c Redis: Changed casing of 'redis' within schema 2019-06-21 16:16:14 -04:00
Ricky Diaz Gomez bcaf844200 Redis: Made check so that if line_prefix_suffix only contains prefix, adds empty string to suffix index 2019-06-21 16:14:13 -04:00
Ricky Diaz Gomez d6059c655d Redis: Updated the testdata 2019-06-20 17:30:01 -04:00
Ricky Diaz Gomez f71548ed94 Redis: Missed an old bool check 2019-06-20 17:14:30 -04:00
Ricky Diaz Gomez 84ffc2c667 Redis: Updated the break condition when looking for fields within info_response 2019-06-20 12:17:26 -04:00
Ricky Diaz Gomez f3184857b4 Redis: Updated testdata 2019-06-19 16:15:52 -04:00
Ricky Diaz Gomez 4446024636 Redis: Changed commandMappings to map[string]string, fixed QUIT err=io.EOF bug, and capture redis_mode now 2019-06-19 16:06:43 -04:00
Ricky Diaz Gomez d9ccfe88f6 Redis: Updated testdata 2019-06-19 13:02:20 -04:00
Ricky Diaz Gomez e12f32b521 Redis: Now gather the OS the server is running 2019-06-19 09:51:40 -04:00
Ricky Diaz Gomez 5be58b2b0d Redis: Actually send the custom commands and store the responses. Also updated the zschema 2019-06-17 17:32:51 -04:00
Ricky Diaz Gomez f0d9070733 Redis: Takes JSON/YAML file that allows for renaming of commands 2019-06-17 15:23:56 -04:00
Jeff Cody 043ca87528
Merge pull request #206 from codyprime/jcody/smbv1-fix
SMB1 Probing
2019-06-10 17:53:42 -04:00
Jeff Cody b69c22c532
SMB: Probe for SMB1 in addition to SMB2
If the probe for SMB2 fails, close the connection and then try probing
for SMB1 as a backup.

Since there are more SMB2 servers in the wild, that is the first
attempt.
2019-06-10 17:17:20 -04:00
Jeff Cody 1232ca4e60
SMB: Add Negotiation Req & Response for v1
Send SMB1 header, and Negotiation Request message for SMB1.

This brings the zgrab2 smb1 scanner to parity with the zgrab smb1
scanner, with presence detection via smbv1_support.

We check the ProtocolID in the raw data response, for two reasons:

1. Even if the full unmarshal fails for the message, we will log
   that it is an smbv1 server

2. We need to add more response types structs, because the format
   is different for various SMB1 dialects.

The negotiation response v1 structure is for the SMB1 "NT LM 0.12"
dialect, and is essentially placeholder for now for future parsing.

TODO: Unmarshal into the appropriate message struct based on
SMB1 dialect, and parse dialect and capabilities, and return those
results.
2019-06-10 17:17:20 -04:00
Jeff Cody f2b76412fb
SMB: Combine 'GetSMBLog()' and 'GetSMBBanner()'
These two functions are largely duplicates, and only differ in the
boolean option passed to LoggedNegotiateProtocol().  Combine the
functions, and just take that option in as an argument to pass along.
2019-06-07 16:54:26 -04:00
Jeff Cody c0f5084a6a
Merge pull request #205 from codyprime/jcody/lib-smbfix
SMB: Bounds check slice index before access
2019-06-05 14:02:20 -04:00
Jeff Cody 2e67991362
SMB: Bounds check slice index before access
The smb library bounds checks for a message size that is too large, but
does not check for a message size that is way too small.  Error out if
the message size is not at least as large as the ProtocolID 4-byte
preamble.

This fixes slice out of bound panics when checking the buffer for the
protID string for certain hosts.

Signed-off-by: Jeff Cody <jcody@censys.io>
2019-06-04 22:26:27 -04:00
Jeff Cody f2ba12c61d
Merge pull request #204 from codyprime/smb-enhance
SMB 2 Capabilities & Version parsing
2019-05-30 16:51:41 -04:00
Jeff Cody 6e38ec3e72
SMB: Fix typos in schema (PR204 review)
@justinbastress noted a couple of typos in the schema file, and
suggested a doc addition.
2019-05-29 16:15:04 -04:00