From 554e8f6ae2b9f628cb030014fa8385da2f3939f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Aug 2021 21:03:06 +0000 Subject: [PATCH 01/18] chore(deps): bump golang from 1.16.6-alpine to 1.16.7-alpine Bumps golang from 1.16.6-alpine to 1.16.7-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 184091da..ba659ca6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.16.6-alpine AS build-env +FROM golang:1.16.7-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From efb71356c4d6efd81207ca97828fd8a715192fc4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Aug 2021 21:04:23 +0000 Subject: [PATCH 02/18] chore(deps): bump golang from 1.16.7-alpine to 1.17.0-alpine Bumps golang from 1.16.7-alpine to 1.17.0-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ba659ca6..b7182b0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.16.7-alpine AS build-env +FROM golang:1.17.0-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From 0b854945ed03a2b12d73a48230700410f0d29d0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 21:03:41 +0000 Subject: [PATCH 03/18] chore(deps): bump golang from 1.17.0-alpine to 1.17.1-alpine Bumps golang from 1.17.0-alpine to 1.17.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 b7182b0d..9f7bff7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.0-alpine AS build-env +FROM golang:1.17.1-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From bcc74055e5f9d85f6908258127bc86d3658010d8 Mon Sep 17 00:00:00 2001 From: LuitelSamikshya Date: Wed, 6 Oct 2021 11:10:30 -0500 Subject: [PATCH 04/18] goflags support --- README.md | 29 +++++++++++++++------------- cmd/mapcidr/main.go | 47 ++++++++++++++++++++++++++++++++------------- go.mod | 1 + go.sum | 10 ++++++++++ 4 files changed, 61 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 26f99158..b8363e36 100644 --- a/README.md +++ b/README.md @@ -54,19 +54,22 @@ mapCIDR is developed to ease load distribution for mass scanning operations, it This will display help for the tool. Here are all the switches it supports. -| Flag | Description | Example | -| --------- | --------------------------------------- | --------------------------- | -| aggregate | Aggregate CIDRs into the minimum number | mapcidr -aggregate | -| cidr | Single CIDR to process | mapcidr -cidr 173.0.84.0/24 | -| ips | File containing ips to process | mapcidr -ips ips.txt | -| sbc | Slice by CIDR count | mapcidr -sbc 10 | -| sbh | Slice by HOST count | mapcidr -sbh 10000 | -| l | File containing list of CIDRs | mapcidr -l cidr.txt | -| o | File to write output to (optional) | mapcidr -o output.txt | -| silent | Make the output silent | mapcidr -silent | -| version | Print current version of mapcidr client | mapcidr -version | -| shuffle | Shuffle ip with masscan blackrock cipher | mapcidr -shuffle | -| shuffle-ports | Shuffle ip:port with comma seprated list of ports | mapcidr -shuffle-ports 21,80,443 | +| Flag | Description | Example | +| --------- | --------------------------------------- | --------------------------- | +OUTPUT: | +| o | File to write output to (optional) | mapcidr -o output.txt | +| silent | Make the output silent | mapcidr -silent | +| version | Print current version of mapcidr client | mapcidr -version | +TARGET: | +| cidr | Single CIDR to process | mapcidr -cidr 173.0.84.0/24 | +| l | File containing list of CIDRs | mapcidr -l cidr.txt | +| ips | File containing ips to process | mapcidr -ips ips.txt | +TEMPLATE: | +| sbc | Slice by CIDR count | mapcidr -sbc 10 | +| sbh | Slice by HOST count | mapcidr -sbh 10000 | +| aggregate | Aggregate CIDRs into the minimum number | mapcidr -aggregate | +| shuffle | Shuffle ip with masscan blackrock cipher | mapcidr -shuffle | +| shuffle-ports | Shuffle ip:port with comma seprated list of ports | mapcidr -shuffle-ports 21,80,443 | # Running mapCIDR diff --git a/cmd/mapcidr/main.go b/cmd/mapcidr/main.go index aaf50f56..38e3cce5 100644 --- a/cmd/mapcidr/main.go +++ b/cmd/mapcidr/main.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "flag" "net" "os" "strconv" @@ -10,6 +9,7 @@ import ( "sync" "time" + "github.com/projectdiscovery/goflags" "github.com/projectdiscovery/gologger" "github.com/projectdiscovery/gologger/levels" "github.com/projectdiscovery/ipranger" @@ -56,19 +56,33 @@ func showBanner() { // ParseOptions parses the command line options for application func ParseOptions() *Options { options := &Options{} + flagSet := goflags.NewFlagSet() + flagSet.SetDescription(`mapCIDR is developed to ease load distribution for mass scanning operations, it can be used both as a library and as independent CLI tool.`) + + //output + createGroup(flagSet, "output", "Output", + flagSet.StringVar(&options.Output, "o", "", "File to write output to (optional)"), + flagSet.BoolVar(&options.Silent, "silent", false, "Silent mode"), + flagSet.BoolVar(&options.Version, "version", false, "Show version"), + ) + + //input + createGroup(flagSet, "input", "Target", + flagSet.StringVar(&options.Cidr, "cidr", "", "Single CIDR to process"), + flagSet.StringVar(&options.FileCidr, "l", "", "File containing CIDR"), + flagSet.StringVar(&options.FileIps, "ips", "", "File containing ips to process"), + ) + + //template + createGroup(flagSet, "template", "Template", + flagSet.IntVar(&options.Slices, "sbc", 0, "Slice by CIDR count"), + flagSet.IntVar(&options.HostCount, "sbh", 0, "Slice by HOST count"), + flagSet.BoolVar(&options.Aggregate, "aggregate", false, "Aggregate CIDRs into the minimum number"), + flagSet.BoolVar(&options.Shuffle, "shuffle", false, "Shuffle Ips"), + flagSet.StringVar(&options.ShufflePorts, "shuffle-ports", "", "Shuffle Ips with ports"), + ) - flag.StringVar(&options.FileIps, "ips", "", "File containing ips to process") - flag.BoolVar(&options.Aggregate, "aggregate", false, "Aggregate CIDRs into the minimum number") - flag.IntVar(&options.Slices, "sbc", 0, "Slice by CIDR count") - flag.IntVar(&options.HostCount, "sbh", 0, "Slice by HOST count") - flag.StringVar(&options.Cidr, "cidr", "", "Single CIDR to process") - flag.StringVar(&options.FileCidr, "l", "", "File containing CIDR") - flag.StringVar(&options.Output, "o", "", "File to write output to (optional)") - flag.BoolVar(&options.Silent, "silent", false, "Silent mode") - flag.BoolVar(&options.Shuffle, "shuffle", false, "Shuffle Ips") - flag.StringVar(&options.ShufflePorts, "shuffle-ports", "", "Shuffle Ips with ports") - flag.BoolVar(&options.Version, "version", false, "Show version") - flag.Parse() + _ = flagSet.Parse() // Read the inputs and configure the logging options.configureOutput() @@ -298,3 +312,10 @@ func hasStdin() bool { } return true } + +func createGroup(flagSet *goflags.FlagSet, groupName, description string, flags ...*goflags.FlagData) { + flagSet.SetGroup(groupName, description) + for _, currentFlag := range flags { + currentFlag.Group(groupName) + } +} diff --git a/go.mod b/go.mod index bfec9429..d649f1ee 100644 --- a/go.mod +++ b/go.mod @@ -8,4 +8,5 @@ require ( github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e github.com/projectdiscovery/gologger v1.1.4 github.com/projectdiscovery/ipranger v0.0.2 + github.com/projectdiscovery/goflags v0.0.7 // indirect ) diff --git a/go.sum b/go.sum index ac170bdd..d0f71469 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 h1:ox2F0PSMlrAAiAdknSRMDrAr8mfxPCfSZolH+/qQnyQ= +github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08/go.mod h1:pCxVEbcm3AMg7ejXyorUXi6HQCzOIBf7zEDVPtw0/U4= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -35,10 +37,14 @@ github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e h1:7bwaFH1jvtOo5ndhTQgoA349ozhX+1dc4b6tbaPnBOA= github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e/go.mod h1:/IsapnEYiWG+yEDPXp0e8NWj3npzB9Ccy9lXEUJwMZs= +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/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= @@ -47,6 +53,8 @@ github.com/projectdiscovery/hmap v0.0.1/go.mod h1:VDEfgzkKQdq7iGTKz8Ooul0NuYHQ8q github.com/projectdiscovery/ipranger v0.0.2 h1:5GcKu+4QWNzD38IJZc3mFBrqboDix6cfJkcn2RsJFGM= github.com/projectdiscovery/ipranger v0.0.2/go.mod h1:kcAIk/lo5rW+IzUrFkeYyXnFJ+dKwYooEOHGVPP/RWE= github.com/projectdiscovery/mapcidr v0.0.4/go.mod h1:ALOIj6ptkWujNoX8RdQwB2mZ+kAmKuLJBq9T5gR5wG0= +github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe h1:tQTgf5XLBgZbkJDPtnV3SfdP9tzz5ZWeDBwv8WhnH9Q= +github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -75,6 +83,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From c8d35117c509208bcf5026c93b39e0810eb6a25c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Oct 2021 21:03:07 +0000 Subject: [PATCH 05/18] chore(deps): bump golang from 1.17.1-alpine to 1.17.2-alpine Bumps golang from 1.17.1-alpine to 1.17.2-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 9f7bff7c..d88b1a33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.1-alpine AS build-env +FROM golang:1.17.2-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From d0efc0df31d1f9d25d542f617d748b3cfe57a9c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Nov 2021 21:05:51 +0000 Subject: [PATCH 06/18] chore(deps): bump golang from 1.17.2-alpine to 1.17.3-alpine Bumps golang from 1.17.2-alpine to 1.17.3-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 d88b1a33..288262a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.2-alpine AS build-env +FROM golang:1.17.3-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From d6a542fd80b276a5417cb6453139ed3035a1423c Mon Sep 17 00:00:00 2001 From: mzack Date: Tue, 30 Nov 2021 09:31:46 +0100 Subject: [PATCH 07/18] Fixing version number --- cmd/mapcidr/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/mapcidr/main.go b/cmd/mapcidr/main.go index 38e3cce5..79631509 100644 --- a/cmd/mapcidr/main.go +++ b/cmd/mapcidr/main.go @@ -42,7 +42,7 @@ const banner = ` ` // Version is the current version of mapcidr -const Version = `v0.0.7` +const Version = `v0.0.8` // showBanner is used to show the banner to the user func showBanner() { From 6742ce5cff2a1400df394596b227bbceef78bb55 Mon Sep 17 00:00:00 2001 From: mzack Date: Tue, 30 Nov 2021 09:49:40 +0100 Subject: [PATCH 08/18] Adding flags to skip base and broadcast ips --- cmd/mapcidr/main.go | 33 ++++++++++++++++++++++----------- go.mod | 2 +- go.sum | 1 - utils.go | 15 ++++++++++++++- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/cmd/mapcidr/main.go b/cmd/mapcidr/main.go index 38e3cce5..c985516c 100644 --- a/cmd/mapcidr/main.go +++ b/cmd/mapcidr/main.go @@ -18,17 +18,19 @@ import ( // Options contains cli options type Options struct { - FileIps string - Slices int - HostCount int - Cidr string - FileCidr string - Silent bool - Version bool - Output string - Aggregate bool - Shuffle bool - ShufflePorts string + FileIps string + Slices int + HostCount int + Cidr string + FileCidr string + Silent bool + Version bool + Output string + Aggregate bool + Shuffle bool + ShufflePorts string + SkipBaseIP bool + SkipBroadcastIP bool // NoColor bool // Verbose bool } @@ -64,6 +66,8 @@ func ParseOptions() *Options { flagSet.StringVar(&options.Output, "o", "", "File to write output to (optional)"), flagSet.BoolVar(&options.Silent, "silent", false, "Silent mode"), flagSet.BoolVar(&options.Version, "version", false, "Show version"), + flagSet.BoolVar(&options.SkipBaseIP, "skip-base", false, "Skip base ips (ending in .0)"), + flagSet.BoolVar(&options.SkipBroadcastIP, "skip-broadcast", false, "Skip broadcast ips (ending in .255)"), ) //input @@ -295,6 +299,13 @@ func output(wg *sync.WaitGroup, outputchan chan string) { if o == "" { continue } + if options.SkipBaseIP && mapcidr.IsBaseIP(o) { + continue + } + if options.SkipBroadcastIP && mapcidr.IsBroadcastIP(o) { + continue + } + gologger.Silent().Msgf("%s\n", o) if f != nil { _, _ = f.WriteString(o + "\n") diff --git a/go.mod b/go.mod index d649f1ee..40dfa9e5 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/golang/snappy v0.0.3 // indirect github.com/json-iterator/go v1.1.11 // indirect github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e + github.com/projectdiscovery/goflags v0.0.7 github.com/projectdiscovery/gologger v1.1.4 github.com/projectdiscovery/ipranger v0.0.2 - github.com/projectdiscovery/goflags v0.0.7 // indirect ) diff --git a/go.sum b/go.sum index d0f71469..17bc3c7c 100644 --- a/go.sum +++ b/go.sum @@ -81,7 +81,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/utils.go b/utils.go index 875c9b03..e9e52142 100644 --- a/utils.go +++ b/utils.go @@ -1,6 +1,9 @@ package mapcidr -import "net" +import ( + "net" + "strings" +) // inc increments an IP address to the next IP in the subnet func inc(ip net.IP) net.IP { @@ -48,3 +51,13 @@ func AsIPV4CIDR(ipv4 string) *net.IPNet { } return network } + +func IsBaseIP(IP string) bool { + ipParsed := net.ParseIP(IP) + return ipParsed != nil && ipParsed.To4() != nil && strings.HasSuffix(IP, ".0") +} + +func IsBroadcastIP(IP string) bool { + ipParsed := net.ParseIP(IP) + return ipParsed != nil && ipParsed.To4() != nil && strings.HasSuffix(IP, ".255") +} From f1d88b1490f7c398fb6c00e6285b34361c7d7534 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Dec 2021 21:03:39 +0000 Subject: [PATCH 09/18] chore(deps): bump golang from 1.17.3-alpine to 1.17.4-alpine Bumps golang from 1.17.3-alpine to 1.17.4-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 288262a3..86a476d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.3-alpine AS build-env +FROM golang:1.17.4-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From 91d00d62060480befe69cd7a2f05dc775c2c31b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Dec 2021 21:04:48 +0000 Subject: [PATCH 10/18] chore(deps): bump golang from 1.17.4-alpine to 1.17.5-alpine Bumps golang from 1.17.4-alpine to 1.17.5-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 86a476d6..db0b74e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.4-alpine AS build-env +FROM golang:1.17.5-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From e6cd1585ef8b0a7c11ed9eaada6be46a04514dc0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jan 2022 21:03:45 +0000 Subject: [PATCH 11/18] chore(deps): bump golang from 1.17.5-alpine to 1.17.6-alpine Bumps golang from 1.17.5-alpine to 1.17.6-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 db0b74e2..bdf583d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.5-alpine AS build-env +FROM golang:1.17.6-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From 725cf0106cd36092249cb80a500405af3bec10c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Feb 2022 21:03:19 +0000 Subject: [PATCH 12/18] chore(deps): bump golang from 1.17.6-alpine to 1.17.7-alpine Bumps golang from 1.17.6-alpine to 1.17.7-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 bdf583d4..8fede402 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.6-alpine AS build-env +FROM golang:1.17.7-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From 2aeee4b7482f73c50150ea572ab4e50527812591 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Feb 2022 21:04:24 +0000 Subject: [PATCH 13/18] chore(deps): bump golangci/golangci-lint-action from 2 to 3.1.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 2 to 3.1.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v2...v3.1.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/lint-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 794d0739..5fbc57f7 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Run golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3.1.0 with: version: latest args: --timeout 5m From 5eeb3d9eda3a6415d3591e1fdda9a4f739fc3627 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 21:04:32 +0000 Subject: [PATCH 14/18] chore(deps): bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-test.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/dockerhub-push.yml | 2 +- .github/workflows/lint-test.yml | 2 +- .github/workflows/release-binary.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 64b428fe..5e8f688b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -16,7 +16,7 @@ jobs: go-version: 1.15 - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Test run: go test . diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 545cdea9..601d89a1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index ed5638d3..678eb5f9 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v1 diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 5fbc57f7..1531c6b8 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run golangci-lint uses: golangci/golangci-lint-action@v3.1.0 with: diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 6fe8c828..8025dd81 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -11,7 +11,7 @@ jobs: steps: - name: "Check out code" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - From e12547c55fd56c1a733205a9d66d67d2314e7a1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 21:04:05 +0000 Subject: [PATCH 15/18] chore(deps): bump golang from 1.17.7-alpine to 1.18.0-alpine Bumps golang from 1.17.7-alpine to 1.18.0-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8fede402..0fc1695c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17.7-alpine AS build-env +FROM golang:1.18.0-alpine AS build-env RUN GO111MODULE=on go get -v github.com/projectdiscovery/mapcidr/cmd/mapcidr FROM alpine:latest From 723559303f62936a6c8038655ec9955655483ed7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 21:04:10 +0000 Subject: [PATCH 16/18] 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/release-binary.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 5e8f688b..ef745e10 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.15 diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 8025dd81..1f0bc5c5 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -16,7 +16,7 @@ jobs: fetch-depth: 0 - name: "Set up Go" - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: 1.16 - From 7fe27ceaff74cac97a149e35d41a68493aa5c2e6 Mon Sep 17 00:00:00 2001 From: sandeep Date: Sun, 24 Apr 2022 02:55:46 +0530 Subject: [PATCH 17/18] workflow fix + readme update --- .github/workflows/lint-test.yml | 4 ++ README.md | 67 ++++++++++++++++++--------------- cmd/mapcidr/main.go | 42 ++++++++++----------- go.mod | 4 ++ go.sum | 3 ++ 5 files changed, 69 insertions(+), 51 deletions(-) diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 1531c6b8..ae50778c 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -9,6 +9,10 @@ jobs: name: Lint Test runs-on: ubuntu-latest steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 - name: Checkout code uses: actions/checkout@v3 - name: Run golangci-lint diff --git a/README.md b/README.md index 2f711a5f..f2644305 100644 --- a/README.md +++ b/README.md @@ -43,30 +43,37 @@ mapCIDR is developed to ease load distribution for mass scanning operations, it # Installation ```sh -▶ go install -v github.com/projectdiscovery/mapcidr/cmd/mapcidr@latest +go install -v github.com/projectdiscovery/mapcidr/cmd/mapcidr@latest ``` # Usage ```sh -▶ mapcidr -h +mapcidr -h ``` This will display help for the tool. Here are all the switches it supports. -| Flag | Description | Example | -|------------------|----------------------------------------------------|------------------------------------| -| `-aggregate` | Aggregate CIDRs into the minimum number | `mapcidr -aggregate` | -| `-cidr` | Single CIDR to process | `mapcidr -cidr 173.0.84.0/24` | -| `-ips` | File containing ips to process | `mapcidr -ips ips.txt` | -| `-sbc` | Slice by CIDR count | `mapcidr -sbc 10` | -| `-sbh` | Slice by HOST count | `mapcidr -sbh 10000` | -| `-l` | File containing list of CIDRs | `mapcidr -l cidr.txt` | -| `-o` | File to write output to (optional) | `mapcidr -o output.txt` | -| `-silent` | Make the output silent | `mapcidr -silent` | -| `-version` | Print current version of `mapcidr` client | `mapcidr -version` | -| `-shuffle` | Shuffle IP with masscan blackrock cipher | `mapcidr -shuffle` | -| `-shuffle-ports` | Shuffle IP:port with comma separated list of ports | `mapcidr -shuffle-ports 21,80,443` | +```yaml +INPUT: + -cidr string CIDR to process + -l, -list string File containing list of CIDRs to process + -il, -ip-list string File containing list of IPs to process + +PROCESS: + -sbc int Slice CIDRs by given CIDR count + -sbh int Slice CIDRs by given HOST count + -agg, -aggregate Aggregate IPs/CIDRs into the minimum subnet + -sip, -shuffle-ip Shuffle input ip + -sp, -shuffle-port string Shuffle input ip:port + +OUTPUT: + -o, -output string File to write output to + -silent Silent mode + -version Show version + -skip-base Skip base IPs (ending in .0) in output + -skip-broadcast Skip broadcast IPs (ending in .255) in output +``` # Running mapCIDR @@ -74,11 +81,11 @@ In order to get list of IPs for a give CIDR, use the following command. ### CIDR expansion -```sh -▶ mapcidr -cidr 173.0.84.0/24 +```console +mapcidr -cidr 173.0.84.0/24 ``` -```sh +```console ____________ ___ __ _ ___ ____ / ___/ _/ _ \/ _ \ / ' \/ _ '/ _ \/ /___/ // // / , _/ @@ -107,11 +114,11 @@ In order to get list of IPs for a give CIDR, use the following command. In order to slice given CIDR or list of CIDR by CIDR count or slice into multiple and equal smaller subnets, use the following command. -```sh -▶ mapcidr -cidr 173.0.84.0/24 -sbc 10 -silent +```console +mapcidr -cidr 173.0.84.0/24 -sbc 10 -silent ``` -``` +```console 173.0.84.0/27 173.0.84.32/27 173.0.84.64/27 @@ -128,11 +135,11 @@ In order to slice given CIDR or list of CIDR by CIDR count or slice into multipl In order to slice given CIDR for equal number of host count in each CIDR, use the following command. -```sh -▶ mapcidr -cidr 173.0.84.0/16 -sbh 20000 -silent +```console +mapcidr -cidr 173.0.84.0/16 -sbh 20000 -silent ``` -``` +```console 173.0.0.0/18 173.0.64.0/18 173.0.128.0/18 @@ -145,22 +152,22 @@ Note: it's possible to obtain a perfect split only when the desired amount of sl In order to merge multiple CIDR ranges into smaller subnet block, use the following command. -```sh -▶ mapcidr -l cidrs.txt -silent -aggregate +```console +mapcidr -l cidrs.txt -silent -aggregate ``` In order to list CIDR blocks for given list of IPs, use the following command. -```sh -▶ mapcidr -l ips.txt -silent -aggregate +```console +mapcidr -l ips.txt -silent -aggregate ``` ### CIDR based IP filtering In order to filter IPs from the given list of CIDR ranges, use the following command. -```sh -▶ mapcidr -ips ip-list.txt -l cirds.txt +```console +mapcidr -ips ip-list.txt -l cirds.txt ``` # Use mapCIDR as a library diff --git a/cmd/mapcidr/main.go b/cmd/mapcidr/main.go index d23e2700..3b57089f 100644 --- a/cmd/mapcidr/main.go +++ b/cmd/mapcidr/main.go @@ -39,12 +39,12 @@ const banner = ` ____________ ___ __ _ ___ ____ / ___/ _/ _ \/ _ \ / ' \/ _ '/ _ \/ /___/ // // / , _/ -/_/_/_/\_,_/ .__/\___/___/____/_/|_| v0.0.8 +/_/_/_/\_,_/ .__/\___/___/____/_/|_| v0.0.9 /_/ ` // Version is the current version of mapcidr -const Version = `v0.0.8` +const Version = `v0.0.9` // showBanner is used to show the banner to the user func showBanner() { @@ -61,29 +61,29 @@ func ParseOptions() *Options { flagSet := goflags.NewFlagSet() flagSet.SetDescription(`mapCIDR is developed to ease load distribution for mass scanning operations, it can be used both as a library and as independent CLI tool.`) - //output - createGroup(flagSet, "output", "Output", - flagSet.StringVar(&options.Output, "o", "", "File to write output to (optional)"), - flagSet.BoolVar(&options.Silent, "silent", false, "Silent mode"), - flagSet.BoolVar(&options.Version, "version", false, "Show version"), - flagSet.BoolVar(&options.SkipBaseIP, "skip-base", false, "Skip base ips (ending in .0)"), - flagSet.BoolVar(&options.SkipBroadcastIP, "skip-broadcast", false, "Skip broadcast ips (ending in .255)"), + //input + createGroup(flagSet, "input", "Input", + flagSet.StringVar(&options.Cidr, "cidr", "", "CIDR to process"), + flagSet.StringVarP(&options.FileCidr, "list", "l", "", "File containing list of CIDRs to process"), + flagSet.StringVarP(&options.FileIps, "ip-list", "il", "", "File containing list of IPs to process"), ) - //input - createGroup(flagSet, "input", "Target", - flagSet.StringVar(&options.Cidr, "cidr", "", "Single CIDR to process"), - flagSet.StringVar(&options.FileCidr, "l", "", "File containing CIDR"), - flagSet.StringVar(&options.FileIps, "ips", "", "File containing ips to process"), + //Process + createGroup(flagSet, "process", "Process", + flagSet.IntVar(&options.Slices, "sbc", 0, "Slice CIDRs by given CIDR count"), + flagSet.IntVar(&options.HostCount, "sbh", 0, "Slice CIDRs by given HOST count"), + flagSet.BoolVarP(&options.Aggregate, "aggregate", "agg", false, "Aggregate IPs/CIDRs into the minimum subnet"), + flagSet.BoolVarP(&options.Shuffle, "shuffle-ip", "sip", false, "Shuffle input ip"), + flagSet.StringVarP(&options.ShufflePorts, "shuffle-port", "sp", "", "Shuffle input ip:port"), ) - //template - createGroup(flagSet, "template", "Template", - flagSet.IntVar(&options.Slices, "sbc", 0, "Slice by CIDR count"), - flagSet.IntVar(&options.HostCount, "sbh", 0, "Slice by HOST count"), - flagSet.BoolVar(&options.Aggregate, "aggregate", false, "Aggregate CIDRs into the minimum number"), - flagSet.BoolVar(&options.Shuffle, "shuffle", false, "Shuffle Ips"), - flagSet.StringVar(&options.ShufflePorts, "shuffle-ports", "", "Shuffle Ips with ports"), + //output + createGroup(flagSet, "output", "Output", + flagSet.StringVarP(&options.Output, "output", "o", "", "File to write output to"), + flagSet.BoolVar(&options.Silent, "silent", false, "Silent mode"), + flagSet.BoolVar(&options.Version, "version", false, "Show version"), + flagSet.BoolVar(&options.SkipBaseIP, "skip-base", false, "Skip base IPs (ending in .0) in output"), + flagSet.BoolVar(&options.SkipBroadcastIP, "skip-broadcast", false, "Skip broadcast IPs (ending in .255) in output"), ) _ = flagSet.Parse() diff --git a/go.mod b/go.mod index b875ed3b..f537ed46 100644 --- a/go.mod +++ b/go.mod @@ -10,12 +10,16 @@ require ( ) require ( + github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect github.com/golang/snappy v0.0.3 // indirect github.com/json-iterator/go v1.1.11 // indirect github.com/logrusorgru/aurora v2.0.3+incompatible // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/projectdiscovery/hmap v0.0.1 // indirect + github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe // indirect github.com/syndtr/goleveldb v1.0.0 // indirect github.com/yl2chen/cidranger v1.0.2 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index b19f3fcc..7f39636a 100644 --- a/go.sum +++ b/go.sum @@ -15,9 +15,11 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= @@ -69,6 +71,7 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= From 5bc1bbb6fc04d0e7d8758517c87c82b65670c3e8 Mon Sep 17 00:00:00 2001 From: sandeep Date: Sun, 24 Apr 2022 02:58:29 +0530 Subject: [PATCH 18/18] docker workflow update --- .github/workflows/dockerhub-push.yml | 31 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index 678eb5f9..9ba4e7c0 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -1,34 +1,39 @@ name: 🌥 Docker Push on: - release: - types: [published] + workflow_run: + workflows: ["🎉 Release Binary"] + types: + - completed workflow_dispatch: jobs: docker: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 - - - name: Set up QEMU + + - name: Get Github tag + id: meta + run: | + echo "::set-output name=tag::$(curl --silent "https://api.github.com/repos/projectdiscovery/mapcidr/releases/latest" | jq -r .tag_name)" + - name: Set up QEMU uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx + + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub + + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - - - name: Build and push + + - name: Build and push uses: docker/build-push-action@v2 with: context: . platforms: linux/amd64,linux/arm64,linux/arm push: true - tags: projectdiscovery/mapcidr:latest \ No newline at end of file + tags: projectdiscovery/mapcidr:latest,projectdiscovery/mapcidr:${{ steps.meta.outputs.tag }} \ No newline at end of file