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

made os detection even faster, fixed typos

This commit is contained in:
Nils 2021-01-21 21:06:26 +00:00 committed by GitHub
parent fcedda6dfa
commit 9df9d6ccfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

66
conn.sh
View File

@ -44,10 +44,16 @@ fi
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"
fping=$(fping -a $2) fping=$(fping -a $2)
if [[ $fping != "$2" ]] && [[ -n $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -n $(nping -q1 -c1 -p3389 $2 | grep "Successful connections: 1") ]];then p135=$(nping -q1 -c1 -p135 $2)
p3389=$(nping -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
elif [[ $fping != "$2" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------"
echo "$2 is not reachable"
echo "-----------------------------------------------------"
else else
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $2 fping -e $2
@ -55,7 +61,7 @@ fi
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
echo "note: this seems to be a linux machine" echo "note: this seems to be a linux machine"
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
fi fi
@ -67,10 +73,16 @@ fi
exit exit
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
fping=$(fping -a $2) fping=$(fping -a $2)
if [[ $fping != "$2" ]] && [[ -n $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -n $(nping -q1 -c1 -p3389 $2 | grep "Successful connections: 1") ]];then p135=$(nping -q1 -c1 -p135 $2)
p3389=$(nping -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
elif [[ $fping != "$2" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------"
echo "$2 is not reachable"
echo "-----------------------------------------------------"
else else
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $2 fping -e $2
@ -78,7 +90,7 @@ fi
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
echo "note: this seems to be a linux machine" echo "note: this seems to be a linux machine"
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
fi fi
@ -87,10 +99,16 @@ fi
echo "-6 used, forcing IPv6 portscanning" echo "-6 used, forcing IPv6 portscanning"
echo "checking connection status for $2" echo "checking connection status for $2"
fping=$(fping -6 -a $2) fping=$(fping -6 -a $2)
if [[ $fping != "$2" ]] && [[ -n $(nping -6 -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -n $(nping -6 -q1 -c1 -p3389 $2 | grep "Successful connections: 1") ]];then p135=$(nping -6 -q1 -c1 -p135 $2)
p3389=$(nping -6 -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
elif [[ $fping != "$2" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------"
echo "$2 is not reachable"
echo "-----------------------------------------------------"
else else
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -6 -e $2 fping -6 -e $2
@ -98,7 +116,7 @@ fi
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
echo "note: this seems to be a linux machine" echo "note: this seems to be a linux machine"
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
fi fi
@ -112,10 +130,16 @@ fi
echo "-4 used, forcing IPv4 portscanning" echo "-4 used, forcing IPv4 portscanning"
echo "checking connection status for $2" echo "checking connection status for $2"
fping=$(fping -4 -a $2) fping=$(fping -4 -a $2)
if [[ $fping != "$2" ]] && [[ -n $(nping -4 -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -n $(nping -4 -q1 -c1 -p3389 $2 | grep "Successful connections: 1") ]];then p135=$(nping -4 -q1 -c1 -p135 $2)
p3389=$(nping -4 -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
elif [[ $fping != "$2" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------"
echo "$2 is not reachable"
echo "-----------------------------------------------------"
else else
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -4 -e $2 fping -4 -e $2
@ -123,7 +147,7 @@ fi
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
echo "note: this seems to be a linux machine" echo "note: this seems to be a linux machine"
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
fi fi
@ -150,7 +174,9 @@ fi
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"
fping=$(fping -a $2) fping=$(fping -a $2)
if [[ $fping != "$2" ]] && [[ -n $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]] || [[ $fping == "$2" ]] && [[ -n $(nping -q1 -c1 -p3389 $2 | grep "Successful connections: 1") ]];then p135=$(nping -q1 -c1 -p135 $2)
p3389=$(nping -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
notify-send "$2 is now reachable" "and seems to be a windows machine" -u normal -t 15000 -a conn notify-send "$2 is now reachable" "and seems to be a windows machine" -u normal -t 15000 -a conn
@ -166,7 +192,7 @@ fi
echo "note: this seems to be a linux machine" echo "note: this seems to be a linux machine"
notify-send "$2 is now reachable" "and seems to be in a linux system" -u normal -t 15000 -a conn notify-send "$2 is now reachable" "and seems to be in a linux system" -u normal -t 15000 -a conn
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
notify-send "$2 is now reachable" "and seems to be in the rescue system" -u normal -t 15000 -a conn notify-send "$2 is now reachable" "and seems to be in the rescue system" -u normal -t 15000 -a conn
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
@ -188,10 +214,16 @@ fi
echo "detected IPv6 adress -> using -6" echo "detected IPv6 adress -> using -6"
echo "checking connection status for $1" echo "checking connection status for $1"
fping=$(fping -6 -a $1) fping=$(fping -6 -a $1)
if [[ $fping != "$1" ]] && [[ -n $(nping -6 -q1 -c1 -p135 $1 | grep "Successful connections: 1") ]] || [[ $fping == "$1" ]] && [[ -n $(nping -6 -q1 -c1 -p3389 $1 | grep "Successful connections: 1") ]];then p135=$(nping -6 -q1 -c1 -p135 $1)
p3389=$(nping -6 -q1 -c1 -p3389 $1)
if [[ $fping != "$1" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$1" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
elif [[ $fping != "$1" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping == "$1" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------"
echo "$2 is not reachable"
echo "-----------------------------------------------------"
else else
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -6 -e $1 fping -6 -e $1
@ -199,7 +231,7 @@ fi
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
echo "note: this seems to be a linux machine" echo "note: this seems to be a linux machine"
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
fi fi
@ -230,10 +262,16 @@ fi
else else
echo "checking connection status for $1" echo "checking connection status for $1"
fping=$(fping -a $1) fping=$(fping -a $1)
if [[ $fping != "$1" ]] && [[ -n $(nping -q1 -c1 -p135 $1 | grep "Successful connections: 1") ]] || [[ $fping == "$1" ]] && [[ -n $(nping -q1 -c1 -p3389 $1 | grep "Successful connections: 1") ]];then p135=$(nping -q1 -c1 -p135 $1)
p3389=$(nping -q1 -c1 -p3389 $1)
if [[ $fping != "$1" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$1" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
elif [[ $fping != "$1" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$1" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------"
echo "$1 is not reachable"
echo "-----------------------------------------------------"
else else
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $1 fping -e $1
@ -241,7 +279,7 @@ fi
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
echo "note: this seems to be a linux machine" echo "note: this seems to be a linux machine"
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
fi fi