Skip to content

Instantly share code, notes, and snippets.

@BDhackers009
Last active April 27, 2022 06:11
Show Gist options
  • Save BDhackers009/30d6735334833798ce54741b7050455a to your computer and use it in GitHub Desktop.
Save BDhackers009/30d6735334833798ce54741b7050455a to your computer and use it in GitHub Desktop.
This is a simple script for Kali Linux(only) which is made with bash. It can scan a domain with subfinder and check all live subdomains using massdns and save the result into a directory.
#!/bin/bash
# Written BY Mustakim Ahmed SIfat {BDhaCkers009}
R="$(printf '\033[1;31m')"
G="$(printf '\033[1;32m')"
Y="$(printf '\033[1;33m')"
W="$(printf '\033[1;37m')"
C="$(printf '\033[1;36m')"
check_pkg() {
pkgs="massdns"
pkgs2="subfinder"
cmnd=$(sudo apt-cache search "${pkgs}")
cmnd2=$(sudo apt-cache search "${pkgs2}")
if [[ ${cmnd} == "" ]]; then
echo "Please install ${pkgs} manually"
echo
echo "massdns:- https://github.com/blechschmidt/massdns"
fi
if [[ ${cmnd2} == "" ]]; then
echo
echo "Please install ${pkgs2} manually"
echo
echo "subfinder:- https://github.com/projectdiscovery/subfinder"
exit 1
fi
}
if [[ ! $(command -v subfinder) && ! $(command -v massdns) ]]; then
check_pkg
fi
packs=(massdns wget subfinder)
for x in "${packs[@]}"; do
type -p "$x" &>/dev/null || {
echo -e "\n${R} [${W}-${R}]${G} Installing package : ${Y}$x${C}"${W}
sudo apt-get update && sudo apt-get install "$x" -y --no-install-recommends
}
done
# checking directory..
dir_="$HOME/proscan"
if [[ ! -d ${dir_} ]]; then
mkdir -p ${dir_}
fi
# downloading resolvers..
FILE="${dir_}/resolvers.txt"
FILE_URL="https://raw.githubusercontent.com/blechschmidt/massdns/master/lists/resolvers.txt"
if [[ -f "${FILE}" ]]; then
rm -rf "${FILE}"
wget -qO "${FILE}" "${FILE_URL}"
else
wget -qO "${FILE}" "${FILE_URL}"
fi
# scanning for subdomains
domain=$1
subs="${dir_}/${domain}"
if [[ $# -eq 0 ]]; then
echo -e "${R}Please provide a domain\n${W}"
echo -e "${Y}Example: ${G}bash $0 google.com${W}\n"
exit 1
else
if [[ -f "${subs}" ]]; then
rm -rf "${subs}"
fi
echo -e "\n${G}Scanning Subdomains of $domain"${W}
subfinder -nW -d "${domain}" -o ${subs}
fi
# scanning subdomains with massdns
lives="${dir_}/${domain}.results.txt"
if [[ -f "${lives}" ]]; then
rm -rf "${lives}"
fi
massdns -q -r ${FILE} -t A -o S -w "${lives}" "${subs}"
if [[ -f "${lives}" ]]; then
sed -i 's/A.*// ; s/CN.*// ; s/\..$//' "${lives}"
echo
echo
echo -e "${G}All live subdomains has been saved in ${dir_} as ${lives} ${W}\n"
elif [[ ! -f "${lives}" ]]; then
echo "${lives}${R} not found. Please re scan and check if the url was correct${W}\n"
echo
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment