Skip to content

Instantly share code, notes, and snippets.

@lexavey
Created September 26, 2022 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lexavey/8cf2a5c5bada83eeb81ff81a90a55cbc to your computer and use it in GitHub Desktop.
Save lexavey/8cf2a5c5bada83eeb81ff81a90a55cbc to your computer and use it in GitHub Desktop.
Check HTTP Status
down_par(){
while ! command -v ./parallel &> /dev/null
do
# printf "\rDownloading Parallel"
wget -q http://git.savannah.gnu.org/cgit/parallel.git/plain/src/parallel -O parallel
chmod 755 parallel
printf "will cite" | ./parallel --citation &> /dev/null
done
}
fast_search(){
host=$1
if [[ $host =~ http[s]? ]]; then
url="$host"
else
url="http://$host"
fi
temp_http_header=$(mktemp)
temp_http_response=$(mktemp)
code=$(curl -L -s $url --insecure -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 OPR/90.0.4480.100' --connect-timeout 15 --max-time 15 --write-out '%{http_code}' --dump-header $temp_http_header -o $temp_http_response)
result=$(grep -E $pattern $temp_http_header $temp_http_response -oah | sort -u |paste -d, -s)
echo "$host - $temp_http_header\n"
rm -f $temp_http_header
rm -f $temp_http_response
echo "$code|$url|$result">>result.txt
echo "$code|$url|$result"
}
down_par
export -f fast_search
./parallel -j 0 -a hosts.txt fast_search {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment