我目前正在尝试编写一个脚本,用于写出它检测到的域名。第一个想法是写出任何包含" NXDOMAIN",但最终包括我发现我无法注册的域名。所以我添加了对#34; a.gtld的要求-servers.net"也。问题是,这两个条件都在域名上得到满足。关于我可以使用什么来过滤我的结果,我完全没有想法。
有没有人有任何想法?这是我的代码:
function getResponse () {
output=$(dig $1.com +nostats +noanswer +noquestion)
if [[ $output == *NXDOMAIN* ]] && [[ $output == *a.gtld-servers.net.* ]]; then
echo "$1.com"
fi
}
for v in {a..z}; do
for w in {a..z}; do
for x in {a..z}; do
getResponse $v$w$x &
sleep 0.01s
done
done
done
for v in {a..z}; do
for w in {a..z}; do
for x in {a..z}; do
for y in {a..z}; do
getResponse $v$w$x$y &
sleep 0.01s
done
done
done
done
答案 0 :(得分:4)
这是一个似乎有效的脚本:
#! /bin/bash
do_query () # name
{
dig "$1" +noquestion +nostat +noanswer +noauthority 2> /dev/null
}
get_answers_number () # name
{
local res=$(do_query "$1")
res=${res##*ANSWER: }
echo "${res%%,*}"
}
# Unregistered domains saved in file
file="unregistered.txt"
echo "Results will be saved in $file"
for adr in {a..z}{a..z}{a..z} {a..z}{a..z}{a..z}{a..z}
do
name="$adr.com"
printf "Checking %s ...\r" "$name"
r=$(get_answers_number "$name")
if ((r==0)); then
echo "Found $name "
echo "$name" >&3
fi
done 3>| "$file"