diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..a5e72e2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,20 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[Issue] " +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Shuffledns version** +Include the version of shuffledns you are using, `shuffledns -version` + +**Complete command you used to reproduce this** + + +**Screenshots** +Add screenshots of the error for a better context. diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index a86411a..cb8c32f 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -1,21 +1,19 @@ name: 🎉 Release Binary on: - create: + push: + tags: + - '*' workflow_dispatch: jobs: release: runs-on: ubuntu-latest - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - steps: - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 with: go-version: 1.17 - - uses: goreleaser/goreleaser-action@v2 with: args: "release --rm-dist" diff --git a/.goreleaser.yml b/.goreleaser.yml index cb309a2..47a58a3 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,21 +1,34 @@ +before: + hooks: + - go mod tidy + builds: - - binary: shuffledns - main: cmd/shuffledns/main.go - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - 386 - - arm - - arm64 - +- env: + - CGO_ENABLED=0 + goos: + - windows + - linux + - darwin + goarch: + - amd64 + - 386 + - arm64 + + ignore: + - goos: darwin + goarch: '386' + - goos: windows + goarch: 'arm' + - goos: windows + goarch: 'arm64' + + binary: '{{ .ProjectName }}' + main: cmd/shuffledns/main.go + archives: - - id: tgz - format: tar.gz - replacements: - darwin: macOS - format_overrides: - - goos: windows - format: zip \ No newline at end of file +- format: zip + replacements: + darwin: macOS + +checksum: + algorithm: sha256 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 990b338..35e3e4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,8 @@ -FROM golang:1.17-alpine as build +FROM golang:1.17.5-alpine as build-env RUN apk --no-cache add git -RUN go get -u -v github.com/projectdiscovery/shuffledns/cmd/shuffledns; exit 0 -ENV GO111MODULE on -WORKDIR github.com/projectdiscovery/shuffledns/cmd/shuffledns -RUN go install ./... +RUN go install -v github.com/projectdiscovery/shuffledns/cmd/shuffledns@latest -FROM alpine:3.14 +FROM alpine:3.15.0 RUN apk --update --no-cache add ldns \ && apk --no-cache --virtual .deps add ldns-dev \ git \ @@ -19,6 +16,6 @@ RUN apk --update --no-cache add ldns \ && rm -rf /massdns \ && apk del .deps -COPY --from=build /go/bin/shuffledns /usr/bin/shuffledns +COPY --from=build-env /go/bin/shuffledns /usr/bin/shuffledns ENV HOME / -ENTRYPOINT ["/usr/bin/shuffledns"] +ENTRYPOINT ["/usr/bin/shuffledns"] \ No newline at end of file diff --git a/README.md b/README.md index 4b32838..a59ab7c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Based on the work on `massdns` project by [@blechschmidt](https://github.com/ble # Usage ```bash -▶ shuffledns -h +shuffledns -h ``` This will display help for the tool. Here are all the switches it supports. @@ -84,10 +84,10 @@ The tool also needs a list of valid resolvers. The [dnsvalidator](https://github ## Installation Instructions -shuffledns requires `go1.14+` to install successfully. Run the following command to get the repo - +shuffledns requires `go1.17+` to install successfully. Run the following command to get the repo - ```bash -▶ GO111MODULE=on go get -v github.com/projectdiscovery/shuffledns/cmd/shuffledns +go install -v github.com/projectdiscovery/shuffledns/cmd/shuffledns@latest ``` ## Running shuffledns @@ -99,7 +99,7 @@ shuffledns requires `go1.14+` to install successfully. Run the following command To resolve a list of subdomains, you can pass the list of subdomains via the `list` option. ```bash -▶ shuffledns -d example.com -list example-subdomains.txt -r resolvers.txt +shuffledns -d example.com -list example-subdomains.txt -r resolvers.txt ``` This will run the tool against subdomains in `example-subdomains.txt` and returns the results. The tool uses the resolvers specified with `-r` flag to do the resolving. @@ -107,7 +107,7 @@ This will run the tool against subdomains in `example-subdomains.txt` and return You can also pass the list of subdomains at standard input (STDIN). This allows for easy integration in automation pipelines. ```bash -▶ subfinder -d example.com | shuffledns -d example.com -r resolvers.txt +subfinder -d example.com | shuffledns -d example.com -r resolvers.txt ``` This uses the subdomains found passively by `subfinder` and resolves them with shuffledns returning only the unique and valid subdomains. @@ -117,13 +117,13 @@ This uses the subdomains found passively by `subfinder` and resolves them with s shuffledns also supports bruteforce of a target with a given wordlist. You can use the `w` flag to pass a wordlist which will be used to generate permutations that will be resolved using massdns. ```bash -▶ shuffledns -d hackerone.com -w wordlist.txt -r resolvers.txt +shuffledns -d hackerone.com -w wordlist.txt -r resolvers.txt ``` This will run the tool against `hackerone.com` with the wordlist `wordlist.txt`. The domain bruteforce can also be done with standard input as in previous example for resolving the subdomains. ```bash -▶ echo hackerone.com | shuffledns -w wordlist.txt -r resolvers.txt +echo hackerone.com | shuffledns -w wordlist.txt -r resolvers.txt ``` --- diff --git a/cmd/shuffledns/main.go b/cmd/shuffledns/main.go index 3efed2f..e87386b 100644 --- a/cmd/shuffledns/main.go +++ b/cmd/shuffledns/main.go @@ -9,11 +9,11 @@ func main() { // Parse the command line flags and read config files options := runner.ParseOptions() - runner, err := runner.New(options) + massdnsRunner, err := runner.New(options) if err != nil { - gologger.Fatalf("Could not create runner: %s\n", err) + gologger.Fatal().Msgf("Could not create runner: %s\n", err) } - runner.RunEnumeration() - runner.Close() + massdnsRunner.RunEnumeration() + massdnsRunner.Close() } diff --git a/go.mod b/go.mod index ef9b1d4..3ef0c7b 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,25 @@ module github.com/projectdiscovery/shuffledns go 1.17 require ( - github.com/miekg/dns v1.1.29 - github.com/projectdiscovery/gologger v1.0.0 + github.com/Mzack9999/roundrobin v0.0.0-20211019094217-f3f5553da353 + github.com/miekg/dns v1.1.45 + github.com/projectdiscovery/gologger v1.1.4 github.com/remeh/sizedwaitgroup v1.0.0 - github.com/rs/xid v1.2.1 - github.com/stretchr/testify v1.5.1 + github.com/rs/xid v1.3.0 + github.com/stretchr/testify v1.7.0 ) require ( - github.com/davecgh/go-spew v1.1.0 // indirect - github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/json-iterator/go v1.1.10 // 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/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect - golang.org/x/net v0.0.0-20190923162816-aa69164e4478 // indirect + golang.org/x/mod v0.4.2 // indirect + golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 // indirect golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365 // indirect - gopkg.in/yaml.v2 v2.2.2 // indirect + golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index 160de37..ded5b07 100644 --- a/go.sum +++ b/go.sum @@ -1,40 +1,77 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/Mzack9999/roundrobin v0.0.0-20211019094217-f3f5553da353 h1:bT3DmkkW7jy6r4gzAz+VcTuDGf4msFjXonsvzsPxlio= +github.com/Mzack9999/roundrobin v0.0.0-20211019094217-f3f5553da353/go.mod h1:jaPtvFne4154rQDj6lyDdPnvHc9II1X/3uXfJtjGKBQ= +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/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/miekg/dns v1.1.29 h1:xHBEhR+t5RzcFJjBLJlax2daXOrTYtr9z4WdKEfWFzg= -github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= +github.com/json-iterator/go v1.1.10/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 v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= +github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= +github.com/miekg/dns v1.1.45 h1:g5fRIhm9nx7g8osrAvgb16QJfmyMsyOCb+J7LSv+Qzk= +github.com/miekg/dns v1.1.45/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 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/gologger v1.0.0 h1:XAQ8kHeVKXMjY4rLGh7eT5+oHU077BNEvs7X6n+vu1s= -github.com/projectdiscovery/gologger v1.0.0/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= 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.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4= +github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 h1:4CSI6oo7cOjJKajidEljs9h+uP0rRZBPPPhcCbj5mw8= +golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe h1:6fAMxZRR6sl1Uq8U61gxU+kPTs2tR8uOySCbBP7BN/M= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365 h1:6wSTsvPddg9gc/mVEEyk9oOAoxn+bT4Z9q1zx+4RwA4= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 h1:BonxutuHCTL0rBDnZlKjpGIQFTjyUVTexFOdWkB6Fg0= +golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -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/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/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= diff --git a/pkg/massdns/massdns.go b/pkg/massdns/massdns.go index ca7b427..f5e81b7 100644 --- a/pkg/massdns/massdns.go +++ b/pkg/massdns/massdns.go @@ -20,7 +20,7 @@ type Client struct { type Config struct { // Domain is the domain specified for enumeration Domain string - // Retries is the nmber of retries for dns + // Retries is the number of retries for dns Retries int // MassdnsPath is the path to the binary MassdnsPath string @@ -34,12 +34,16 @@ type Config struct { TempDir string // OutputFile is the file to use for massdns output OutputFile string + // Json is format ouput to ndjson format + Json bool // WildcardsThreads is the number of wildcards concurrent threads WildcardsThreads int // MassdnsRaw perform wildcards filtering from an existing massdns output file MassdnsRaw string // StrictWildcard controls whether the wildcard check should be performed on each result StrictWildcard bool + // WildcardOutputFile is the file where the list of wildcards is dumped + WildcardOutputFile string } // excellentResolvers contains some resolvers used in dns verification step diff --git a/pkg/massdns/process.go b/pkg/massdns/process.go index c4dea7c..d753cdf 100644 --- a/pkg/massdns/process.go +++ b/pkg/massdns/process.go @@ -3,11 +3,12 @@ package massdns import ( "bufio" "bytes" + "encoding/json" "errors" "fmt" "os" "os/exec" - "path" + "path/filepath" "strconv" "strings" "time" @@ -41,7 +42,7 @@ func (c *Client) Process() error { defer shstore.Close() // Set the correct target file - massDNSOutput := path.Join(c.config.TempDir, xid.New().String()) + massDNSOutput := filepath.Join(c.config.TempDir, xid.New().String()) if c.config.MassdnsRaw != "" { massDNSOutput = c.config.MassdnsRaw } @@ -49,33 +50,33 @@ func (c *Client) Process() error { // Check if we need to run massdns if c.config.MassdnsRaw == "" { // Create a temporary file for the massdns output - gologger.Infof("Creating temporary massdns output file: %s\n", massDNSOutput) + gologger.Info().Msgf("Creating temporary massdns output file: %s\n", massDNSOutput) err = c.runMassDNS(massDNSOutput, shstore) if err != nil { return fmt.Errorf("could not execute massdns: %w", err) } } - gologger.Infof("Started parsing massdns output\n") + gologger.Info().Msgf("Started parsing massdns output\n") err = c.parseMassDNSOutput(massDNSOutput, shstore) if err != nil { return fmt.Errorf("could not parse massdns output: %w", err) } - gologger.Infof("Massdns output parsing compeleted\n") + gologger.Info().Msgf("Massdns output parsing completed\n") // Perform wildcard filtering only if domain name has been specified if c.config.Domain != "" { - gologger.Infof("Started removing wildcards records\n") + gologger.Info().Msgf("Started removing wildcards records\n") err = c.filterWildcards(shstore) if err != nil { return fmt.Errorf("could not parse massdns output: %w", err) } - gologger.Infof("Wildcard removal completed\n") + gologger.Info().Msgf("Wildcard removal completed\n") } - gologger.Infof("Finished enumeration, started writing output\n") + gologger.Info().Msgf("Finished enumeration, started writing output\n") // Write the final elaborated list out return c.writeOutput(shstore) @@ -83,9 +84,9 @@ func (c *Client) Process() error { func (c *Client) runMassDNS(output string, store *store.Store) error { if c.config.Domain != "" { - gologger.Infof("Executing massdns on %s\n", c.config.Domain) + gologger.Info().Msgf("Executing massdns on %s\n", c.config.Domain) } else { - gologger.Infof("Executing massdns\n") + gologger.Info().Msgf("Executing massdns\n") } now := time.Now() // Run the command on a temp file and wait for the output @@ -96,7 +97,7 @@ func (c *Client) runMassDNS(output string, store *store.Store) error { if err != nil { return fmt.Errorf("could not execute massdns: %w\ndetailed error: %s", err, stderr.String()) } - gologger.Infof("Massdns execution took %s\n", time.Now().Sub(now)) + gologger.Info().Msgf("Massdns execution took %s\n", time.Since(now)) return nil } @@ -212,14 +213,25 @@ func (c *Client) writeOutput(store *store.Store) error { } uniqueMap[hostname] = struct{}{} - buffer.WriteString(hostname) - buffer.WriteString("\n") + if c.config.Json { + hostnameJson, err := json.Marshal(map[string]interface{}{"hostname": hostname}) + if err != nil { + return fmt.Errorf("could not marshal output as json: %v", err) + } + + buffer.WriteString(string(hostnameJson)) + buffer.WriteString("\n") + } else { + buffer.WriteString(hostname) + buffer.WriteString("\n") + } + data := buffer.String() if output != nil { - w.WriteString(data) + _, _ = w.WriteString(data) } - gologger.Silentf("%s", data) + gologger.Silent().Msgf("%s", data) buffer.Reset() } } diff --git a/pkg/massdns/utils.go b/pkg/massdns/utils.go index aad35f6..0b959f5 100644 --- a/pkg/massdns/utils.go +++ b/pkg/massdns/utils.go @@ -1,6 +1,8 @@ package massdns import ( + "bufio" + "errors" "os" ) @@ -15,3 +17,22 @@ func IsBlankFile(file string) (bool, error) { } return false, nil } + +// DumpWildcardsToFile dumps the wildcard ips list to file +func (c *Client) DumpWildcardsToFile(filename string) error { + if len(c.wildcardIPMap) == 0 { + return errors.New("no wildcards") + } + f, err := os.Create(filename) + if err != nil { + return err + } + defer f.Close() + + bw := bufio.NewWriter(f) + for k := range c.wildcardIPMap { + _, _ = bw.WriteString(k + "\n") + } + defer bw.Flush() + return nil +} diff --git a/pkg/runner/banners.go b/pkg/runner/banners.go index 5126d87..d5eafa2 100644 --- a/pkg/runner/banners.go +++ b/pkg/runner/banners.go @@ -6,17 +6,17 @@ const banner = ` __ ________ __ ___ / / __ __/ _/ _/ /__ ___/ /__ ___ (_-= int32(len(w.servers)-1) { - atomic.StoreInt32(&w.serversIndex, 0) - serverIndex = 0 - } - resolver := w.servers[serverIndex] - atomic.AddInt32(&w.serversIndex, 1) - + resolver := w.servers.Next() var retryCount int - retry: - // Create a dns message and send it to the server m := new(dns.Msg) m.Id = dns.Id()