Skip to content

Commit

Permalink
Added optional --bin to specify the location of the massdns binary
Browse files Browse the repository at this point in the history
  • Loading branch information
d3mondev committed Jul 30, 2020
1 parent 20912f6 commit cf070f1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ Only the resulting valid domains are sent to stdout so that you can pipe the res

## Installation

puredns requires massdns to be installed on the host machine. [Follow the instructions](https://github.com/blechschmidt/massdns#compilation) to compile massdns on your system. For now, it also needs to be in accessible through the PATH environment variable. On most systems, a good place to copy the massdns executable is `/usr/local/bin`.
puredns requires massdns to be installed on the host machine. [Follow the instructions](https://github.com/blechschmidt/massdns#compilation) to compile massdns on your system.

If the path to the massdns binary is present in the PATH environment variable, puredns will work out of the box. On most systems, a good place to copy the massdns executable is `/usr/local/bin`.

Otherwise, you will need to specify the path to the massdns binary file using the `--bin` command line argument.

The script also requires a few other dependencies:

Expand Down Expand Up @@ -111,6 +115,8 @@ Usage:
bruteforce <wordlist> <domain> Perform subdomain bruteforcing on a domain using a wordlist
Optional:
-b, --bin <path> Path to massdns binary file
-r, --resolvers <filename> Text file containing resolvers
-rt, --resolvers-trusted <filename> Text file containing trusted resolvers
Expand All @@ -125,7 +131,7 @@ Usage:
-sw, --skip-wildcard-check Do no perform wildcard detection and filtering
-sv, --skip-validation Do not validate massdns results using trusted resolvers
-w, --write <filename> Write valid domains to a file
-w, --write <filename> Write valid domains to a file
-wm, --write-massdns <filename> Write massdns results to a file
-ww, --write-wildcards <filename> Write wildcard root subdomains to a file
-wa, --write-answers <filename> Write wildcard DNS answers to a file
Expand Down
23 changes: 20 additions & 3 deletions puredns
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ usage() {
echo " bruteforce <wordlist> <domain> Perform subdomain bruteforcing on a domain using a wordlist"
echo ""
echo " Optional:"
echo " -b, --bin <path> Path to massdns binary file"
echo ""
echo " -r, --resolvers <filename> Text file containing resolvers"
echo " -rt, --resolvers-trusted <filename> Text file containing trusted resolvers"
echo ""
Expand All @@ -52,7 +54,7 @@ usage() {
echo " -sw, --skip-wildcard-check Do no perform wildcard detection and filtering"
echo " -sv, --skip-validation Do not validate massdns results using trusted resolvers"
echo ""
echo " -w, --write <filename> Write valid domains to a file"
echo " -w, --write <filename> Write valid domains to a file"
echo " -wm, --write-massdns <filename> Write massdns results to a file"
echo " -ww, --write-wildcards <filename> Write wildcard root subdomains to a file"
echo " -wa, --write-answers <filename> Write wildcard DNS answers to a file"
Expand Down Expand Up @@ -84,6 +86,8 @@ log_success() {
}

parse_args() {
massdns_bin="massdns"

resolvers_file="$(dirname $0)/resolvers.txt"
trusted_resolvers_file="$(dirname $0)/trusted.txt"

Expand All @@ -102,6 +106,10 @@ parse_args() {
set +u
while :; do
case $1 in
--bin|-b)
massdns_bin=$2
shift
;;
--resolvers|-r)
resolvers_file=$2
shift
Expand Down Expand Up @@ -172,6 +180,15 @@ parse_args() {
shift
done

"${massdns_bin}" --help > /dev/null 2>&1
if [[ ! $? -eq 0 ]]; then
echo "Error: unable to execute massdns. Make sure it is present and that the"
echo "path to the binary is added to the PATH environment variable."
echo ""
echo "Alternatively, specify the path to massdns using --bin"
exit 1
fi

if [[ -z "${mode}" ]]; then
usage
echo ""
Expand Down Expand Up @@ -275,7 +292,7 @@ massdns_resolve() {
pv_args+=("-L" "${limit_rate}")
fi

cat "${domains_work}" | pv "${pv_args[@]}" | massdns -q -r "${resolvers_file}" -o S -t A -w "${massdns_work}"
cat "${domains_work}" | pv "${pv_args[@]}" | "${massdns_bin}" -q -r "${resolvers_file}" -o S -t A -w "${massdns_work}"
cat "${massdns_work}" | awk -F '. ' '{ print $1 }' | sort -u > "${domains_work}"

printf "${COL_RESET}" >&2
Expand Down Expand Up @@ -328,7 +345,7 @@ massdns_validate() {
printf "${COL_PV}" >&2

local count=$(wc -l ${domains_work} | awk '{ print $1 }')
cat "${domains_work}" | pv -L "${rate}" -l -F "Queries per second: %r %t %e Progress: %p" -s "${count}" | massdns -q -r "${trusted_resolvers_file}" -o S -t A -w "${massdns_work}"
cat "${domains_work}" | pv -L "${rate}" -l -F "Queries per second: %r %t %e Progress: %p" -s "${count}" | "${massdns_bin}" -q -r "${trusted_resolvers_file}" -o S -t A -w "${massdns_work}"
cat "${massdns_work}" | awk -F '. ' '{ print $1 }' | sort -u > "${domains_work}"

printf "${COL_RESET}" >&2
Expand Down

0 comments on commit cf070f1

Please sign in to comment.