1
0
mirror of https://github.com/byReqz/conn.git synced 2024-10-31 16:53:14 +00:00
conn/conn.sh

110 lines
4.5 KiB
Bash
Raw Normal View History

#!/bin/bash
while [ ! -n "$1" ]; do
2021-01-16 01:43:55 +00:00
echo "Usage: $0 (options) <ip>"
echo "Options:"
echo " -m/--multi -- test multiple ips / disable portscan"
echo " -h/--help -- show help"
echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)"
echo " -y/--yes -- portscan without asking"
echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y"
2021-01-16 17:07:39 +00:00
echo " -w/--wait -- wait for active connection"
exit
done
while [ ! -z "$1" ]; do
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then
2021-01-16 01:43:55 +00:00
echo "Usage: $0 (options) <ip> (y/n)"
echo "Options:"
echo " -m/--multi -- test multiple ips / disable portscan"
echo " -h/--help -- show help"
2021-01-16 01:38:25 +00:00
echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)"
echo " -y/--yes -- portscan without asking"
echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y"
2021-01-16 17:07:39 +00:00
echo " -w/--wait -- wait for active connection"
exit
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
echo "multi-ip mode, portscan disabled"
echo "-------------------Availability----------------------"
2021-01-16 01:38:25 +00:00
fping -e $@
echo "-----------------------------------------------------"
exit
elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then
echo "checking connection status for $2"
echo "-------------------Availability----------------------"
2021-01-16 01:38:25 +00:00
fping -e $2
echo "-----------------------------------------------------"
echo "-------------------Portscan---------------------"
nmap -Pn $2
fping -c 4 -A $2
echo "------------------------------------------------"
exit
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
2021-01-16 01:38:25 +00:00
echo "checking connection status for $2"
echo "-------------------Availability----------------------"
fping -e $2
echo "-----------------------------------------------------"
exit
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
2021-01-16 01:38:25 +00:00
echo "-6 used, forcing IPv6 portscanning"
echo "checking connection status for $2"
echo "-------------------Availability----------------------"
fping -6 -e $2
echo "-----------------------------------------------------"
echo "-------------------Portscan---------------------"
nmap -Pn -6 $2
fping -6 -c 4 -A $2
echo "------------------------------------------------"
exit
2021-01-16 17:07:39 +00:00
elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then
echo "-w used, waiting for active connection"
echo "checking connection status for $2"
while [[ "$(fping -q -u $2)" == "$2" ]]; do :
done
notify-send "$2 is now reachable" -u normal -t 8000 -a conn
echo "-------------------Availability----------------------"
fping -e $2
echo "-----------------------------------------------------"
echo "portscan? (y/n) (default: y)"
read portscan
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
echo "-------------------Portscan---------------------"
nmap -Pn $2
fping -c 4 -A $2
echo "------------------------------------------------"
exit
elif [[ "$portscan" = "n" ]]; then
exit
fi
exit
2021-01-16 02:06:27 +00:00
#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
2021-01-16 01:38:25 +00:00
echo "noticed IPv6 adress -> using -6"
echo "checking connection status for $1"
echo "-------------------Availability----------------------"
fping -6 -e $1
echo "-----------------------------------------------------"
echo "-------------------Portscan---------------------"
nmap -Pn -6 $1
fping -6 -c 4 -A $1
echo "------------------------------------------------"
exit
else
echo "checking connection status for $1"
echo "-------------------Availability----------------------"
2021-01-16 01:38:25 +00:00
fping -e $1
echo "-----------------------------------------------------"
echo "portscan? (y/n) (default: y)"
read portscan
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
echo "-------------------Portscan---------------------"
nmap -Pn $1
fping -c 4 -A $1
echo "------------------------------------------------"
exit
elif [[ "$portscan" = "n" ]]; then
exit
fi
fi
done