Commit Graph

49 Commits

Author SHA1 Message Date
Paul A. Parkanzky
7386c5d3fa Fix script #! invocations 2018-08-21 13:33:56 -04:00
Paul A. Parkanzky
2f316b2242 Add mongodb integration tests. 2018-08-21 13:11:34 -04:00
Clayton Zimmerman
c11be290dc
Feature/IPP: Fix Retry-TLS and Collect All IPP Attributes (#143)
* Correctly enables TLS only during retry grab when retry-tls flag is set.
* Fixes evaluation which caused too many arguments error in IPP integration test.
* Updates IPP zgrab2 schema to reflect storing all attributes in response.
* Adds Attributes member to ScanResults
* Ensures tryReadAttributes only reads attributes in the case of a postive detection. Cleans up isIPP
* Reads all attributes in IPP response
* Detects invalid length errors when reading IPP attributes.
* Returns the correct amount of uris, ipp versions, and cups versions in ScanResults.
2018-07-09 14:39:54 -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
Alex Halderman
0c597e5a8d
Merge branch 'master' into ah/trigger 2018-06-26 17:53:20 -07:00
J. Alex Halderman
9df97e03cf Add support for tags and triggers. 2018-06-26 13:51:10 -04:00
Clayton Zimmerman
9b00db7f29
Feature/create ipp module (#137)
* Changes grab to return *ScanResults. Implements ippInContentType correctly.

* Slots in an operational re-working of several HTTP module functions, and adds dependency on zgrab's http module. Includes some laregly copy-pasted sections worthy of scrutiny.

* Adds support to retry failed HTTP over HTTPS. Removes vestigial functions.

* Implements sending CUPS-get-printers request if CUPS is detected, yielding more detailed & accurate version information. Also handles URI's more correctly.

* Creates separate container to run IPP over TLS on CUPS. Runs basic tests against both containers.

* Creates virtual printer on each container to test for augmenting data with CUPS-get-printers request (which only works when printers exist).

* Augments version information with CUPS-get-printers response if possible.

* Allows specifying IPP version in constructed requests. Checks for version-not-supported server error.

* Allows resending IPP requests with different versions if we hit a version-not-supported error.

* Updates IPP zgrab2 schema to include fields added in modules/ipp/scanner.go

* Removes unnecessary TODO's

* Updates testable example for new definition of AttributeByteString

* Removes versionNotSupported's dependency on bufferFromBody. Checks bounds on generated requests' fields correctly.

* Updates zgrab2 IPP schema to match ScanResults object in modules/ipp/scanner.go

* Corrects IPP tests, bounds checking, zgrab schema formatting.

* Logs errors for unexpected behavior in buffer io operations. Updates schema to include standalone fields for attributes described in CUPS-get-printers response.

* Logs at debug level only when verbose flag is set. Prints accurate error message when CUPSVersion test fails.

* Handles HTTP request errors before checking for nil response/body. Fixes and tests convertURIToIPP.
2018-06-26 12:00:27 -04:00
linus torvalds
baa8744ae5 compatible new.sh with OSX 2018-06-22 11:28:45 +08:00
Clayton Zimmerman
2afd7d8a2d Addresses comments from pull request #135. Makes ipp Dockerfile conform to best practices. Makes reference to IPP RFC where appropriate. 2018-06-12 17:00:52 -04:00
Clayton Zimmerman
e46f988d28 Configures docker container to run scanner correctly. 2018-06-11 16:52:26 -04:00
Clayton Zimmerman
84100ce1b8 Makes necessary initial changes so Dockerfile and testing scripts install and run cups. 2018-06-11 11:53:07 -04:00
Clayton Zimmerman
b076c7b005 Boilerplate for IPP scan module. 2018-06-07 15:13:01 -04:00
Justin Bastress
2b8f04234e Fix new.sh, add sample container setup; add apt-update target for zgrab2_service_base 2018-05-30 12:07:24 -04:00
Justin Bastress
24dad0b670 handle module rename 2018-05-04 11:31:53 -04:00
Justin Bastress
a472e0b560 updates schema template to match current layout 2018-04-23 16:41:34 -04:00
Justin Bastress
735cb3a4c3 port DNP3 scanner 2018-03-21 16:52:53 -04:00
Justin Bastress
0f7a265bdd add modbus scanner 2018-03-21 10:36:58 -04:00
Justin Bastress
0fbf68b9e9 fix input flags 2018-03-15 13:25:53 -04:00
Justin Bastress
8dd7a62768 remove port forwarding from pop3 container 2018-03-15 13:17:52 -04:00
Justin Bastress
f1c9bfbc89 merge master 2018-03-15 13:12:21 -04:00
Justin Bastress
ad6295f421 port POP3 2018-03-15 13:10:10 -04:00
Justin Bastress
57bc835bcf Add integration tests; Post PR comment updates: stray further from original ZGrab input/output in favor of more zgrab2-like input/output; make QUIT optional (default off). 2018-03-15 11:07:18 -04:00
Justin Bastress
b52d4c47bc chmod +x shell scripts 2018-03-14 09:20:03 -04:00
Justin Bastress
fa6a7ce50c port telnet module from zgrab; add basic integration tests and schema 2018-03-13 15:23:57 -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
9a8080e543 Fix typo in scanner template (#63)
'module that proves for (target)' to 'modules that scans for (target)'

https://github.com/zmap/zgrab2/pull/63
2018-02-27 14:59:24 -05:00
justinbastress
f02bd59f8a Add redis zgrab2 module (#53) 2018-02-13 13:25:47 -05:00
justinbastress
bd952d9809
golint and godocs for mysql module (#56) 2018-02-12 10:42:45 -05:00
justinbastress
2766a7ae08
Port http from zgrab (#31) 2018-02-09 13:45:50 -05:00
justinbastress
2f7dfd76fe
Add NTP zgrab2 module (#39) 2018-02-07 12:25:46 -05:00
justinbastress
8eb958e22c
Add MSSQL zgrab2 module (#38) 2018-02-02 14:52:03 -05:00
justinbastress
a8b4461d29
Merge #45 into master (#52)
Remove integration-test-setup (no longer needed)
2018-01-31 13:01:14 -05:00
Zakir Durumeric
f47026adb3
Merge pull request #44 from zmap/feature/updateIntegrationTestScriptTemplates
Update integration test script templates
2018-01-31 11:05:34 -05:00
Justin Bastress
e6739acff9 fix service test scripts -- remove useless i flags to docker run; if container is already running, use it; smarter wait conditions for postgres and mysql 2018-01-29 16:53:50 -05:00
Justin Bastress
c5747b7198 sandwich each module's test.sh with its setup.sh and cleanup.sh; fix some relative paths in test.sh 2018-01-29 16:48:57 -05:00
Justin Bastress
59aa3d8571 Update README; fix output file in test 2018-01-29 16:36:45 -05:00
Justin Bastress
da294f7f1e Add .templates folder in lieu of inline scripts; update templates to match more common scenarios 2018-01-29 16:03:32 -05:00
justinbastress
a1fca68c04
Port FTP module from zgrab (#32)
* remove unnecessary indirection on net.Conn

* Ignore *.pyc

* fix NPE on nil handshake

* refactoring -- move status to status.go; add Open() methods for ScanTarget

* cherry-pick .gitignore fix

* pull in TLS fix

* status.go comments

* trim over-generalizations

* use /usr/bin/env bash instead of absolute path

* remove debug tcpwrap

* add integration tests for postgres

* hack for cleanup.sh to work on mingw -- use //var/lib instead of /var/lib

* cleanup should actually stop the process though

* comments / rearrange

* Bump up timeout in postgres tests; only pass user if explicitly requested to do so

* add schema stubs to new.sh

* Integration test fixes -- use /usr/bin/env bash; log all validation failures

* add postgres schemas

* fill out zcrypto.client_hello schema

* handle early get of TLSLog

* postgres: return SCAN_SUCCESS on success

* cleanup

* fix new.sh

* fix typo

* postgres container cleanup

* build.sh docs

* standardize container/image names

* add not to check for success

* shift mysql's connection management to ScanTarget.Open(); wrap Read/Write methods returned by ScanTarget.Open() to enforce timeouts

* catch schematically-valid but non-successful scans

* postgres: clean up output format; more scanning

* cleanup; better error handling; get detailed protocol version error

* refactor modules

* clean up dangling connections

* split gigantic postgres.go

* remove unused

* ServerParams gets its own type

* refactor integration tests: run zgrab2 in its own container, which is linked to the service containers, so that we don't need to keep track of unique ports on the host any more

* rename entrypoint; remove duplicate postgres tests

* comments for postgres schema

* port over ftp support from the original zgrab; add schema / integration tests for FTP; fix log line in ssh test

* Use param expansion to check for env variable [minor]

This is a *very* minor change to `docker-runner/docker-run.sh` checks to
see if the environment variable required to run the script has been set
to a non-empty string. If not, the script exits with a non-zero status
code and displays a default message:

```
❯ docker-runner/docker-run.sh
docker-runner/docker-run.sh: line 7: CONTAINER_NAME: parameter null or not set
```

This was the behavior before, but just uses a one-liner declarative bash
idiom.

For further reading on parameter expansion, see
https://stackoverflow.com/a/307735.

@justinbastress can tell me if I did something wrong and broke the
intent of the script :-)

* Add integration_test targets to makefile; use makefile instead of directly calling go build everywhere; run postgres schema through PEP8 linter

* use make in docker-runner entrypoint

* add .integration_test_setup to .gitignore

* cleanup

* add ftp schema

* more .gitignore items

* Makefile updates: Windows support; add docker-runner target; better cleanup.

* docker-runner Dockerfile: start from zgrab2_runner_base image

* cleanup postgres setup

* make travis use make

* add .gitattributes, try to prevent it from overriding lfs with crlfs in shell scripts at least

* fix folder name in Makefile

* update go (one of our dependencies now works only with >= 1.9)

* From travis: `I don't have any idea what to do with '1.9.0'.`

* explicit clean make

* fix dep order

* fix build.sh location

* popd

* use make to ensure zgrab2_runner exists

* Make docker-runner an order-dependency for integration-test-cleanup; don't do a cleanup after each integration test

* use explicit tag name for zgrab2_runner

* Add container-clean target to Makefile, to remove cyclic dependency on docker; use .id files to track docker images; add servce-base image; use Make to build / track images

* use LF in Makefiles; update .gitignore; use zgrab_service_base image in ssh container; fix line endings (?)

* remove overzealous cleanup

* let setup continue even if some containers are already running

* ftp: use zgrab2_service_base for ftp container; restart container if already running

* FTP: remove redundant prefix; add non-authtls test

* zgrab depends on *.go

* docker-runner depends on zgrab2 binary

* clean output before running integration tests

* address Zakir's comments: rename auth_*_resp -> auth_*, 'a FTP banner' -> 'an FTP banner'

* fix schema

* update/rebuild when necessary in container
2018-01-18 13:41:51 -05:00
justinbastress
f49887290d
Implements postgres zgrab2 module (#30)
* remove unnecessary indirection on net.Conn

* Ignore *.pyc

* fix NPE on nil handshake

* refactoring -- move status to status.go; add Open() methods for ScanTarget

* cherry-pick .gitignore fix

* pull in TLS fix

* status.go comments

* trim over-generalizations

* use /usr/bin/env bash instead of absolute path

* remove debug tcpwrap

* add integration tests for postgres

* hack for cleanup.sh to work on mingw -- use //var/lib instead of /var/lib

* cleanup should actually stop the process though

* comments / rearrange

* Bump up timeout in postgres tests; only pass user if explicitly requested to do so

* add schema stubs to new.sh

* Integration test fixes -- use /usr/bin/env bash; log all validation failures

* add postgres schemas

* fill out zcrypto.client_hello schema

* handle early get of TLSLog

* postgres: return SCAN_SUCCESS on success

* cleanup

* fix new.sh

* fix typo

* postgres container cleanup

* build.sh docs

* standardize container/image names

* add not to check for success

* shift mysql's connection management to ScanTarget.Open(); wrap Read/Write methods returned by ScanTarget.Open() to enforce timeouts

* catch schematically-valid but non-successful scans

* postgres: clean up output format; more scanning

* cleanup; better error handling; get detailed protocol version error

* refactor modules

* clean up dangling connections

* split gigantic postgres.go

* remove unused

* ServerParams gets its own type

* refactor integration tests: run zgrab2 in its own container, which is linked to the service containers, so that we don't need to keep track of unique ports on the host any more

* rename entrypoint; remove duplicate postgres tests

* comments for postgres schema

* Use param expansion to check for env variable [minor]

This is a *very* minor change to `docker-runner/docker-run.sh` checks to
see if the environment variable required to run the script has been set
to a non-empty string. If not, the script exits with a non-zero status
code and displays a default message:

```
❯ docker-runner/docker-run.sh
docker-runner/docker-run.sh: line 7: CONTAINER_NAME: parameter null or not set
```

This was the behavior before, but just uses a one-liner declarative bash
idiom.

For further reading on parameter expansion, see
https://stackoverflow.com/a/307735.

@justinbastress can tell me if I did something wrong and broke the
intent of the script :-)

* Add integration_test targets to makefile; use makefile instead of directly calling go build everywhere; run postgres schema through PEP8 linter

* use make in docker-runner entrypoint

* add .integration_test_setup to .gitignore

* more .gitignore items

* Makefile updates: Windows support; add docker-runner target; better cleanup.

* docker-runner Dockerfile: start from zgrab2_runner_base image

* cleanup postgres setup

* make travis use make

* add .gitattributes, try to prevent it from overriding lfs with crlfs in shell scripts at least

* fix folder name in Makefile

* update go (one of our dependencies now works only with >= 1.9)

* From travis: `I don't have any idea what to do with '1.9.0'.`

* explicit clean make

* fix dep order

* fix build.sh location

* popd

* use make to ensure zgrab2_runner exists

* Make docker-runner an order-dependency for integration-test-cleanup; don't do a cleanup after each integration test

* use explicit tag name for zgrab2_runner

* Add container-clean target to Makefile, to remove cyclic dependency on docker; use .id files to track docker images; add servce-base image; use Make to build / track images

* use LF in Makefiles; update .gitignore; use zgrab_service_base image in ssh container; fix line endings (?)

* remove overzealous cleanup

* let setup continue even if some containers are already running

* zgrab depends on *.go

* docker-runner depends on zgrab2 binary

* clean output before running integration tests
2018-01-15 14:24:57 -05:00
justinbastress
e0bf14f645
add ssh integration tests (#26)
* add SSH integration tests

* README updates; better sshd container based on a docs.docker.com example
2017-12-19 10:09:43 -05:00
Justin Bastress
81a14b3654 typo fix 2017-12-18 11:44:05 -05:00
Andrew Sardone
f38d85b71c
Add script to generate new-protocol tests [minor]
Just a minor little utility script for generating shell scripts around
the setup/test/cleanup rhythm of the zgrab integration tests.
2017-12-18 00:56:57 -05:00
Andrew Sardone
f45ab312bb
Move all test scripts into integration_tests/ directory
This is just a very minor directory organization change, but it has the
advantage of keeping a bunch of files out of the root directory and
packaging them together since they are related to each other.

Now, our `integration_tests/` directory has a nice pattern of
setup/cleanup/test.sh scripts at the top global level and at each module
level:

```
❯ tree --dirsfirst integration_tests
integration_tests
├── mysql
│   ├── util
│   │   ├── launch_mysql_container.sh
│   │   └── wait_for_mysqld.sh
│   ├── cleanup.sh
│   ├── setup.sh
│   ├── single_run.sh
│   └── test.sh
├── ssh
│   ├── cleanup.sh
│   ├── setup.sh
│   └── test.sh
├── cleanup.sh
├── setup.sh
└── test.sh

3 directories, 12 files
```

The scripts are runnable via:

```
./integration_tests/setup.sh && ./integration_tests/test.sh && ./integration_tests/cleanup.sh
```
2017-12-18 00:44:06 -05:00
Justin Bastress
fcf62fb278 use set +e instead of bash +e 2017-12-15 17:02:42 -05:00
Justin Bastress
b33a5ec60e remove double 'docker stop' 2017-12-15 13:34:41 -05:00
Justin Bastress
a0904d6b30 note non-SSL mysql 2017-12-15 09:57:56 -05:00
Justin Bastress
c5f0a94e70 get unquoted string from jp to simplify comparison 2017-12-15 09:56:15 -05:00
Justin Bastress
e8609a3bfc fix logging for wait_for_mysqld 2017-12-15 09:39:18 -05:00
justinbastress
a244ec15e6 TLS scan prototype + Travis integration (#25)
* Fix typo

* Actually call init per sender for each goroutine

* split out TLS handling

* Rename tls_handshake; update docs

* fix comments

* format fixes

* merge updates

* fix path

* refactor heartbleed logging (now the same as original zgrab)

* add ScanStatus, update modules to return it

* fix threaded for loop; fix styling of dict literal

* fix compile errors, note un-bubbled handshake error

* initial schema commit

* fix comment

* schema cleanup

* comments

* fix TODOs

* first attempt at docker integration in travis; also add schema validation

* add integration_tests.sh

* need sudo?

* try pip install --user

* revert regression

* add docker service again

* chmod +x integration_tests.sh

* fix path of binary

* Dump output file to stdout

* travis work

* use jp's build-self-contained script

* use go get/go build to get jp

* fix jp path

* switch from bogus regex to wildcard

* do all mysql versions; fix version comparison

* re-enable notifications; fix successful version check log message; comment TryGetScanStatus

* move to conf.d layout for integration tests

* update README

* add missing scripts

* add ./ to path
2017-12-15 09:25:17 -05:00