mirror of
https://github.com/byReqz/conn.git
synced 2024-11-25 02:04:54 +00:00
bigger update
made os detection faster (yet again) fixed typos changed notifications when using -w
This commit is contained in:
parent
663e302316
commit
fcedda6dfa
111
conn.sh
111
conn.sh
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# license: gpl-3
|
||||||
|
|
||||||
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/conn.sh | md5sum | cut -c -32) != $(md5sum $0 | cut -c -32) ]] && [[ -z $1 ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/conn.sh | md5sum | cut -c -32) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "--update" ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/conn.sh | md5sum | cut -c -32) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "-u" ]];then
|
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/conn.sh | md5sum | cut -c -32) != $(md5sum $0 | cut -c -32) ]] && [[ -z $1 ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/conn.sh | md5sum | cut -c -32) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "--update" ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/conn.sh | md5sum | cut -c -32) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "-u" ]];then
|
||||||
echo "#############################################"
|
echo "#############################################"
|
||||||
@ -42,14 +43,22 @@ fi
|
|||||||
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"
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $2
|
fping -e $2
|
||||||
if [[ -n $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]];then
|
rescue=$(nping -q1 -c1 -p22,222 $2)
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(nping -q1 -c1 -p22 $2 | 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
|
||||||
|
echo "note: this seems to be in the rescue system"
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
echo "-------------------Portscan---------------------"
|
echo "-------------------Portscan---------------------"
|
||||||
nmap --reason -Pn $2
|
nmap --reason -Pn $2
|
||||||
echo ""
|
echo ""
|
||||||
@ -57,27 +66,42 @@ fi
|
|||||||
echo "------------------------------------------------"
|
echo "------------------------------------------------"
|
||||||
exit
|
exit
|
||||||
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
|
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
|
||||||
echo "checking connection status for $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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $2
|
fping -e $2
|
||||||
if [[ -n $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]];then
|
rescue=$(nping -q1 -c1 -p22,222 $2)
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(nping -q1 -c1 -p22 $2 | 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
|
||||||
|
echo "note: this seems to be in the rescue system"
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
exit
|
exit
|
||||||
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
|
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
|
||||||
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)
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -6 -e $2
|
fping -6 -e $2
|
||||||
if [[ -n $(nping -6 -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]];then
|
rescue=$(nping -6 -q1 -c1 -p22,222 $2)
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(nping -6 -q1 -c1 -p22 $2 | 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
|
||||||
|
echo "note: this seems to be in the rescue system"
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
echo "-------------------Portscan---------------------"
|
echo "-------------------Portscan---------------------"
|
||||||
nmap --reason -Pn -6 $2
|
nmap --reason -Pn -6 $2
|
||||||
echo ""
|
echo ""
|
||||||
@ -87,18 +111,26 @@ fi
|
|||||||
elif [[ $1 == "-4" ]] || [[ "$1" == "--force-ipv4" ]];then
|
elif [[ $1 == "-4" ]] || [[ "$1" == "--force-ipv4" ]];then
|
||||||
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)
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -4 -e $2
|
fping -4 -e $2
|
||||||
if [[ -n $(nping -4 -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]];then
|
rescue=$(nping -4 -q1 -c1 -p22,222 $2)
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(nping -4 -q1 -c1 -p22 $2 | 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
|
||||||
|
echo "note: this seems to be in the rescue system"
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
echo "-------------------Portscan---------------------"
|
echo "-------------------Portscan---------------------"
|
||||||
nmap --reason -Pn $2
|
nmap -4 --reason -Pn $2
|
||||||
echo ""
|
echo ""
|
||||||
fping -6 -c 4 $2
|
fping -4 -c 4 $2
|
||||||
echo "------------------------------------------------"
|
echo "------------------------------------------------"
|
||||||
exit
|
exit
|
||||||
elif [[ $1 == "-u" ]] || [[ "$1" == "--update" ]];then
|
elif [[ $1 == "-u" ]] || [[ "$1" == "--update" ]];then
|
||||||
@ -117,19 +149,28 @@ fi
|
|||||||
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"
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
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
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
while [[ "$(fping -m -q -u $2)" == "$2" ]]; do :
|
while [[ "$(fping -m -q -u $2)" == "$2" ]]; do :
|
||||||
done
|
done
|
||||||
notify-send "$2 is now reachable" -u normal -t 15000 -a conn
|
# notify-send "$2 is now reachable" -u normal -t 15000 -a conn
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $2
|
fping -e $2
|
||||||
if [[ -n $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]];then
|
rescue=$(nping -q1 -c1 -p22,222 $2)
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
notify-send "$2 seems to be a windows machine" -u normal -t 15000 -a conn
|
|
||||||
elif [[ -n $(nping -q1 -c1 -p22 $2 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this seems to be a linux machine"
|
echo "note: this seems to be a linux machine"
|
||||||
notify-send "$2 seems to be a linux machine" -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
|
||||||
|
echo "note: this 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
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
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
|
||||||
@ -146,14 +187,22 @@ fi
|
|||||||
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ ! "$2" =~ [:] ]] && [[ -z "$3" ]];then
|
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ ! "$2" =~ [:] ]] && [[ -z "$3" ]];then
|
||||||
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)
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -6 -e $1
|
fping -6 -e $1
|
||||||
if [[ -n $(nping -6 -q1 -c1 -p135 $1 | grep "Successful connections: 1") ]];then
|
rescue=$(nping -6 -q1 -c1 -p22,222 $1)
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(nping -6 -q1 -c1 -p22 $1 | 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
|
||||||
|
echo "note: this seems to be in the rescue system"
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
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
|
||||||
@ -180,14 +229,22 @@ fi
|
|||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
echo "checking connection status for $1"
|
echo "checking connection status for $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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $1
|
fping -e $1
|
||||||
if [[ -n $(nping -q1 -c1 -p135 $1 | grep "Successful connections: 1") ]];then
|
rescue=$(nping -q1 -c1 -p22,222 $1)
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(nping -q1 -c1 -p22 $1 | 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
|
||||||
|
echo "note: this seems to be in the rescue system"
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user