Giter Club home page Giter Club logo

zgrab2's Introduction

ZGrab 2.0

ZGrab is a fast, modular application-layer network scanner designed for completing large Internet-wide surveys. ZGrab is built to work with ZMap (ZMap identifies L4 responsive hosts, ZGrab performs in-depth, follow-up L7 handshakes). Unlike many other network scanners, ZGrab outputs detailed transcripts of network handshakes (e.g., all messages exchanged in a TLS handshake) for offline analysis.

ZGrab 2.0 contains a new, modular ZGrab framework, which fully supersedes https://github.com/zmap/zgrab.

Installation

With Docker

You can run ZGrab 2.0 with our official Docker image. For example, to scan a single website using the HTTP module, you can use:

echo 'example.com' | docker run --rm -i ghcr.io/zmap/zgrab2 http

For more complex scanning scenarios, such as using multiple modules or custom configurations, you can create a configuration file and pass it to the container:

docker run --rm -i -v /path/to/your/config.ini:/config.ini ghcr.io/zmap/zgrab2 multiple -c /config.ini

Replace /path/to/your/config.ini with the path to your configuration file on the host machine. See Multiple Module Usage for more details on configurations.

Building from Source

For Go 1.17 and later you must build from source:

git clone https://github.com/zmap/zgrab2.git
cd zgrab2
make
./zgrab2

For Go 1.16 and below you can install via go get:

You will need to have a valid $GOPATH set up, for more information about $GOPATH, see https://golang.org/doc/code.html.

Once you have a working $GOPATH, run:

go get github.com/zmap/zgrab2

This will install zgrab under $GOPATH/src/github.com/zmap/zgrab2

cd $GOPATH/src/github.com/zmap/zgrab2
make

Single Module Usage

ZGrab2 supports modules. For example, to run the ssh module use

./zgrab2 ssh

To retrieve detailed command-line usage and options for a specific module, append -h to the command:

./zgrab2 [module] -h

This will display the module-specific options, as well as the application-wide options, including usage examples, available flags, and descriptions for each option.

Module specific options must be included after the module. Application specific options can be specified at any time.

Input Format

Targets are specified with input files or from stdin, in CSV format. Each input line has three fields:

IP, DOMAIN, TAG

Each line must specify IP, DOMAIN, or both. If only DOMAIN is provided, scanners perform a DNS hostname lookup to determine the IP address. If both IP and DOMAIN are provided, scanners connect to IP but use DOMAIN in protocol-specific contexts, such as the HTTP HOST header and TLS SNI extension.

If the IP field contains a CIDR block, the framework will expand it to one target for each IP address in the block.

The TAG field is optional and used with the --trigger scanner argument.

Unused fields can be blank, and trailing unused fields can be omitted entirely. For backwards compatibility, the parser allows lines with only one field to contain DOMAIN.

These are examples of valid input lines:

10.0.0.1
domain.com
10.0.0.1, domain.com
10.0.0.1, domain.com, tag
10.0.0.1, , tag
, domain.com, tag
192.168.0.0/24, , tag

Multiple Module Usage

To run a scan with multiple modules, a .ini file must be used with the multiple module. Below is an example .ini file with the corresponding zgrab2 command.

multiple.ini

[Application Options]
output-file="output.txt"
input-file="input.txt"
[http]
name="http80"
port=80
endpoint="/"
[http]
name="http8080"
port=8080
endpoint="/"
[ssh]
port=22
./zgrab2 multiple -c multiple.ini

Application Options must be the initial section name. Other section names should correspond exactly to the relevant zgrab2 module name. The default name for each module is the command name. If the same module is to be used multiple times then name must be specified and unique.

Multiple module support is particularly powerful when combined with input tags and the --trigger scanner argument. For example, this input contains targets with two different tags:

141.212.113.199, , tagA
216.239.38.21, censys.io, tagB

Invoking zgrab2 with the following multiple configuration will perform an SSH grab on the first target above and an HTTP grab on the second target:

[ssh]
trigger="tagA"
name="ssh22"
port=22

[http]
trigger="tagB"
name="http80"
port=80

Adding New Protocols

Add module to modules/ that satisfies the following interfaces: Scanner, ScanModule, ScanFlags.

The flags struct must embed zgrab2.BaseFlags. In the modules init() function the following must be included.

func init() {
    var newModule NewModule
    _, err := zgrab2.AddCommand("module", "short description", "long description of module", portNumber, &newModule)
    if err != nil {
        log.Fatal(err)
    }
}

Output schema

To add a schema for the new module, add a module under schemas, and update zgrab2_schemas/zgrab2/__init__.py to ensure that it is loaded.

See zgrab2_schemas/README.md for details.

Integration tests

To add integration tests for the new module, run integration_tests/new.sh [your_new_protocol_name]. This will add stub shell scripts in integration_tests/your_new_protocol_name; update these as needed. See integration_tests/mysql/* for an example. The only hard requirement is that the test.sh script drops its output in $ZGRAB_OUTPUT/[your-module]/*.json, so that it can be validated against the schema.

How to Run Integration Tests

To run integration tests, you must have Docker and Python 2 on host installed. Then, you can follow the following steps to run integration tests:

go get github.com/jmespath/jp && go build github.com/jmespath/jp
# or, sudo wget https://github.com/jmespath/jp/releases/download/0.2.1/jp-linux-amd64 -O /usr/local/bin/jp && sudo chmod +x /usr/local/bin/jp
pip2 install --user zschema
pip2 install --user -r requirements.txt
make integration-test

Running the integration tests will generate quite a bit of debug output. To ensure that tests completed successfully, you can check for a successful exit code after the tests complete:

echo $?
0

Refer to our Github Actions workflow for an example of how to prepare environment for integration tests.

License

ZGrab2.0 is licensed under Apache 2.0 and ISC. For more information, see the LICENSE file.

zgrab2's People

Contributors

andrewsardone avatar anthrax1 avatar aspacewalz avatar cdzombak avatar chushuai avatar clayzim avatar codyprime avatar corny avatar dabdine avatar dadrian avatar dependabot[bot] avatar developstorm avatar engn33r avatar hmcguinn avatar jordan-wright avatar justinbastress avatar meteorite avatar mindavi avatar mzpqnxow avatar nirusu avatar parkanzky avatar phillip-stephens avatar rickydia avatar seanstoppable avatar thegwan avatar twschum avatar vl4deee11 avatar yalegko avatar ycamper avatar zakird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zgrab2's Issues

unrecognized import path "golang.org/x/crypto/ssh/terminal"

I'm new for GO...

When i execute go get github.com/zmap/zgrab2 it shows:

package golang.org/x/crypto/ssh/terminal: unrecognized import path "golang.org/x/crypto/ssh/terminal" (https fetch: Get https://golang.org/x/crypto/ssh/terminal?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
package golang.org/x/sys/unix: unrecognized import path "golang.org/x/sys/unix" (https fetch: Get https://golang.org/x/sys/unix?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
package golang.org/x/net/idna: unrecognized import path "golang.org/x/net/idna" (https fetch: Get https://golang.org/x/net/idna?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)

Is there anything wrong with the git repository path?

And then i try to execute make in ../zgrab2 it shows:

cd cmd/zgrab2 && go build && cd ../..
../../lib/ssh/kex.go:22:2: cannot find package "golang.org/x/crypto/curve25519" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/crypto/curve25519 (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/crypto/curve25519 (from $GOPATH)
../../lib/ssh/keys.go:28:2: cannot find package "golang.org/x/crypto/ed25519" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/crypto/ed25519 (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/crypto/ed25519 (from $GOPATH)
../../lib/smb/ntlmssp/crypto.go:9:2: cannot find package "golang.org/x/crypto/md4" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/crypto/md4 (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/crypto/md4 (from $GOPATH)
../../../../sirupsen/logrus/terminal_check_notappengine.go:9:2: cannot find package "golang.org/x/crypto/ssh/terminal" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/crypto/ssh/terminal (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/crypto/ssh/terminal (from $GOPATH)
../../lib/http/h2_bundle.go:46:2: cannot find package "golang.org/x/net/http2/hpack" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/net/http2/hpack (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/net/http2/hpack (from $GOPATH)
../../../../weppos/publicsuffix-go/publicsuffix/publicsuffix.go:15:2: cannot find package "golang.org/x/net/idna" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/net/idna (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/net/idna (from $GOPATH)
../../lib/http/h2_bundle.go:48:2: cannot find package "golang.org/x/net/lex/httplex" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/net/lex/httplex (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/net/lex/httplex (from $GOPATH)
../../../../sirupsen/logrus/terminal_linux.go:10:8: cannot find package "golang.org/x/sys/unix" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/sys/unix (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/sys/unix (from $GOPATH)
../../lib/http/request.go:30:2: cannot find package "golang.org/x/text/unicode/norm" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/text/unicode/norm (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/text/unicode/norm (from $GOPATH)
../../lib/http/request.go:31:2: cannot find package "golang.org/x/text/width" in any of:
/home/user/Downloads/Go/go/src/golang.org/x/text/width (from $GOROOT)
/home/user/Code/Go/src/golang.org/x/text/width (from $GOPATH)
make: *** [zgrab2] Error 1

Improve integration test wait time

Most failures will occur with any service -- but, since we run the tests for each service before validating the output of any of them, you will have to wait several minutes before getting that result, i.e.:

  1. For each service:
    a. Start container(s)
    b. Run tests, store output
    c. Stop container(s)
  2. For all output files:
    a. Validate schema
    b. Check for success

This could be improved by instead doing something like

  1. For each service:
    a. Start container(s)
    b. Run tests, store output
    c. Stop container(s)
    d. Validate schema
    b. Check for success

zgrab2 JSON Marshaller

zgrab2 needs a special JSON Marshaller that can take into account command line flags and tags like zgrab.debug

config.go comments

	MetaFileName       string          `short:"m" long:"metadata-file" default:"-" description:"Metadata filename, use - for stdout"`
	LogFileName        string          `short:"l" long:"log-file" default:"-" description:"Log filename, use - for stdout"`

- should redirect to stderr not stdout for both of these

func init() {
	config.Multiple.ContinueOnError = true //set default for multiple value
}

Why isn't this just a command-line argument

	switch config.LogFileName {
	case "-":
		config.logFile = os.Stderr
	default:
		var err error
		if config.logFile, err = os.Create(config.LogFileName); err != nil {
			log.Fatal(err)
		}
		log.SetOutput(config.logFile)
	}

This is confusing logic as the non-default logic is labeled as default. Why not just use an if statement since there are only two options and that more clearly explains your logic?

if config.ConnectionsPerHost > 50 || config.ConnectionsPerHost < 1 {

You just checked that second predicate a line earlier.

postgres: detection threshold

Currently, if the scanner gets a connection on port 5432 and reads an 'N' followed by a disconnect / hang, that can be interpreted as a detection.

That may need to be tweaked.

HTTP Timeout doesn't work as expected

I specified the following on the command line:

echo google.com | ./zgrab2 http --port 8080 --timeout 3

(A site and port I expect to not connect but timeout after a certain point)

Rather than timing out after 3 seconds, according to the metadata at the end, it continues through for 75 seconds.

{"statuses":{"http":{"successes":0,"failures":1}},"start":"2018-05-01T11:55:54-04:00","end":"2018-05-01T11:57:10-04:00","duration":"1m15.374277319s"}

tls: Expose supported algorithms

There should be some way for users to determine if a given e.g. cipher suite or signature algorithm is actually supported by zcrypto (without waiting for a server to try using it).

module tls or http check heartbleed doesn't work

I'm testing zgrab2 on server vulnerable to heartbleed, but module tls or http tell me the host is not vulnerable to heartbleed.

zgrab2 http --heartbleed -p 443 --use-https

or

zgrab2 tls --heartbleed -p 443

output:

"heartbleed_log":{"heartbeat_enabled":false,"heartbleed_vulnerable":false}}

I tried with zgrab, the result output is correct.

Name Constraints schema is incorrect

See #34 but for name constraints.

JSON object specified for non-record field: data.tls.server_certificates.chain.parsed.extensions.name_constraints.excluded_ip_addresses

Fix TLS scanner

It seems that some flags are ignored / unused (for example, NoSNI is unused, and even without it, it doesn't seem that SNI is working).

Finish Zgrab2 initial functionality

  • finish http
  • finish ssh
  • finish tls
  • refactor cidr to ip list parsing, i.e. netIPv4Len vs len and incrementing ipv6 address in cidr block
  • implement ability to change network interface
  • implement connections per host (for loop)

utility.go comments

Some notes of things to be fixed up.

https://github.com/zmap/zgrab2/blob/master/utility.go
func ParseInput(s string) (*net.IPNet, string, error) {

This could use a better name. What kind of input is being parsed? At first I thought this was handling command-line arguments. Also, please put spaces in comments. :D

It seems strange that this function returns a pointer and a string. Why not just return the net.IPNet? I can't imagine this is a large object.

case j == -1:
		//ip,domain
		str := strings.Split(s, ",")

This should also handle the case "ip, domain". That's inevitably going to happen.

Add support for scanning for CONNECT hosts

The HTTP module should be able to behave exactly as it does now (e.g. follow redirects, output multiple requests in a chain), except it should be able to send those requests contingent on first scanning and finding an open CONNECT hosts. The expected interface and behavior would be something along the lines of zgrab2 --http --connect --method GET --path / --connect-target google.com, which would cause zgrab2 to send CONNECT requests to input hosts attempting to proxy to google.com. If the remote host is an open proxy, zgrab2 would then follow any redirects that google.com returns, but through the proxy.

We would add details of the CONNECT request to the http.Result struct, and still store the inner responses / redirects in the response/redirect chain.

Common HTTP request headers are unknown

From an HTTP request:

"request": {
  "url": {
    "scheme": "http",
    "host": "google.com",
    "path": "/"
  },
  "method": "GET",
  "headers": {
    "unknown": [
      {
        "key": "user_agent",
        "value": [
          "Mozilla/5.0 zgrab/0.x"
        ]
      },
      {
        "key": "accept",
        "value": [
          "*/*"
        ]
      }
    ]
  },
  "host": "google.com"

These shouldn't be unknown given that we send them with every request. We should find the list commonly sent headers and output all of them as recognized.

MySQL Integrations Tests Fail

I'm unable to get the MySQL integration tests to pass (maybe more than MySQL? Not sure) on a clean build.

Steps to Reproduce

  • go get the zmap/zgrab2 package
  • Run make integration-test

Debug Log

cd cmd/zgrab2 && go build && cd ../..
rm -f zgrab2
ln -s cmd/zgrab2/zgrab2 zgrab2
make -C docker-runner
docker build -t zgrab2_runner:latest -f Dockerfile -q .. > docker-runner.id || rm -f docker-runner.id
rm -rf zgrab-output
./integration_tests/test.sh
~/src/go/src/github.com/zmap/zgrab2/integration_tests ~/src/go/src/github.com/zmap/zgrab2
~/src/go/src/github.com/zmap/zgrab2/integration_tests/ftp ~/src/go/src/github.com/zmap/zgrab2/integration_tests ~/src/go/src/github.com/zmap/zgrab2
Running integration_tests/ftp/test.sh
ftp/test: Testing FTP with --authtls on zgrab_ftp...
+ echo target
+ /go/src/github.com/zmap/zgrab2/cmd/zgrab2/zgrab2 ftp --authtls
time="2018-01-31T05:54:56Z" level=info msg="started grab at 2018-01-31T05:54:56Z"
time="2018-01-31T05:54:57Z" level=info msg="finished grab at 2018-01-31T05:54:57Z"
{"statuses":{"ftp":{"successes":1,"failures":0}},"start":"2018-01-31T05:54:56Z","end":"2018-01-31T05:54:57Z","duration":"245.507085ms"}
ftp/test: Testing FTP on zgrab_ftp...
+ echo target
+ /go/src/github.com/zmap/zgrab2/cmd/zgrab2/zgrab2 ftp
time="2018-01-31T05:54:58Z" level=info msg="started grab at 2018-01-31T05:54:58Z"
time="2018-01-31T05:54:58Z" level=info msg="finished grab at 2018-01-31T05:54:58Z"
{"statuses":{"ftp":{"successes":1,"failures":0}},"start":"2018-01-31T05:54:58Z","end":"2018-01-31T05:54:58Z","duration":"11.024085ms"}
ftp/test: BEGIN vsftpd logs from zgrab_ftp [{(
Wed Jan 31 05:35:44 2018 [pid 9] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:35:44 2018 [pid 9] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
Wed Jan 31 05:35:44 2018 [pid 9] FTP command: Client "::ffff:172.17.0.18", "AUTH TLS"
Wed Jan 31 05:35:44 2018 [pid 9] FTP response: Client "::ffff:172.17.0.18", "234 Proceed with negotiation."
Wed Jan 31 05:35:44 2018 [pid 9] DEBUG: Client "::ffff:172.17.0.18", "Control connection terminated without SSL shutdown."
Wed Jan 31 05:35:45 2018 [pid 11] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:35:45 2018 [pid 11] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
Wed Jan 31 05:37:12 2018 [pid 19] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:37:12 2018 [pid 19] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
Wed Jan 31 05:37:12 2018 [pid 19] FTP command: Client "::ffff:172.17.0.18", "AUTH TLS"
Wed Jan 31 05:37:12 2018 [pid 19] FTP response: Client "::ffff:172.17.0.18", "234 Proceed with negotiation."
Wed Jan 31 05:37:12 2018 [pid 19] DEBUG: Client "::ffff:172.17.0.18", "Control connection terminated without SSL shutdown."
Wed Jan 31 05:37:13 2018 [pid 21] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:37:13 2018 [pid 21] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
Wed Jan 31 05:37:28 2018 [pid 29] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:37:28 2018 [pid 29] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
Wed Jan 31 05:37:28 2018 [pid 29] FTP command: Client "::ffff:172.17.0.18", "AUTH TLS"
Wed Jan 31 05:37:28 2018 [pid 29] FTP response: Client "::ffff:172.17.0.18", "234 Proceed with negotiation."
Wed Jan 31 05:37:28 2018 [pid 29] DEBUG: Client "::ffff:172.17.0.18", "Control connection terminated without SSL shutdown."
Wed Jan 31 05:37:30 2018 [pid 31] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:37:30 2018 [pid 31] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
Wed Jan 31 05:54:56 2018 [pid 39] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:54:56 2018 [pid 39] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
Wed Jan 31 05:54:56 2018 [pid 39] FTP command: Client "::ffff:172.17.0.18", "AUTH TLS"
Wed Jan 31 05:54:56 2018 [pid 39] FTP response: Client "::ffff:172.17.0.18", "234 Proceed with negotiation."
Wed Jan 31 05:54:57 2018 [pid 39] DEBUG: Client "::ffff:172.17.0.18", "Control connection terminated without SSL shutdown."
Wed Jan 31 05:54:58 2018 [pid 41] CONNECT: Client "::ffff:172.17.0.18"
Wed Jan 31 05:54:58 2018 [pid 41] FTP response: Client "::ffff:172.17.0.18", "220 (vsFTPd 3.0.3)"
)}] END vsftpd logs from zgrab_ftp
ftp/test: BEGIN docker logs from zgrab_ftp [{(
+ true
+ /usr/sbin/vsftpd
)}] END docker logs from zgrab_ftp
~/src/go/src/github.com/zmap/zgrab2/integration_tests ~/src/go/src/github.com/zmap/zgrab2
~/src/go/src/github.com/zmap/zgrab2/integration_tests/mysql ~/src/go/src/github.com/zmap/zgrab2/integration_tests ~/src/go/src/github.com/zmap/zgrab2
Running integration_tests/mysql/test.sh
mysql/test: Testing MySQL Version 5.5...
+ echo target
+ /go/src/github.com/zmap/zgrab2/cmd/zgrab2/zgrab2 mysql --timeout 10
time="2018-01-31T05:55:00Z" level=info msg="started grab at 2018-01-31T05:55:00Z"
time="2018-01-31T05:55:00Z" level=info msg="finished grab at 2018-01-31T05:55:00Z"
{"statuses":{"mysql":{"successes":1,"failures":0}},"start":"2018-01-31T05:55:00Z","end":"2018-01-31T05:55:00Z","duration":"8.047874ms"}
./test.sh: line 23: ./../../jp: No such file or directory
make: *** [integration-test] Error 127

I thought that maybe I was missing the jp directory/file but a mkdir or a touch didn't affect the test outcome. I'm running the tests from the root zgrab2 directory.

Environment

MacOS High Sierra version 10.13.3 (17D47)
Branch: master
Docker version 18.01.0-ce, build 03596f5

Extended Key Usage is schema'd incorrectly

I've been poking around with the TLS parts of the schema, and noticed a few things that are off. This is all largely due to cruft, but we should make zgrab2 schema's actually match the output. I expect this "bug" is due to something we fixup in either ZTag or ESLoader.

extended_key_usage is typed as a ListOf(Integer()), but it's actually an object. There's a script in ZCrypto that helps generate the actual schema for it. See https://github.com/zmap/zcrypto/blob/6447918deb1c310126e1cecbd711bdaac3b5558d/x509/extensions.go#L47 and https://github.com/zmap/zcrypto/blob/da4419f6d9aafae65261ac8e0e4472ac99a4d284/x509/extended_key_usage_schema.sh

Audit log messages

Log messages must only contain exceptional / actionable messages, not information about an individual scan failing because the host didn't act as expected.

Change HTTP timeout to be a float

Hi,
I wanted to set the timeout in http to a value less than a second
However the minimum allowed value is 1 second (I wanted for example 0.2 second, 200 milliseconds)
Thanks!

Fix IP List Parsing

refactor cidr to ip list parsing, i.e. netIPv4Len vs len and incrementing ipv6 address in cidr block

Move main

The current main directory should move to cmd/zgrab.

Add `--metadata-file`

We should support outputting metadata at the end of a scan. Starting a list of what should go into this file:

  • Start Time
  • End Time
  • Input Hosts
  • Breakdown of errors vs success
  • exact command that ZGrab received

Please feel free to take on more metadata requests.

Implement HTTP/2

Per @dadrian,

We have the code for HTTP/2, but need to resolve some differences with zcrypto/tls and crypto/tls in order to it to compile and pass tests.

More reusable HTTP library code

Writing scanners for protocols that sit on top of HTTP can lead to some serious code duplication.

Identify code that can be moved to a library that can be shared among any HTTP-based scanner.

Domain scanning

Currently if a domain is passed in, it can be looked up again for each scan.

Would it make more sense to look it up once at the start, pass it to each call to Scan(), and return it in the result (so that it is possible to determine which host was actually scanned)?

mysql: Disable debug logs in non-verbose mode

Logs are getting spammed with e.g.

:time="2018-05-10T17:14:12-04:00" level=debug msg="Failed to detect error from Server returned error after connecting: error_code = 0x46a; error_message = Host '...' is not allowed to connect to this MySQL server at goroutine 277 [running]:\nruntime/debug.Stack(0xae47c0, 0xc421efa5a0, 0xc420068040)\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0xa7\ngithub.com/zmap/zgrab2.TryGetScanStatus(0xae47c0, 0xc421efa5a0, 0xc421efa5a0, 0xae47c0)\n\t/var/search/tmp/go/src/github.com/zmap/zgrab2/status.go:92 +0x2b9\ngithub.com/zmap/zgrab2/modules/mysql.(*Scanner).Scan.func1(0xc421987bc0, 0xc421987ba0, 0xc42016ba90, 0xc421987bb0, 0xc421987b48)\n\t/var/search/tmp/go/src/github.com/zmap/zgrab2/modules/mysql/scanner.go:206 +0x189\npanic(0x988880, 0xc421efa5a0)\n\t/usr/local/go/src/runtime/panic.go:502 +0x229\ngithub.com/zmap/zgrab2/modules/mysql.(*Scanner).Scan(0xc42015c4c0, 0xc4214e3260, 0x10, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\n\t/var/search/tmp/go/src/github.com/zmap/zgrab2/modules/mysql/scanner.go:221 +0x348\ngithub.com/zmap/zgrab2.RunScanner(0xaec040, 0xc42015c4c0, 0xc4204108b0, 0xc4214e3260, 0x10, 0x10, 0x0, 0x0, 0xa56c59, 0x5, ...)\n\t/var/search/tmp/go/src/github.com/zmap/zgrab2/scanner.go:32 +0xd1\ngithub.com/zmap/zgrab2.grabTarget(0xc4214e3260, 0x10, 0x10, 0x0, 0x0, 0xc4204108b0, 0x0, 0x0, 0x0)\n\t/var/search/tmp/go/src/github.com/zmap/zgrab2/processing.go:92 +0x219\ngithub.com/zmap/zgrab2.Process.func2(0xc420169680, 0xc4204108b0, 0xc42050c000, 0xc4204c0050, 0xed)\n\t/var/search/tmp/go/src/github.com/zmap/zgrab2/processing.go:159 +0x126\ncreated by github.com/zmap/zgrab2.Process\n\t/var/search/tmp/go/src/github.com/zmap/zgrab2/processing.go:152 +0x191\n"

Document scannable protocols

We should document the protocols that ZGrab supports and provide an example for each one. Right now, it's very difficult to understand to know what the project supports.

module tls give exception on error but don't write the result as in zgrab

I have done a large scan on my network for port 443, not all host which have open port 443 has a web server HTTPS, so zgrab2 give me an error with stack trace but don't log the event in output file.
zgrab instead report all errors in output file, very useful for post-processing.

echo IP_WITH_443_OPEN_PORT_BUT_NO_HTTPS | /opt/scanner/sbin/zgrab2 tls --heartbleed --output-file=xxxxx.json
INFO[0000] started grab at 2018-03-26T09:39:30+02:00    
DEBU[0003] Failed to detect error from tls: oversized record received with length 20527 at goroutine 894 [running]:
runtime/debug.Stack(0xd9e8e0, 0xc420366d90, 0xc42003a040)
	/usr/lib/go-1.9/src/runtime/debug/stack.go:24 +0xa7
github.com/zmap/zgrab2.TryGetScanStatus(0xd9e8e0, 0xc420366d90, 0xc420366d90, 0xc420358e00)
	/root/go/src/github.com/zmap/zgrab2/status.go:92 +0x2c0
github.com/zmap/zgrab2/modules.(*TLSScanner).Scan(0xc42000e528, 0xc420368320, 0x10, 0x10, 0x0, 0x0, 0xa19060, 0x1, 0x4, 0x7f929d28acd0, ...)
	/root/go/src/github.com/zmap/zgrab2/modules/tls.go:72 +0xec
github.com/zmap/zgrab2.RunScanner(0xda9600, 0xc42000e528, 0xc420366d20, 0xc420368320, 0x10, 0x10, 0x0, 0x0, 0xa4a144, 0x3, ...)
	/root/go/src/github.com/zmap/zgrab2/scanner.go:32 +0xcc
github.com/zmap/zgrab2.grabTarget(0xc420368320, 0x10, 0x10, 0x0, 0x0, 0xc420366d20, 0x0, 0x0, 0x0)
	/root/go/src/github.com/zmap/zgrab2/processing.go:91 +0x245
github.com/zmap/zgrab2.Process.func2(0xc420057b00, 0xc420366d20, 0xc420057b60, 0xc4203682e0, 0x374)
        /root/go/src/github.com/zmap/zgrab2/processing.go:150 +0x143
created by github.com/zmap/zgrab2.Process
	/root/go/src/github.com/zmap/zgrab2/processing.go:143 +0x191

output file xxxx.json is empty
with zgrab instead

echo IP_WITH_443_OPEN_PORT_BUT_NO_HTTPS | /opt/scanner/sbin/zgrab --port 443 --tls --heartbleed --output-file=xxxxx.json
Mar 26 09:39:50.173 [INFO] banner-grab: started grab at 2018-03-26T09:39:50+02:00
Mar 26 09:39:52.851 [ERROR] banner-grab: Conversation error with remote host 2.238.76.236:443: tls: oversized record received with length 20527
Mar 26 09:39:54.607 [INFO] banner-grab: finished grab (0 success; 1 failure) at 2018-03-26T09:39:54+02:00

output file xxxxx.json

cat xxxxx.json 
{"ip":"IP_WITH_443_OPEN_PORT_BUT_NO_HTTPS","timestamp":"2018-03-26T09:39:52+02:00","data":{"tls":{}},"error":"tls: oversized record received with length 20527","error_component":"tls"}

I have used golang 1.10 for tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.