Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.7 Release preparation #117

Merged
merged 47 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6b6f84c
chore(deps): bump golang from 1.16.7-alpine3.14 to 1.17.0-alpine3.14
dependabot[bot] Aug 23, 2021
50f62f5
Merge pull request #100 from projectdiscovery/dependabot/docker/dev/g…
Mzack9999 Aug 23, 2021
52662a7
Adding support for resolver protocol
Mzack9999 Aug 26, 2021
91fa4f1
updating retryabledns with doh support
Mzack9999 Aug 28, 2021
993cc8c
bumping go version
Mzack9999 Aug 31, 2021
9a507d2
adding functional tests
Mzack9999 Aug 31, 2021
c8c9620
suppressing linter for functional tests helper routines
Mzack9999 Aug 31, 2021
e6778af
chore(deps): bump golang from 1.17.0-alpine3.14 to 1.17.1-alpine3.14
dependabot[bot] Sep 13, 2021
eb7c606
Merge pull request #105 from projectdiscovery/dependabot/docker/dev/g…
ehsandeep Sep 13, 2021
55e3d7d
updating go modules
Mzack9999 Sep 16, 2021
8cd8118
Merge pull request #103 from projectdiscovery/101-maintenance-tests
Mzack9999 Sep 16, 2021
0436355
Merge branch 'dev' into 98-feature-custom-port-in-resolvers
Mzack9999 Sep 16, 2021
0cb41bf
Merge pull request #102 from projectdiscovery/98-feature-custom-port-…
ehsandeep Sep 16, 2021
44ffc15
improve perf in filtering wildcard subdomains
Sep 22, 2021
315142a
fix mistake
Sep 22, 2021
fc03f70
fix counting removed wildcard subdomains
Sep 22, 2021
69e9f26
fix bug in printing results
Sep 22, 2021
9d456ba
some minor improvements
Sep 23, 2021
a4ff978
fix false positive cases in filtering wildcard subdomains & improve perf
Sep 23, 2021
bbc40f2
fix bugs
Sep 23, 2021
a9df361
reduce dns requests by caching
Sep 23, 2021
fffdbca
fix duplicate
Sep 26, 2021
94ea6ae
remove duplicate wildcard checks
Sep 26, 2021
05f9578
Adding hosts file support
Mzack9999 Sep 27, 2021
9632562
chore(deps): bump golang from 1.17.1-alpine3.14 to 1.17.2-alpine3.14
dependabot[bot] Oct 11, 2021
12bc672
Merge pull request #110 from projectdiscovery/dependabot/docker/dev/g…
Mzack9999 Oct 11, 2021
abdd824
Merge pull request #106 from yabeow/master
ehsandeep Oct 15, 2021
f39e06b
Merge branch 'master' of https://github.com/projectdiscovery/dnsx int…
ehsandeep Oct 19, 2021
b3b1983
chore(deps): bump golang from 1.17.2-alpine3.14 to 1.17.3-alpine3.14
dependabot[bot] Nov 8, 2021
44f4ccb
Merge pull request #114 from projectdiscovery/dependabot/docker/dev/g…
Mzack9999 Nov 8, 2021
1450448
Merge pull request #108 from projectdiscovery/adding-hosts-file-support
ehsandeep Nov 8, 2021
4c80e56
goflags support
LuitelSamikshya Nov 10, 2021
294bb2b
format fix in readme
LuitelSamikshya Nov 10, 2021
7729428
misc updates
ehsandeep Nov 11, 2021
10188a9
readme updates
ehsandeep Nov 11, 2021
21beb31
Merge pull request #116 from projectdiscovery/goflags-support
ehsandeep Nov 11, 2021
3c2f77c
misc update
ehsandeep Nov 11, 2021
4cb8a47
workflow updates
ehsandeep Nov 11, 2021
52c4056
added functional test cases
LuitelSamikshya Nov 15, 2021
75f04c6
added functional-test pipeline for github action
LuitelSamikshya Nov 16, 2021
9bca3b0
Merge branch 'dev' of https://github.com/projectdiscovery/dnsx into f…
ehsandeep Nov 16, 2021
9236f3e
misc updates
ehsandeep Nov 16, 2021
b21afd6
misc test updates
ehsandeep Nov 17, 2021
1d2c410
Merge pull request #120 from projectdiscovery/functional-test
ehsandeep Nov 17, 2021
ed425bf
version update
ehsandeep Nov 18, 2021
5df7e58
update: installation instruction in docker file
ehsandeep Nov 19, 2021
2d84859
readme update
ehsandeep Nov 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17

- name: Test
run: go test .
working-directory: cmd/dnsx/

- name: Integration Tests
run: bash run.sh
working-directory: integration_tests/

- name: Build
run: go build .
working-directory: cmd/dnsx/
32 changes: 19 additions & 13 deletions .github/workflows/dockerhub-push.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
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: Git Checkout
uses: actions/checkout@v2
-
name: Set up QEMU

- name: Get Github tag
id: meta
run: |
echo "::set-output name=tag::$(curl --silent "https://api.github.com/repos/projectdiscovery/dnsx/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/dnsx:latest
tags: projectdiscovery/dnsx:latest,projectdiscovery/dnsx:${{ steps.meta.outputs.tag }}
25 changes: 25 additions & 0 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 🧪 Functional Test
on:
push:
pull_request:
workflow_dispatch:


jobs:
functional:
name: Functional Test
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Check out code
uses: actions/checkout@v2

- name: Functional Tests
run: |
chmod +x run.sh
bash run.sh
working-directory: cmd/functional-test
2 changes: 1 addition & 1 deletion .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: "Set up Go"
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
-
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
cmd/dnsx/dnsx
.DS_Store
dist/
dist/
cmd/functional-test/dnsx_dev
cmd/functional-test/functional-test
cmd/functional-test/dnsx
cmd/functional-test/log.txt
cmd/functional-test/*.cfg
52 changes: 33 additions & 19 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
before:
hooks:
- go mod tidy

builds:
- binary: dnsx
main: cmd/dnsx/dnsx.go
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386
- arm
- arm64

- env:
- CGO_ENABLED=0
goos:
- windows
- linux
- darwin
goarch:
- amd64
- 386
- arm
- arm64

ignore:
- goos: darwin
goarch: '386'
- goos: windows
goarch: 'arm'
- goos: windows
goarch: 'arm64'

binary: '{{ .ProjectName }}'
main: cmd/dnsx/dnsx.go

archives:
- id: tgz
format: tar.gz
replacements:
darwin: macOS
format_overrides:
- goos: windows
format: zip
- format: zip
replacements:
darwin: macOS

checksum:
algorithm: sha256
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM golang:1.16.7-alpine3.14 AS build-env
RUN go get -v github.com/projectdiscovery/dnsx/cmd/dnsx
FROM golang:1.17.3-alpine3.14 AS build-env
RUN go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest

FROM alpine:3.14
RUN apk add --no-cache bind-tools ca-certificates
Expand Down
95 changes: 56 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
- Handles wildcard subdomains in automated way.
- **Stdin** and **stdout** support to work with other tools.

# Installation Instructions


dnsx requires **go1.17** to install successfully. Run the following command to get the repo -

```sh
go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest
```

# Usage

```sh
Expand All @@ -56,44 +65,52 @@ dnsx -h

This will display help for the tool. Here are all the switches it supports.

| Flag | Description | Example |
| ------------------- | ---------------------------------- | --------------------- |
| a | Query A record | dnsx -a |
| aaaa | Query AAAA record | dnsx -aaaa |
| cname | Query CNAME record | dnsx -cname |
| ns | Query NS record | dnsx -ns |
| ptr | Query PTR record | dnsx -ptr |
| txt | Query TXT record | dnsx -txt |
| mx | Query MX record | dnsx -mx |
| soa | Query SOA record | dnsx -soa |
| raw | Operates like dig | dnsx -raw |
| rcode | DNS Response codes | dnsx -rcode 0,1,2 |
| l | File input list of subdomains/host | dnsx -l list.txt |
| json | JSON output | dnsx -json |
| r | File or comma separated resolvers | dnsx -r 1.1.1.1 |
| rl | Limit of DNS request/second | dnsx -rl 100 |
| resp | Display response data | dnsx -cname -resp |
| resp-only | Display only response data | dnsx -cname resp-only |
| retry | Number of DNS retries | dnsx -retry 1 |
| silent | Show only results in the output | dnsx -silent |
| stats | Display stats of the running scan | dnsx -stats |
| o | File to write output to (optional) | dnsx -o output.txt |
| t | Concurrent threads to make | dnsx -t 100 |
| trace | Perform dns trace | dnsx -trace |
| trace-max-recursion | Max recursion for dns trace | dnsx -t 32767 |
| verbose | Verbose output | dnsx -verbose |
| version | Show version of dnsx | dnsx -version |
| wd | Wildcard domain name for filtering | dnsx -wd example.com |
| wt | Wildcard Filter Threshold | dnsx -wt 5 |


# Installation Instructions


dnsx requires **go1.16+** to install successfully. Run the following command to get the repo -

```sh
go get -v github.com/projectdiscovery/dnsx/cmd/dnsx
```console
INPUT:
-l, -list string File input with list of sub(domains)/hosts

QUERY:
-a Query A record (default)
-aaaa Query AAAA record
-cname Query CNAME record
-ns Query NS record
-txt Query TXT record
-ptr Query PTR record
-mx Query MX record
-soa Query SOA record

FILTERS:
-resp Display DNS response
-resp-only Display DNS response only
-rcode, -rc string Display DNS status code (eg. -rcode noerror,servfail,refused)

RATE-LIMIT:
-t, -c int Number of concurrent threads to use (default 100)
-rl, -rate-limit int Number of DNS request/second (disabled as default) (default -1)

OUTPUT:
-o, -output string File to write output (optional)
-json Write output in JSONL(ines) format

DEBUG:
-silent Show only results in the output
-v, -verbose Verbose output
-raw, -debug Display RAW DNS response
-stats Display stats of the running scan
-version Show version of dnsx

OPTIMIZATION:
-retry int Number of DNS retries (default 1)
-hf, -hostsfile Parse system host file
-trace Perform DNS trace
-trace-max-recursion int Max recursion for dns trace (default 32767)
-flush-interval int Flush interval of output file (default 10)
-resume Resume

CONFIGURATIONS:
-r, -resolver string List of resolvers (file or comma separated)
-wt, -wildcard-threshold int Wildcard Filter Threshold (default 5)
-wd, -wildcard-domain string Domain name for wildcard filtering (other flags will be ignored)
```

### Running dnsx
Expand Down Expand Up @@ -136,7 +153,7 @@ support.hackerone.com [104.16.53.111]
**dnsx** can be used to extract **A** records for the given list of subdomains, for example:-

```sh
subfinder -silent -d hackerone.com | dnsx -silent -a -resp-only
subfinder -silent -d hackerone.com | dnsx -silent -a -resp-only

104.16.99.52
104.16.100.52
Expand Down
83 changes: 83 additions & 0 deletions cmd/functional-test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package main

import (
"bufio"
"flag"
"fmt"
"log"
"os"
"strings"

"github.com/logrusorgru/aurora"
"github.com/pkg/errors"

"github.com/projectdiscovery/dnsx/internal/testutils"
)

var (
debug = os.Getenv("DEBUG") == "true"
success = aurora.Green("[✓]").String()
failed = aurora.Red("[✘]").String()
errored = false

mainDnsxBinary = flag.String("main", "", "Main Branch Dnsx Binary")
devDnsxBinary = flag.String("dev", "", "Dev Branch Dnsx Binary")
testcases = flag.String("testcases", "", "Test cases file for dnsx functional tests")
)

func main() {
flag.Parse()

if err := runFunctionalTests(); err != nil {
log.Fatalf("Could not run functional tests: %s\n", err)
}
if errored {
os.Exit(1)
}
}

func runFunctionalTests() error {
file, err := os.Open(*testcases)
if err != nil {
return errors.Wrap(err, "could not open test cases")
}
defer file.Close()

scanner := bufio.NewScanner(file)
for scanner.Scan() {
text := strings.TrimSpace(scanner.Text())
if text == "" {
continue
}
if err := runIndividualTestCase(text); err != nil {
errored = true
fmt.Fprintf(os.Stderr, "%s Test \"%s\" failed: %s\n", failed, text, err)
} else {
fmt.Printf("%s Test \"%s\" passed!\n", success, text)
}
}
return nil
}

func runIndividualTestCase(testcase string) error {
parts := strings.Fields(testcase)

var finalArgs []string
var target string
if len(parts) > 1 {
finalArgs = parts[2:]
target = parts[0]
}
mainOutput, err := testutils.RunDnsxBinaryAndGetResults(target, *mainDnsxBinary, debug, finalArgs)
if err != nil {
return errors.Wrap(err, "could not run dnsx main test")
}
devOutput, err := testutils.RunDnsxBinaryAndGetResults(target, *devDnsxBinary, debug, finalArgs)
if err != nil {
return errors.Wrap(err, "could not run dnsx dev test")
}
if len(mainOutput) == len(devOutput) {
return nil
}
return fmt.Errorf("%s main is not equal to %s dev", mainOutput, devOutput)
}
13 changes: 13 additions & 0 deletions cmd/functional-test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echo 'Building functional-test binary'
go build

echo 'Building DNSX binary from current branch'
go build -o dnsx_dev ../dnsx

echo 'Installing latest release of DNSX'
GO111MODULE=on go build -v github.com/projectdiscovery/dnsx/cmd/dnsx

echo 'Starting DNSX functional test'
./functional-test -main ./dnsx -dev ./dnsx_dev -testcases testcases.txt