From 517f357311dc9f0f4123583daaba4ca940237730 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Mar 2022 11:12:17 +0000 Subject: [PATCH 01/23] chore(deps): bump github.com/stretchr/testify from 1.7.0 to 1.7.1 in /v2 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.0 to 1.7.1. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.7.0...v1.7.1) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- v2/go.mod | 2 +- v2/go.sum | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/v2/go.mod b/v2/go.mod index b19b8496..28a942f7 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -26,7 +26,7 @@ require ( require ( github.com/logrusorgru/aurora v2.0.3+incompatible github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.7.1 ) require ( diff --git a/v2/go.sum b/v2/go.sum index 3e8bf9f7..bc689f0b 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -91,11 +91,10 @@ github.com/projectdiscovery/dnsx v1.0.7-0.20210927160546-05f957862698/go.mod h1: github.com/projectdiscovery/fdmax v0.0.3 h1:FM6lv9expZ/rEEBI9tkRh6tx3DV0gtpwzdc0h7bGPqg= github.com/projectdiscovery/fdmax v0.0.3/go.mod h1:NWRcaR7JTO7fC27H4jCl9n7Z+KIredwpgw1fV+4KrKI= github.com/projectdiscovery/fileutil v0.0.0-20210926202739-6050d0acf73c/go.mod h1:U+QCpQnX8o2N2w0VUGyAzjM3yBAe4BKedVElxiImsx0= +github.com/projectdiscovery/fileutil v0.0.0-20210928100737-cab279c5d4b5/go.mod h1:U+QCpQnX8o2N2w0VUGyAzjM3yBAe4BKedVElxiImsx0= github.com/projectdiscovery/fileutil v0.0.0-20220215113056-ba188a0c8abc h1:dbDgsj26PW06L3zMo7AT08IbEqMd2u8QQ1BvlfMAY2w= github.com/projectdiscovery/fileutil v0.0.0-20220215113056-ba188a0c8abc/go.mod h1:Pm0f+MWgDFMSSI9NBedNh48LyYPs8gD3Jd8DXGmp4aQ= github.com/projectdiscovery/goconfig v0.0.0-20210804090219-f893ccd0c69c/go.mod h1:mBv7GRD5n3WNbFE9blG8ynzXTM5eh9MmwaK6EOyn6Pk= -github.com/projectdiscovery/goflags v0.0.7 h1:aykmRkrOgDyRwcvGrK3qp+9aqcjGfAMs/+LtRmtyxwk= -github.com/projectdiscovery/goflags v0.0.7/go.mod h1:Jjwsf4eEBPXDSQI2Y+6fd3dBumJv/J1U0nmpM+hy2YY= github.com/projectdiscovery/goflags v0.0.8-0.20220304165250-2530b305a4a9 h1:J05G/rKDM/MSWI3FrXbnCFM7PtZeV+gRic6wzS8eLqI= github.com/projectdiscovery/goflags v0.0.8-0.20220304165250-2530b305a4a9/go.mod h1:37KhVbVLllyuIAgpXGqcvE/hsFEwJ+ctEUSHawjhsBY= github.com/projectdiscovery/gologger v1.0.1/go.mod h1:Ok+axMqK53bWNwDSU1nTNwITLYMXMdZtRc8/y1c7sWE= @@ -136,8 +135,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/yl2chen/cidranger v1.0.2 h1:lbOWZVCG1tCRX4u24kuM1Tb4nHqWkDxwLdoS+SevawU= From 715177a66ef8aabe071e7eebade3fbb4490fe960 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 13:05:36 +0000 Subject: [PATCH 02/23] chore(deps): bump alpine from 3.15.2 to 3.15.4 Bumps alpine from 3.15.2 to 3.15.4. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6183d082..fe58a19b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.18.0-alpine AS builder RUN apk add build-base libpcap-dev RUN go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest -FROM alpine:3.15.2 +FROM alpine:3.15.4 RUN apk add nmap libpcap-dev bind-tools ca-certificates COPY --from=builder /go/bin/naabu /usr/local/bin/naabu ENTRYPOINT ["naabu"] From 850e5af4fced6406054dacf0575aa508cdb8968b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 13:05:38 +0000 Subject: [PATCH 03/23] chore(deps): bump actions/setup-go from 2 to 3 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-test.yml | 2 +- .github/workflows/functional-test.yml | 2 +- .github/workflows/lint-test.yml | 2 +- .github/workflows/release-binary.yml | 6 +++--- .github/workflows/sonarcloud.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index ffc0e2d3..65113944 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -13,7 +13,7 @@ jobs: os: [ubuntu-latest] # Todo: windows-latest, macOS-latest steps: - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 diff --git a/.github/workflows/functional-test.yml b/.github/workflows/functional-test.yml index 8ecc4b16..515d17d3 100644 --- a/.github/workflows/functional-test.yml +++ b/.github/workflows/functional-test.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 6d975aeb..181a2e25 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index a4082be3..39edef3f 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -14,7 +14,7 @@ jobs: with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 - name: Install Dependences @@ -36,7 +36,7 @@ jobs: with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 - name: Install Dependences @@ -59,7 +59,7 @@ jobs: with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 - name: Run GoReleaser diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7cf9ef0b..87c7da4f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: "Set up Go" - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.17 From e994f6fd657076f7f80bd2018fadb91b146bf484 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 13:04:40 +0000 Subject: [PATCH 04/23] chore(deps): bump golang from 1.18.0-alpine to 1.18.1-alpine Bumps golang from 1.18.0-alpine to 1.18.1-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fe58a19b..27006984 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18.0-alpine AS builder +FROM golang:1.18.1-alpine AS builder RUN apk add build-base libpcap-dev RUN go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest From 96b2550de7b9c65b9adb19a1cf372545f9b73d17 Mon Sep 17 00:00:00 2001 From: forgedhallpass <13679401+forgedhallpass@users.noreply.github.com> Date: Mon, 18 Apr 2022 17:07:10 +0300 Subject: [PATCH 05/23] chore: go version update to 1.18 in GitHub actions --- .github/workflows/build-test.yml | 2 +- .github/workflows/functional-test.yml | 2 +- .github/workflows/lint-test.yml | 2 +- .github/workflows/release-binary.yml | 6 +++--- .github/workflows/sonarcloud.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 65113944..34ea7de1 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Check out code uses: actions/checkout@v3 diff --git a/.github/workflows/functional-test.yml b/.github/workflows/functional-test.yml index 515d17d3..a156ee3d 100644 --- a/.github/workflows/functional-test.yml +++ b/.github/workflows/functional-test.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Check out code uses: actions/checkout@v3 diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 181a2e25..042541f5 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Install Dependences run: sudo apt install libpcap-dev diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 39edef3f..e53314a9 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Install Dependences run: brew install libpcap - name: Run GoReleaser @@ -38,7 +38,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Install Dependences run: sudo apt install libpcap-dev @@ -61,7 +61,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 87c7da4f..29757d83 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -20,7 +20,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Install Dependences run: sudo apt install libpcap-dev From e20447f34dc582d5a109e1b27948b64b0b478685 Mon Sep 17 00:00:00 2001 From: forgedhallpass <13679401+forgedhallpass@users.noreply.github.com> Date: Mon, 18 Apr 2022 17:07:26 +0300 Subject: [PATCH 06/23] documentation: minor fixes in the readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5d4db252..06370823 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- naabu + naabu

@@ -29,7 +29,7 @@ all ports that return a reply. # Features

- naabu + naabu

@@ -249,7 +249,7 @@ Currently `cloudflare`, `akamai`, `incapsula` and `sucuri` IPs are supported for # 📋 Notes - Naabu is designed to scan ports on multiple hosts / mass port scanning. - As default naabu is configured with a assumption that you are running it from VPS. -- We suggest to tune the flags / rate if running naabu from local system. +- We suggest tuning the flags / rate if running naabu from local system. - For best results, run naabu as **root** user. -naabu is made with 🖤 by the [projectdiscovery](https://projectdiscovery.io) team. Community contributions have made the project what it is. See the **[Thanks.md](https://github.com/projectdiscovery/naabu/blob/master/THANKS.md)** file for more details. +`naabu` is made with 🖤 by the [projectdiscovery](https://projectdiscovery.io) team. Community contributions have made the project what it is. See the **[Thanks.md](https://github.com/projectdiscovery/naabu/blob/master/THANKS.md)** file for more details. From fdb9cfa0fca84e9084dffc2d2a8278c6a36cdc1b Mon Sep 17 00:00:00 2001 From: wellencamass <77920409+wellencamass@users.noreply.github.com> Date: Wed, 20 Apr 2022 13:30:11 +0300 Subject: [PATCH 07/23] Update Dockerfile Its not possible to run nmap nse scripts without nmap-scripts package, gives NSE: failed to initialize the script engine: could not locate nse_main.lua --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6183d082..d4dfdbf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ RUN apk add build-base libpcap-dev RUN go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest FROM alpine:3.15.2 -RUN apk add nmap libpcap-dev bind-tools ca-certificates +RUN apk add nmap libpcap-dev bind-tools ca-certificates nmap-scripts COPY --from=builder /go/bin/naabu /usr/local/bin/naabu ENTRYPOINT ["naabu"] From 10aa2378bc2a4dcfc2cdc2bf585f1ef70fae2cd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 13:05:59 +0000 Subject: [PATCH 08/23] chore(deps): bump github/codeql-action from 1 to 2 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v1...v2) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8a61036a..403f537d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -31,12 +31,12 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 \ No newline at end of file + uses: github/codeql-action/analyze@v2 \ No newline at end of file From 33149b0f1869436d1ac13f95826a839cefd00e09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 13:42:56 +0000 Subject: [PATCH 09/23] chore(deps): bump github.com/projectdiscovery/mapcidr in /v2 Bumps [github.com/projectdiscovery/mapcidr](https://github.com/projectdiscovery/mapcidr) from 0.0.8 to 0.0.9. - [Release notes](https://github.com/projectdiscovery/mapcidr/releases) - [Changelog](https://github.com/projectdiscovery/mapcidr/blob/master/.goreleaser.yml) - [Commits](https://github.com/projectdiscovery/mapcidr/compare/v0.0.8...v0.0.9) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/mapcidr dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- v2/go.mod | 2 +- v2/go.sum | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/v2/go.mod b/v2/go.mod index 28a942f7..f3e4a851 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -15,7 +15,7 @@ require ( github.com/projectdiscovery/gologger v1.1.4 github.com/projectdiscovery/ipranger v0.0.3-0.20210831161617-ac80efae0961 github.com/projectdiscovery/iputil v0.0.0-20210804143329-3a30fcde43f3 - github.com/projectdiscovery/mapcidr v0.0.8 + github.com/projectdiscovery/mapcidr v0.0.9 github.com/projectdiscovery/networkpolicy v0.0.1 github.com/remeh/sizedwaitgroup v1.0.0 go.uber.org/ratelimit v0.2.0 diff --git a/v2/go.sum b/v2/go.sum index bc689f0b..7935fa4f 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -95,6 +95,7 @@ github.com/projectdiscovery/fileutil v0.0.0-20210928100737-cab279c5d4b5/go.mod h github.com/projectdiscovery/fileutil v0.0.0-20220215113056-ba188a0c8abc h1:dbDgsj26PW06L3zMo7AT08IbEqMd2u8QQ1BvlfMAY2w= github.com/projectdiscovery/fileutil v0.0.0-20220215113056-ba188a0c8abc/go.mod h1:Pm0f+MWgDFMSSI9NBedNh48LyYPs8gD3Jd8DXGmp4aQ= github.com/projectdiscovery/goconfig v0.0.0-20210804090219-f893ccd0c69c/go.mod h1:mBv7GRD5n3WNbFE9blG8ynzXTM5eh9MmwaK6EOyn6Pk= +github.com/projectdiscovery/goflags v0.0.7/go.mod h1:Jjwsf4eEBPXDSQI2Y+6fd3dBumJv/J1U0nmpM+hy2YY= github.com/projectdiscovery/goflags v0.0.8-0.20220304165250-2530b305a4a9 h1:J05G/rKDM/MSWI3FrXbnCFM7PtZeV+gRic6wzS8eLqI= github.com/projectdiscovery/goflags v0.0.8-0.20220304165250-2530b305a4a9/go.mod h1:37KhVbVLllyuIAgpXGqcvE/hsFEwJ+ctEUSHawjhsBY= github.com/projectdiscovery/gologger v1.0.1/go.mod h1:Ok+axMqK53bWNwDSU1nTNwITLYMXMdZtRc8/y1c7sWE= @@ -111,8 +112,9 @@ github.com/projectdiscovery/iputil v0.0.0-20210804143329-3a30fcde43f3/go.mod h1: github.com/projectdiscovery/mapcidr v0.0.4/go.mod h1:ALOIj6ptkWujNoX8RdQwB2mZ+kAmKuLJBq9T5gR5wG0= github.com/projectdiscovery/mapcidr v0.0.6/go.mod h1:ZEBhMmBU3laUl3g9QGTrzJku1VJOzjdFwW01f/zVVzM= github.com/projectdiscovery/mapcidr v0.0.7/go.mod h1:7CzdUdjuLVI0s33dQ33lWgjg3vPuLFw2rQzZ0RxkT00= -github.com/projectdiscovery/mapcidr v0.0.8 h1:16U05F2x3o/jSTsxSCY2hCuCs9xOSwVxjo2zlsL4L4E= github.com/projectdiscovery/mapcidr v0.0.8/go.mod h1:7CzdUdjuLVI0s33dQ33lWgjg3vPuLFw2rQzZ0RxkT00= +github.com/projectdiscovery/mapcidr v0.0.9 h1:PIa09fMHdghlmkUeTgHP9bwYnb3k2wXXM2f6LMj26zg= +github.com/projectdiscovery/mapcidr v0.0.9/go.mod h1:zgsrc+UXwcLcBopUNboiI4tpTICbfdTyJZiBi2tx+NI= github.com/projectdiscovery/networkpolicy v0.0.0-20210414200240-b3fa8abf324c/go.mod h1:KZIP5x7t+bH2dASgnYaqbiLI4z0gxXzekwUtarrQMdc= github.com/projectdiscovery/networkpolicy v0.0.1 h1:RGRuPlxE8WLFF9tdKSjTsYiTIKHNHW20Kl0nGGiRb1I= github.com/projectdiscovery/networkpolicy v0.0.1/go.mod h1:asvdg5wMy3LPVMGALatebKeOYH5n5fV5RCTv6DbxpIs= From e63a26126d1e00dd2dbaa6c10da5e537a98209fd Mon Sep 17 00:00:00 2001 From: mzack Date: Wed, 27 Apr 2022 17:55:55 +0200 Subject: [PATCH 10/23] Adding support for passive stream scan --- v2/go.mod | 5 +-- v2/go.sum | 10 ++++-- v2/pkg/runner/banners.go | 15 ++++++--- v2/pkg/runner/options.go | 2 ++ v2/pkg/runner/runner.go | 67 +++++++++++++++++++++++++++++++++++++-- v2/pkg/runner/validate.go | 15 +++++---- 6 files changed, 97 insertions(+), 17 deletions(-) diff --git a/v2/go.mod b/v2/go.mod index f3e4a851..d7904465 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -11,7 +11,7 @@ require ( github.com/projectdiscovery/dnsx v1.0.7-0.20210927160546-05f957862698 github.com/projectdiscovery/fdmax v0.0.3 github.com/projectdiscovery/fileutil v0.0.0-20220215113056-ba188a0c8abc - github.com/projectdiscovery/goflags v0.0.8-0.20220304165250-2530b305a4a9 + github.com/projectdiscovery/goflags v0.0.8-0.20220411122653-4f7127a41268 github.com/projectdiscovery/gologger v1.1.4 github.com/projectdiscovery/ipranger v0.0.3-0.20210831161617-ac80efae0961 github.com/projectdiscovery/iputil v0.0.0-20210804143329-3a30fcde43f3 @@ -26,6 +26,8 @@ require ( require ( github.com/logrusorgru/aurora v2.0.3+incompatible github.com/pkg/errors v0.9.1 + github.com/projectdiscovery/retryablehttp-go v1.0.2 + github.com/projectdiscovery/uncover v0.0.5 github.com/stretchr/testify v1.7.1 ) @@ -43,7 +45,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/projectdiscovery/hmap v0.0.1 // indirect github.com/projectdiscovery/retryabledns v1.0.13-0.20210927160332-db15799e2e4d // indirect - github.com/projectdiscovery/retryablehttp-go v1.0.2 // indirect github.com/projectdiscovery/stringsutil v0.0.0-20210830151154-f567170afdd9 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect github.com/yl2chen/cidranger v1.0.2 // indirect diff --git a/v2/go.sum b/v2/go.sum index 7935fa4f..481820e2 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -34,6 +34,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -92,12 +93,14 @@ github.com/projectdiscovery/fdmax v0.0.3 h1:FM6lv9expZ/rEEBI9tkRh6tx3DV0gtpwzdc0 github.com/projectdiscovery/fdmax v0.0.3/go.mod h1:NWRcaR7JTO7fC27H4jCl9n7Z+KIredwpgw1fV+4KrKI= github.com/projectdiscovery/fileutil v0.0.0-20210926202739-6050d0acf73c/go.mod h1:U+QCpQnX8o2N2w0VUGyAzjM3yBAe4BKedVElxiImsx0= github.com/projectdiscovery/fileutil v0.0.0-20210928100737-cab279c5d4b5/go.mod h1:U+QCpQnX8o2N2w0VUGyAzjM3yBAe4BKedVElxiImsx0= +github.com/projectdiscovery/fileutil v0.0.0-20220214145203-ee3ead95c0b9/go.mod h1:Pm0f+MWgDFMSSI9NBedNh48LyYPs8gD3Jd8DXGmp4aQ= github.com/projectdiscovery/fileutil v0.0.0-20220215113056-ba188a0c8abc h1:dbDgsj26PW06L3zMo7AT08IbEqMd2u8QQ1BvlfMAY2w= github.com/projectdiscovery/fileutil v0.0.0-20220215113056-ba188a0c8abc/go.mod h1:Pm0f+MWgDFMSSI9NBedNh48LyYPs8gD3Jd8DXGmp4aQ= +github.com/projectdiscovery/folderutil v0.0.0-20220212074351-38f1c1d2fdd4/go.mod h1:BMqXH4jNGByVdE2iLtKvc/6XStaiZRuCIaKv1vw9PnI= github.com/projectdiscovery/goconfig v0.0.0-20210804090219-f893ccd0c69c/go.mod h1:mBv7GRD5n3WNbFE9blG8ynzXTM5eh9MmwaK6EOyn6Pk= github.com/projectdiscovery/goflags v0.0.7/go.mod h1:Jjwsf4eEBPXDSQI2Y+6fd3dBumJv/J1U0nmpM+hy2YY= -github.com/projectdiscovery/goflags v0.0.8-0.20220304165250-2530b305a4a9 h1:J05G/rKDM/MSWI3FrXbnCFM7PtZeV+gRic6wzS8eLqI= -github.com/projectdiscovery/goflags v0.0.8-0.20220304165250-2530b305a4a9/go.mod h1:37KhVbVLllyuIAgpXGqcvE/hsFEwJ+ctEUSHawjhsBY= +github.com/projectdiscovery/goflags v0.0.8-0.20220411122653-4f7127a41268 h1:Y1lK/BRa58vy/3rsYjGD3+BIo4Z3hw+9eRqCNEOsvXM= +github.com/projectdiscovery/goflags v0.0.8-0.20220411122653-4f7127a41268/go.mod h1:uN+pHMLsWQoiZHUg/l0tqf/VdbX3+ecKfYz/H7b/+NA= github.com/projectdiscovery/gologger v1.0.1/go.mod h1:Ok+axMqK53bWNwDSU1nTNwITLYMXMdZtRc8/y1c7sWE= github.com/projectdiscovery/gologger v1.1.4 h1:qWxGUq7ukHWT849uGPkagPKF3yBPYAsTtMKunQ8O2VI= github.com/projectdiscovery/gologger v1.1.4/go.mod h1:Bhb6Bdx2PV1nMaFLoXNBmHIU85iROS9y1tBuv7T5pMY= @@ -127,6 +130,8 @@ github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe/go.mo github.com/projectdiscovery/stringsutil v0.0.0-20210823090203-2f5f137e8e1d/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I= github.com/projectdiscovery/stringsutil v0.0.0-20210830151154-f567170afdd9 h1:xbL1/7h0k6HE3RzPdYk9W/8pUxESrGWewTaZdIB5Pes= github.com/projectdiscovery/stringsutil v0.0.0-20210830151154-f567170afdd9/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I= +github.com/projectdiscovery/uncover v0.0.5 h1:x6+96/5WwHhZxkWubTnUdNmoGdg/UIO2rwkL9VOxwmk= +github.com/projectdiscovery/uncover v0.0.5/go.mod h1:LF8NewLQXa0mI5H/6ASDy9/4sxghCTAXAhGkhKG1kb8= github.com/remeh/sizedwaitgroup v1.0.0 h1:VNGGFwNo/R5+MJBf6yrsr110p0m4/OX4S3DCy7Kyl5E= github.com/remeh/sizedwaitgroup v1.0.0/go.mod h1:3j2R4OIe/SeS6YDhICBy22RWjJC5eNCJ1V+9+NVNYlo= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= @@ -188,6 +193,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210419170143-37df388d1f33/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210915083310-ed5796bab164 h1:7ZDGnxgHAMw7thfC5bEos0RDAccZKxioiWBhfIe+tvw= golang.org/x/sys v0.0.0-20210915083310-ed5796bab164/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index 356cdfde..dabd843e 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -30,16 +30,23 @@ func showBanner() { // showNetworkCapabilities shows the network capabilities/scan types possible with the running user func showNetworkCapabilities(options *Options) { - accessLevel := "non root" - scanType := "CONNECT" - if privileges.IsPrivileged && options.ScanType == SynScan { + var accessLevel, scanType string + + switch { + case privileges.IsPrivileged && options.ScanType == SynScan: accessLevel = "root" if isLinux() { accessLevel = "CAP_NET_RAW" } - scanType = "SYN" + case options.Passive: + accessLevel = "non root" + scanType = "PASSIVE" + default: + accessLevel = "non root" + scanType = "CONNECT" } + gologger.Info().Msgf("Running %s scan with %s privileges\n", scanType, accessLevel) } diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index 3e07307b..dfa970d3 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -56,6 +56,7 @@ type Options struct { Resume bool ResumeCfg *ResumeCfg Stream bool + Passive bool } // OnResultCallback (hostname, ip, ports) @@ -106,6 +107,7 @@ func ParseOptions() *Options { flagSet.StringVar(&options.Proxy, "proxy", "", "socks5 proxy"), flagSet.BoolVar(&options.Resume, "resume", false, "resume scan using resume.cfg"), flagSet.BoolVar(&options.Stream, "stream", false, "stream mode (disables resume, nmap, verify, retries, shuffling, etc)"), + flagSet.BoolVar(&options.Passive, "passive", false, "Pulls ports from shodan internetdb"), ) flagSet.CreateGroup("optimization", "Optimization", diff --git a/v2/pkg/runner/runner.go b/v2/pkg/runner/runner.go index 237355ce..b2e14bdb 100644 --- a/v2/pkg/runner/runner.go +++ b/v2/pkg/runner/runner.go @@ -3,8 +3,11 @@ package runner import ( "bytes" "encoding/csv" + "encoding/json" "fmt" "net" + "net/http" + "net/url" "os" "path/filepath" "strings" @@ -15,11 +18,14 @@ import ( "github.com/projectdiscovery/blackrock" "github.com/projectdiscovery/clistats" "github.com/projectdiscovery/dnsx/libs/dnsx" + "github.com/projectdiscovery/fileutil" "github.com/projectdiscovery/gologger" "github.com/projectdiscovery/ipranger" "github.com/projectdiscovery/mapcidr" "github.com/projectdiscovery/naabu/v2/pkg/privileges" "github.com/projectdiscovery/naabu/v2/pkg/scan" + "github.com/projectdiscovery/retryablehttp-go" + "github.com/projectdiscovery/uncover/uncover/agent/shodanidb" "github.com/remeh/sizedwaitgroup" "go.uber.org/ratelimit" ) @@ -132,7 +138,8 @@ func (r *Runner) RunEnumeration() error { shouldUseRawPackets := isOSSupported() && privileges.IsPrivileged && r.options.ScanType == SynScan - if r.options.Stream { + switch { + case r.options.Stream && !r.options.Passive: // stream active r.scanner.State = scan.Scan for cidr := range r.streamChannel { if err := r.scanner.IPRanger.Add(cidr.String()); err != nil { @@ -157,7 +164,61 @@ func (r *Runner) RunEnumeration() error { r.wgscan.Wait() r.handleOutput() return nil - } else { + case r.options.Stream && r.options.Passive: // stream passive + // create retryablehttp instance + httpClient := retryablehttp.NewClient(retryablehttp.DefaultOptionsSingle) + r.scanner.State = scan.Scan + for cidr := range r.streamChannel { + if err := r.scanner.IPRanger.Add(cidr.String()); err != nil { + gologger.Warning().Msgf("Couldn't track %s in scan results: %s\n", cidr, err) + } + ipStream, _ := mapcidr.IPAddressesAsStream(cidr.String()) + for ip := range ipStream { + r.wgscan.Add() + go func(ip string) { + defer r.wgscan.Done() + + // obtain ports from shodan idb + shodanURL := fmt.Sprintf(shodanidb.URL, url.QueryEscape(ip)) + request, err := retryablehttp.NewRequest(http.MethodGet, shodanURL, nil) + if err != nil { + gologger.Warning().Msgf("Couldn't create http request for %s: %s\n", ip, err) + return + } + r.limiter.Take() + response, err := httpClient.Do(request) + if err != nil { + gologger.Warning().Msgf("Couldn't retrieve http response for %s: %s\n", ip, err) + return + } + if response.StatusCode != http.StatusOK { + gologger.Warning().Msgf("Couldn't retrieve data for %s, server replied with status code: %d\n", ip, response.StatusCode) + return + } + + // unmarshal the response + data := &shodanidb.ShodanResponse{} + if err := json.NewDecoder(response.Body).Decode(data); err != nil { + gologger.Warning().Msgf("Couldn't unmarshal json data for %s: %s\n", ip, err) + return + } + + for _, port := range data.Ports { + r.scanner.ScanResults.AddPort(ip, port) + } + }(ip) + } + } + r.wgscan.Wait() + + // Validate the hosts if the user has asked for second step validation + if r.options.Verify { + r.ConnectVerification() + } + + r.handleOutput() + return nil + default: // shrinks the ips to the minimum amount of cidr var targets []*net.IPNet r.scanner.IPRanger.Hosts.Scan(func(k, v []byte) error { @@ -407,7 +468,7 @@ func (r *Runner) handleOutput() { // create path if not existing outputFolder := filepath.Dir(output) - if _, statErr := os.Stat(outputFolder); os.IsNotExist(statErr) { + if fileutil.FolderExists(outputFolder) { mkdirErr := os.MkdirAll(outputFolder, 0700) if mkdirErr != nil { gologger.Error().Msgf("Could not create output folder %s: %s\n", outputFolder, mkdirErr) diff --git a/v2/pkg/runner/validate.go b/v2/pkg/runner/validate.go index 14e2ab45..9dba8e13 100644 --- a/v2/pkg/runner/validate.go +++ b/v2/pkg/runner/validate.go @@ -75,21 +75,24 @@ func (options *Options) validateOptions() error { } } + // stream if options.Stream { if options.Resume { - return errors.New("resume not supported in stream mode") + return errors.New("resume not supported in stream active mode") } if options.EnableProgressBar { - return errors.New("stats not supported in stream mode") - } - if options.Verify { - return errors.New("verify not supported in stream mode") + return errors.New("stats not supported in stream active mode") } if options.Nmap { - return errors.New("nmap not supported in stream mode") + return errors.New("nmap not supported in stream active mode") } } + // stream passive + if options.Verify && !options.Passive { + return errors.New("verify not supported in stream active mode") + } + return nil } From c1c50ac105d0be33a1d90d88b0f96e91904babfc Mon Sep 17 00:00:00 2001 From: mzack Date: Wed, 27 Apr 2022 18:12:18 +0200 Subject: [PATCH 11/23] adding stream test cases --- v2/cmd/functional-test/testcases.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/v2/cmd/functional-test/testcases.txt b/v2/cmd/functional-test/testcases.txt index 2c735603..6416c841 100644 --- a/v2/cmd/functional-test/testcases.txt +++ b/v2/cmd/functional-test/testcases.txt @@ -4,4 +4,6 @@ 127.0.0.1 {{binary}} -ep 80 -p 8000 127.0.0.1 {{binary}} -c 25 -p 8000 127.0.0.1 {{binary}} -nmap-cli 'nmap -Pn -sT' -p 8000 -127.0.0.1 {{binary}} -json \ No newline at end of file +127.0.0.1 {{binary}} -json +scanme.nmap.org {{binary}} -stream -passive +scanme.nmap.org {{binary}} -stream -passive -verify \ No newline at end of file From d363a3d96f27f3dd9abe9c57eac8f563a5e4cf7c Mon Sep 17 00:00:00 2001 From: mzack Date: Wed, 27 Apr 2022 18:53:16 +0200 Subject: [PATCH 12/23] adding passive check --- v2/pkg/runner/validate.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/v2/pkg/runner/validate.go b/v2/pkg/runner/validate.go index 9dba8e13..406513d9 100644 --- a/v2/pkg/runner/validate.go +++ b/v2/pkg/runner/validate.go @@ -75,6 +75,11 @@ func (options *Options) validateOptions() error { } } + // passive is available only with stream + if options.Passive && !options.Stream { + return errors.New("passive supported in stream mode only") + } + // stream if options.Stream { if options.Resume { From 726aee3803597c3cfea6342a5e8a6ed1b85b8946 Mon Sep 17 00:00:00 2001 From: mzack Date: Wed, 27 Apr 2022 21:48:13 +0200 Subject: [PATCH 13/23] Adding nmap ips grouping by range --- v2/pkg/runner/nmap.go | 114 +++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 36 deletions(-) diff --git a/v2/pkg/runner/nmap.go b/v2/pkg/runner/nmap.go index 8dbf3cdc..5c1376fa 100644 --- a/v2/pkg/runner/nmap.go +++ b/v2/pkg/runner/nmap.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "os/exec" + "sort" "strings" "github.com/pkg/errors" @@ -15,50 +16,91 @@ func (r *Runner) handleNmap() error { // command from CLI command := r.options.NmapCLI hasCLI := r.options.NmapCLI != "" - // If at least one is defined handle it - if command != "" { - args := strings.Split(command, " ") - var ( - ips []string - ports []string - ) - allports := make(map[int]struct{}) - for ip, p := range r.scanner.ScanResults.IPPorts { - ips = append(ips, ip) - for pp := range p { - allports[pp] = struct{}{} - } + if hasCLI { + type IpPorts struct { + IP string + Ports []int } - for p := range allports { - ports = append(ports, fmt.Sprintf("%d", p)) + var ipsPorts []*IpPorts + // build a list of all targets + for ip, ports := range r.scanner.ScanResults.IPPorts { + var portsList []int + for port := range ports { + portsList = append(portsList, port) + } + ipsPorts = append(ipsPorts, &IpPorts{IP: ip, Ports: portsList}) } - // if we have no open ports we avoid running nmap - if len(ports) == 0 { - errMsg := errors.New("Skipping nmap scan as no open ports were found") - gologger.Info().Msgf(errMsg.Error()) - return errMsg + // sort by number of ports + sort.Slice(ipsPorts, func(i, j int) bool { + return len(ipsPorts[i].Ports) < len(ipsPorts[j].Ports) + }) + + // suggests commands grouping ips in pseudo-exp ranges + // 0 - 100 ports + // 100 - 1000 ports + // 1000 - 10000 ports + // 10000 - 60000 ports + ranges := make(map[int][]*IpPorts) // for better readability + // collect the indexes corresponding to ranges changes + for _, ipPorts := range ipsPorts { + length := len(ipPorts.Ports) + var index int + switch { + case length > 100 && length < 1000: + index = 1 + case length >= 1000 && length < 10000: + index = 2 + case length >= 10000: + index = 3 + default: + index = 0 + } + ranges[index] = append(ranges[index], ipPorts) } - portsStr := strings.Join(ports, ",") - ipsStr := strings.Join(ips, ",") + for _, rang := range ranges { + args := strings.Split(command, " ") + var ( + ips []string + ports []string + ) + allports := make(map[int]struct{}) + for _, ipPorts := range rang { + ips = append(ips, ipPorts.IP) + for _, pp := range ipPorts.Ports { + allports[pp] = struct{}{} + } + } + for p := range allports { + ports = append(ports, fmt.Sprintf("%d", p)) + } + + // if we have no open ports we avoid running nmap + if len(ports) == 0 { + continue + } + + portsStr := strings.Join(ports, ",") + ipsStr := strings.Join(ips, " ") - args = append(args, "-p", portsStr) - args = append(args, ips...) + args = append(args, "-p", portsStr) + args = append(args, ips...) - // if requested via config file or via cli - if r.options.Nmap || hasCLI { - gologger.Info().Msgf("Running nmap command: %s -p %s %s", command, portsStr, ipsStr) - cmd := exec.Command(args[0], args[1:]...) - cmd.Stdout = os.Stdout - err := cmd.Run() - if err != nil { - errMsg := errors.Wrap(err, "Could not run nmap command") - gologger.Error().Msgf(errMsg.Error()) - return errMsg + // if requested via config file or via cli + if r.options.Nmap || hasCLI { + gologger.Info().Msgf("Running nmap command: %s -p %s %s", command, portsStr, ipsStr) + cmd := exec.Command(args[0], args[1:]...) + cmd.Stdout = os.Stdout + err := cmd.Run() + if err != nil { + errMsg := errors.Wrap(err, "Could not run nmap command") + gologger.Error().Msgf(errMsg.Error()) + return errMsg + } + } else { + gologger.Info().Msgf("Suggested nmap command: %s -p %s %s", command, portsStr, ipsStr) } - } else { - gologger.Info().Msgf("Suggested nmap command: %s -p %s %s", command, portsStr, ipsStr) } } From da980c5004419fcbf2231c8fd5a9a2f08a2b473e Mon Sep 17 00:00:00 2001 From: mzack Date: Wed, 27 Apr 2022 22:01:51 +0200 Subject: [PATCH 14/23] making test output more generic --- v2/pkg/runner/output_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/v2/pkg/runner/output_test.go b/v2/pkg/runner/output_test.go index 45f7681a..1531ba6e 100644 --- a/v2/pkg/runner/output_test.go +++ b/v2/pkg/runner/output_test.go @@ -14,7 +14,8 @@ func TestWriteHostOutput(t *testing.T) { var s string buf := bytes.NewBufferString(s) assert.Nil(t, WriteHostOutput(host, ports, buf)) - assert.Equal(t, "127.0.0.1:80\n127.0.0.1:8080\n", buf.String()) + assert.Contains(t, buf.String(), "127.0.0.1:80") + assert.Contains(t, buf.String(), "127.0.0.1:8080") } func TestWriteJSONOutput(t *testing.T) { From c5271247e40b8faca6597c4e0a3b4fb3f7d70f6f Mon Sep 17 00:00:00 2001 From: mzack Date: Thu, 28 Apr 2022 00:22:25 +0200 Subject: [PATCH 15/23] adding multi-port nmap scan --- v2/cmd/functional-test/testcases.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/v2/cmd/functional-test/testcases.txt b/v2/cmd/functional-test/testcases.txt index 2c735603..24a6e336 100644 --- a/v2/cmd/functional-test/testcases.txt +++ b/v2/cmd/functional-test/testcases.txt @@ -4,4 +4,5 @@ 127.0.0.1 {{binary}} -ep 80 -p 8000 127.0.0.1 {{binary}} -c 25 -p 8000 127.0.0.1 {{binary}} -nmap-cli 'nmap -Pn -sT' -p 8000 -127.0.0.1 {{binary}} -json \ No newline at end of file +127.0.0.1 {{binary}} -json +127.0.0.1 {{binary}} -nmap-cli 'nmap -sT' \ No newline at end of file From 2f5cbe34729c00e16dec1bb4434e9e624eab95e2 Mon Sep 17 00:00:00 2001 From: mzack Date: Fri, 6 May 2022 13:58:52 +0200 Subject: [PATCH 16/23] enabling stream if passive flag is provided --- v2/pkg/runner/validate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/v2/pkg/runner/validate.go b/v2/pkg/runner/validate.go index 406513d9..771eab79 100644 --- a/v2/pkg/runner/validate.go +++ b/v2/pkg/runner/validate.go @@ -75,9 +75,9 @@ func (options *Options) validateOptions() error { } } - // passive is available only with stream - if options.Passive && !options.Stream { - return errors.New("passive supported in stream mode only") + // passive mode enables automatically stream + if options.Passive { + options.Stream = true } // stream From fa167225a8e099a5b552915a97d4d95da14af637 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 13:04:13 +0000 Subject: [PATCH 17/23] chore(deps): bump docker/build-push-action from 2 to 3 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2 to 3. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/dockerhub-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index 36e55c96..9bfadc94 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -32,7 +32,7 @@ jobs: password: ${{ secrets.DOCKER_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: . platforms: linux/amd64,linux/arm64,linux/arm From e16145e8f4d07d589f19a96b87205452972e293d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 13:04:15 +0000 Subject: [PATCH 18/23] chore(deps): bump docker/login-action from 1 to 2 Bumps [docker/login-action](https://github.com/docker/login-action) from 1 to 2. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v1...v2) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/dockerhub-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index 36e55c96..20c1cb07 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -26,7 +26,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} From f96e6478cc528ddb0a6b8d3147400fb388fe96af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 13:04:17 +0000 Subject: [PATCH 19/23] chore(deps): bump docker/setup-buildx-action from 1 to 2 Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v1...v2) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/dockerhub-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index 36e55c96..b76fdd92 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -23,7 +23,7 @@ jobs: uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to DockerHub uses: docker/login-action@v1 From 57aaee935c5f4a2a1f7de2f94f7bd21241080512 Mon Sep 17 00:00:00 2001 From: LuitelSamikshya Date: Tue, 10 May 2022 09:39:07 -0500 Subject: [PATCH 20/23] added buffer reset --- v2/pkg/runner/runner.go | 1 + 1 file changed, 1 insertion(+) diff --git a/v2/pkg/runner/runner.go b/v2/pkg/runner/runner.go index b2e14bdb..fa00a734 100644 --- a/v2/pkg/runner/runner.go +++ b/v2/pkg/runner/runner.go @@ -493,6 +493,7 @@ func (r *Runner) handleOutput() { buffer := bytes.Buffer{} writer := csv.NewWriter(&buffer) for _, host := range dt { + buffer.Reset() if host == "ip" { host = hostIP } From 4d7be05dc9ba5f329f51ede6998ac2acf50ea6ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 May 2022 15:02:35 +0000 Subject: [PATCH 21/23] chore(deps): bump docker/setup-qemu-action from 1 to 2 Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 1 to 2. - [Release notes](https://github.com/docker/setup-qemu-action/releases) - [Commits](https://github.com/docker/setup-qemu-action/compare/v1...v2) --- updated-dependencies: - dependency-name: docker/setup-qemu-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/dockerhub-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index b0b25ab6..0388b8a3 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -20,7 +20,7 @@ jobs: echo "::set-output name=tag::$(curl --silent "https://api.github.com/repos/projectdiscovery/naabu/releases/latest" | jq -r .tag_name)" - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 From b1d877d34558f4ff570bd2352a2838884f33e964 Mon Sep 17 00:00:00 2001 From: sandeep Date: Tue, 10 May 2022 21:25:52 +0530 Subject: [PATCH 22/23] banner update --- v2/pkg/runner/banners.go | 4 ++-- v2/pkg/runner/options.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index dabd843e..be923ece 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -13,11 +13,11 @@ const banner = ` __ ___ ___ ___ _/ / __ __ / _ \/ _ \/ _ \/ _ \/ // / -/_//_/\_,_/\_,_/_.__/\_,_/ v2.0.6 +/_//_/\_,_/\_,_/_.__/\_,_/ v2.0.7 ` // Version is the current version of naabu -const Version = `2.0.6` +const Version = `2.0.7` // showBanner is used to show the banner to the user func showBanner() { diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index dfa970d3..41f47ccc 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -107,7 +107,7 @@ func ParseOptions() *Options { flagSet.StringVar(&options.Proxy, "proxy", "", "socks5 proxy"), flagSet.BoolVar(&options.Resume, "resume", false, "resume scan using resume.cfg"), flagSet.BoolVar(&options.Stream, "stream", false, "stream mode (disables resume, nmap, verify, retries, shuffling, etc)"), - flagSet.BoolVar(&options.Passive, "passive", false, "Pulls ports from shodan internetdb"), + flagSet.BoolVar(&options.Passive, "passive", false, "display passive open ports using shodan internetdb api"), ) flagSet.CreateGroup("optimization", "Optimization", From 0598ec4a22b4b298c1eeba1abe23253ca5d5299b Mon Sep 17 00:00:00 2001 From: sandeep Date: Tue, 10 May 2022 21:43:26 +0530 Subject: [PATCH 23/23] readme update --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 06370823..56b2806c 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ all ports that return a reply. - Fast And Simple **SYN/CONNECT** probe based scanning + - Passive Port Enumeration using Shodan [Internetdb API](https://internetdb.shodan.io) - Optimized for ease of use and **lightweight** on resources - **Automatic IP deduplication for port scan** - **NMAP** integration for service discovery @@ -81,11 +82,12 @@ CONFIGURATION: -interface-list, -il list available interfaces and public ip -interface, -i string network Interface to use for port scan -nmap invoke nmap scan on targets (nmap must be installed) - Deprecated - -nmap-cli string nmap command to run on found results (example: -nmap-cli 'nmap -sV') + -nmap-cli string nmap command to run on found results (-nmap-cli 'nmap -sV') -r string list of custom resolver dns resolution (comma separated or from file) -proxy string socks5 proxy -resume resume scan using resume.cfg -stream stream mode (disables resume, nmap, verify, retries, shuffling, etc) + -passive display passive open ports using shodan internetdb api OPTIMIZATION: -retries int number of retries for the port scan (default 3)