1
0
mirror of https://github.com/byReqz/conn.git synced 2024-11-22 17:11:16 +00:00

rather big update

added multi-input (ipv4 and ipv6) detection, tweaked auto-detection regexes, added -4, tweaked syntax
This commit is contained in:
Nils 2021-01-16 23:15:46 +00:00 committed by GitHub
parent da4c4b57e5
commit f42ddf88d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

98
conn.sh
View File

@ -6,6 +6,7 @@ while [ ! -n "$1" ]; do
echo " -m/--multi -- test multiple ips / disable portscan" echo " -m/--multi -- test multiple ips / disable portscan"
echo " -h/--help -- show help" echo " -h/--help -- show help"
echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)" echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)"
echo " -4/--force-ipv4 -- force ipv4 portscanning (also forces portscanning)"
echo " -y/--yes -- portscan without asking" echo " -y/--yes -- portscan without asking"
echo " -n/--no -- dont portscan" echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y" echo " -p/--portscan -- same as -y"
@ -19,6 +20,7 @@ while [ ! -z "$1" ]; do
echo " -m/--multi -- test multiple ips / disable portscan" echo " -m/--multi -- test multiple ips / disable portscan"
echo " -h/--help -- show help" echo " -h/--help -- show help"
echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)" echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)"
echo " -4/--force-ipv4 -- force ipv4 portscanning (also forces portscanning)"
echo " -y/--yes -- portscan without asking" echo " -y/--yes -- portscan without asking"
echo " -n/--no -- dont portscan" echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y" echo " -p/--portscan -- same as -y"
@ -27,23 +29,23 @@ while [ ! -z "$1" ]; do
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
echo "multi-ip mode, portscan disabled" echo "multi-ip mode, portscan disabled"
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $@ fping -m -e $@
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
exit exit
elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then
echo "checking connection status for $2" echo "checking connection status for $2"
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $2 fping -m -e $2
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
echo "-------------------Portscan---------------------" echo "-------------------Portscan---------------------"
nmap -Pn $2 nmap -Pn $2
fping -c 4 -A $2 fping -m -c 4 -A $2
echo "------------------------------------------------" echo "------------------------------------------------"
exit exit
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
echo "checking connection status for $2" echo "checking connection status for $2"
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $2 fping -m -e $2
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
exit exit
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
@ -57,54 +59,82 @@ while [ ! -z "$1" ]; do
fping -6 -c 4 -A $2 fping -6 -c 4 -A $2
echo "------------------------------------------------" echo "------------------------------------------------"
exit exit
elif [[ $1 == "-4" ]] || [[ "$1" == "--force-ipv4" ]];then
echo "-4 used, forcing IPv4 portscanning"
echo "checking connection status for $2"
echo "-------------------Availability----------------------"
fping -4 -e $2
echo "-----------------------------------------------------"
echo "-------------------Portscan---------------------"
nmap -Pn $2
fping -6 -c 4 -A $2
echo "------------------------------------------------"
exit
elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then
echo "-w used, waiting for active connection" echo "-w used, waiting for active connection"
echo "checking connection status for $2" echo "checking connection status for $2"
while [[ "$(fping -q -u $2)" == "$2" ]]; do : while [[ "$(fping -m -q -u $2)" == "$2" ]]; do :
done done
notify-send "$2 is now reachable" -u normal -t 8000 -a conn notify-send "$2 is now reachable" -u normal -t 8000 -a conn
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $2 fping -m -e $2
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
echo "portscan? (y/n) (default: y)" echo "portscan? (y/n) (default: y)"
read portscan read portscan
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
echo "-------------------Portscan---------------------" echo "-------------------Portscan---------------------"
nmap -Pn $2 nmap -Pn $2
fping -c 4 -A $2 fping -m -c 4 -A $2
echo "------------------------------------------------" echo "------------------------------------------------"
exit
else
exit
fi
exit exit
elif [[ "$portscan" = "n" ]]; then elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ ! "$2" =~ [:] ]] && [[ -z "$3" ]];then
exit echo "detected IPv6 adress -> using -6"
fi
exit
#this checks if the ip is (not) ipv4 and then checks if it includes a :
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]];then
echo "noticed IPv6 adress -> using -6"
echo "checking connection status for $1" echo "checking connection status for $1"
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -6 -e $1 fping -6 -e $1
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
echo "-------------------Portscan---------------------" echo "portscan? (y/n) (default: y)"
nmap -Pn -6 $1 read portscan
fping -6 -c 4 -A $1 if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
echo "------------------------------------------------" echo "-------------------Portscan---------------------"
nmap -Pn -6 $1
fping -6 -c 4 -A $1
echo "------------------------------------------------"
else
exit
fi
exit
elif [[ "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$2" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] || [[ "$3" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ ! "$1" =~ [-] ]];then
echo "multi-ip input detected, portscan disabled"
echo "-------------------Availability----------------------"
fping -m -e $@
echo "-----------------------------------------------------"
exit
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ ! "$2" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ "$2" =~ [:] ]] || [[ ! "$3" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ ! "$1" =~ [-] ]];then
echo "multi-ipv6 input detected, portscan disabled"
echo "-------------------Availability----------------------"
fping -m -e -6 $@
echo "-----------------------------------------------------"
exit exit
else else
echo "checking connection status for $1" echo "checking connection status for $1"
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $1 fping -m -e $1
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
echo "portscan? (y/n) (default: y)" echo "portscan? (y/n) (default: y)"
read portscan read portscan
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
echo "-------------------Portscan---------------------" echo "-------------------Portscan---------------------"
nmap -Pn $1 nmap -Pn $1
fping -c 4 -A $1 fping -m -c 4 -A $1
echo "------------------------------------------------" echo "------------------------------------------------"
exit exit
elif [[ "$portscan" = "n" ]]; then else
exit exit
fi fi
fi fi
done done