117 lines
4.2 KiB
Bash
Executable File
117 lines
4.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# change this :)
|
|
LISTADO="./lista.txt"
|
|
XARGS_PROCNUM="32"
|
|
HTTP_TIMEOUT="10"
|
|
|
|
RED="\e[0;31m"
|
|
GREEN="\e[0;32m"
|
|
YELLOW="\e[0;33m"
|
|
NC="\e[0m"
|
|
DISTRO="" # will be defined at runtime
|
|
|
|
make_banner() {
|
|
cat <<'EOF'
|
|
_ _ _ _ _
|
|
__ _ _ __ | |_(_| )__ _ __ ___ ___ _ __ (_) |_ ___ _ __
|
|
/ _` | '_ \| __| |/ __| | '_ ` _ \ / _ \| '_ \| | __/ _ \| '__|
|
|
| (_| | | | | |_| |\__ \ | | | | | | (_) | | | | | || (_) | |
|
|
\__,_|_| |_|\__|_||___/ |_| |_| |_|\___/|_| |_|_|\__\___/|_|
|
|
EOF
|
|
}
|
|
|
|
make_text() {
|
|
case $2 in
|
|
ok)
|
|
echo -e "${GREEN}[+] $1${NC}"
|
|
;;
|
|
warn)
|
|
echo -e "${YELLOW}[+] $1${NC}"
|
|
;;
|
|
err)
|
|
echo -e "${RED}[+] $1${NC}"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
get_os() {
|
|
OS=$(cat /etc/os-release)
|
|
if [[ "$OS" =~ "Debian" ]];
|
|
then
|
|
DISTRO="debian"
|
|
elif [[ "$OS" =~ "Ubuntu" ]];
|
|
then
|
|
DISTRO="ubuntu"
|
|
elif [[ "$OS" =~ "Rocky" ]];
|
|
then
|
|
DISTRO="centos"
|
|
elif [[ "$OS" =~ "CloudLinux" ]];
|
|
then
|
|
DISTRO="centos"
|
|
elif [[ "$OS" =~ "Alma" ]];
|
|
then
|
|
DISTRO="centos"
|
|
elif [[ "$OS" =~ "Arch" ]];
|
|
then
|
|
DISTRO="arch"
|
|
elif [[ "$OS" =~ "Centos" ]];
|
|
then
|
|
DISTRO="centos"
|
|
elif [[ "$OS" =~ "Fedora" ]];
|
|
then
|
|
DISTRO="centos"
|
|
fi
|
|
}
|
|
|
|
check_curl() {
|
|
if ! curl -sqo /dev/null google.com ;
|
|
then
|
|
make_text "cURL is not installed. installing..." warn
|
|
case $DISTRO in
|
|
ubuntu | debian)
|
|
sudo apt install curl -y
|
|
;;
|
|
centos)
|
|
sudo dnf install curl -y
|
|
;;
|
|
arch)
|
|
sudo pacman -S curl
|
|
;;
|
|
*)
|
|
make_text "distro not supported. make a commit!" err
|
|
esac
|
|
fi
|
|
make_text "cURL is okay. continuing..." ok
|
|
}
|
|
|
|
make_report() {
|
|
make_text "running cURL on $(wc -l $LISTADO | cut -d" " -f1 ) sites..." ok
|
|
REPORT="report_$(date +"%d-%m-%y-%R")"
|
|
mkdir "$REPORT"
|
|
echo "url,http_code,remote_ip,response_code,time_total,url_effective,redirect_url,errormsg" >> "$REPORT"/"$REPORT".txt
|
|
echo "url,http_code,remote_ip,response_code,time_total,url_effective,redirect_url,errormsg" >> "$REPORT"/"$REPORT"_connissues.txt
|
|
echo "url,http_code,remote_ip,response_code,time_total,url_effective,redirect_url,errormsg" >> "$REPORT"/"$REPORT"_timeout.txt
|
|
echo "url,http_code,remote_ip,response_code,time_total,url_effective,redirect_url,errormsg" >> "$REPORT"/"$REPORT"_unresolved.txt
|
|
xargs -t -P $XARGS_PROCNUM -I {} \
|
|
curl -sqo /dev/null {} \
|
|
-w "%{url},%{http_code},%{remote_ip},%{response_code},%{time_total},%{url_effective},%{redirect_url},%{errormsg}\n" \
|
|
--connect-timeout "$HTTP_TIMEOUT" < "$LISTADO" >> "$REPORT"/"$REPORT".txt
|
|
make_text "creating subreports..." warn
|
|
grep -i "not resolve" "$REPORT"/"$REPORT".txt >> "$REPORT"/"$REPORT"_unresolved.txt
|
|
grep -i "not connect" "$REPORT"/"$REPORT".txt >> "$REPORT"/"$REPORT"_connissues.txt
|
|
grep -i "timed out" "$REPORT"/"$REPORT".txt >> "$REPORT"/"$REPORT"_timeout.txt
|
|
make_text "found $(wc -l "$REPORT"/"$REPORT"_timeout.txt | cut -d" " -f1) timeouts." warn
|
|
make_text "found $(wc -l "$REPORT"/"$REPORT"_connissues.txt | cut -d" " -f1) sites with connection issues." warn
|
|
make_text "found $(wc -l "$REPORT"/"$REPORT"_unresolved.txt | cut -d" " -f1) sites with unresolved IP addresses." warn
|
|
make_text "found $(grep -cviE "not resolve|not connect|timed out" "$REPORT"/"$REPORT".txt) sites that are okay." ok
|
|
make_text "reports ready. good luck :)" ok
|
|
}
|
|
|
|
|
|
|
|
get_os
|
|
check_curl
|
|
make_report
|
|
make_banner
|