mirror of
https://github.com/byReqz/conn.git
synced 2024-11-01 01:03:14 +00:00
Compare commits
16 Commits
21b83509a8
...
44b684e721
Author | SHA1 | Date | |
---|---|---|---|
|
44b684e721 | ||
|
2d0c64ba2b | ||
|
21fd765ede | ||
|
d06b4c3ca0 | ||
|
190a85326c | ||
|
bce9576c2d | ||
|
e68d8d52b2 | ||
|
236930bc73 | ||
|
c9de29f3ec | ||
|
97db5c1fb9 | ||
|
def8538bac | ||
|
768479ca2f | ||
|
acd564445e | ||
|
260bd37608 | ||
|
cb324fe66c | ||
|
fbd0ce0d7c |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
hash
|
hash
|
||||||
|
*.note
|
||||||
|
69
README.md
69
README.md
@ -1,29 +1,29 @@
|
|||||||
# conn
|
# conn
|
||||||
|
|
||||||
quick and dirty server availability check <br> <br>
|
quick and dirty server availability check <br> <br>
|
||||||
basically just a way too complex wrapper for nmap and fping <br>
|
basically just a way too complex wrapper for nmap and fping <br>
|
||||||
|
the pre-rewrite version is available as conn.sh.old and is no longer maintained <br>
|
||||||
|
|
||||||
### features:
|
### features:
|
||||||
- multi-input detection
|
- ~~multi-input detection~~ (not needed anymore since the rewrite)
|
||||||
- ipv4 input detection
|
- ~~ipv4 input detection~~ (not needed anymore since the rewrite)
|
||||||
- ipv6 input detection
|
- ~~ipv6 input detection~~ (not needed anymore since the rewrite)
|
||||||
- waiting for availability
|
- waiting for availability
|
||||||
- send notification on availability
|
- send notification on availability
|
||||||
- updater built in
|
- updater built in
|
||||||
|
|
||||||
# usage
|
# usage
|
||||||
Usage: conn (options) [ip] <br>
|
Usage: conn <args> [IP(s)/hostname(s)] <br>
|
||||||
Options: <br>
|
Options: <br>
|
||||||
-m/--multi -- test multiple ips / disable portscan <br>
|
-h / --help show help page (this) <br>
|
||||||
-h/--help -- show help <br>
|
-6 / --force-ipv6 force ipv6 portscanning (also forces portscanning) <br>
|
||||||
-6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning) <br>
|
-4 / --force-ipv4 force ipv4 portscanning (also forces portscanning) <br>
|
||||||
-4/--force-ipv4 -- force ipv4 portscanning (also forces portscanning) <br>
|
-y / --yes portscan without asking <br>
|
||||||
-y/--yes -- portscan without asking <br>
|
-n / --no dont portscan <br>
|
||||||
-n/--no -- dont portscan <br>
|
-w / --wait wait for active connection <br>
|
||||||
-p/--portscan -- same as -y <br>
|
-u / --update update the script <br>
|
||||||
-w/--wait -- wait for active connection <br>
|
-f / --fast disable os check <br>
|
||||||
-u/--update -- update the script <br>
|
-s / --simple simplify output <br>
|
||||||
-f/ --fast -- disable os check <br>
|
|
||||||
-s/ --simple -- same as -f <br>
|
|
||||||
|
|
||||||
# installation
|
# installation
|
||||||
1. download the script: <br>
|
1. download the script: <br>
|
||||||
@ -43,28 +43,33 @@ chmod +x conn.sh && ./conn.sh
|
|||||||
|
|
||||||
# sample output
|
# sample output
|
||||||
```bash
|
```bash
|
||||||
checking connection status for localhost
|
./conn.sh nils.lol
|
||||||
|
checking connection status for nils.lol
|
||||||
-------------------Availability----------------------
|
-------------------Availability----------------------
|
||||||
localhost is alive (545 ms)
|
nils.lol is alive (35.5 ms)
|
||||||
note: this seems to be a linux machine
|
note: this seems to be a linux machine
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
portscan? (y/n) (default: y)
|
||||||
|
|
||||||
-------------------Portscan---------------------
|
-------------------Portscan---------------------
|
||||||
Starting Nmap 7.91 ( https://nmap.org ) at 2021-02-15 15:07 CET
|
Starting Nmap 7.92 ( https://nmap.org ) at 2021-12-05 13:42 CET
|
||||||
Nmap scan report for localhost (127.0.0.1)
|
Nmap scan report for nils.lol (168.119.185.158)
|
||||||
Host is up, received user-set (0.047s latency).
|
Host is up, received user-set (0.048s latency).
|
||||||
Other addresses for localhost (not scanned): ::1
|
Not shown: 995 filtered tcp ports (no-response)
|
||||||
Not shown: 998 closed ports
|
PORT STATE SERVICE REASON
|
||||||
Reason: 998 conn-refused
|
21/tcp open ftp syn-ack
|
||||||
PORT STATE SERVICE REASON
|
22/tcp open ssh syn-ack
|
||||||
22/tcp open ssh syn-ack
|
80/tcp open http syn-ack
|
||||||
631/tcp open ipp syn-ack
|
81/tcp closed hosts2-ns conn-refused
|
||||||
Nmap done: 1 IP address (1 host up) scanned in 3.23 seconds
|
443/tcp open https syn-ack
|
||||||
|
|
||||||
localhost : [0], 64 bytes, 0.185 ms (0.185 avg, 0% loss)
|
Nmap done: 1 IP address (1 host up) scanned in 5.54 seconds
|
||||||
localhost : [1], 64 bytes, 0.058 ms (0.122 avg, 0% loss)
|
|
||||||
localhost : [2], 64 bytes, 0.060 ms (0.101 avg, 0% loss)
|
|
||||||
localhost : [3], 64 bytes, 0.081 ms (0.096 avg, 0% loss)
|
|
||||||
|
|
||||||
localhost : xmt/rcv/%loss = 4/4/0%, min/avg/max = 0.058/0.096/0.185
|
nils.lol : [0], 64 bytes, 36.5 ms (36.5 avg, 0% loss)
|
||||||
|
nils.lol : [1], 64 bytes, 35.7 ms (36.1 avg, 0% loss)
|
||||||
|
nils.lol : [2], 64 bytes, 34.7 ms (35.6 avg, 0% loss)
|
||||||
|
nils.lol : [3], 64 bytes, 33.5 ms (35.1 avg, 0% loss)
|
||||||
|
|
||||||
|
nils.lol : xmt/rcv/%loss = 4/4/0%, min/avg/max = 33.5/35.1/36.5
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
```
|
```
|
||||||
|
666
conn.sh
666
conn.sh
@ -1,457 +1,229 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# license: gpl-3
|
# license: gpl-3
|
||||||
|
|
||||||
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ -z $1 ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "--update" ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "-u" ]];then
|
show_help="conn: a quick and dirty server availability check
|
||||||
echo "#############################################"
|
|
||||||
echo -e "\e[4mnote: newer version detected, use -u to update\e[0m"
|
usage:
|
||||||
echo "#############################################"
|
"$0" <args> [IP(s)/hostname(s)]
|
||||||
echo ""
|
|
||||||
fi
|
arguments:
|
||||||
while [ ! -n "$1" ]; do
|
-h / --help show help page (this)
|
||||||
echo "Usage: $0 (options) <ip>"
|
-6 / --force-ipv6 force ipv6 portscanning (also forces portscanning)
|
||||||
echo "Options:"
|
-4 / --force-ipv4 force ipv4 portscanning (also forces portscanning)
|
||||||
echo " -m/--multi -- test multiple ips / disable portscan"
|
-y / --yes portscan without asking
|
||||||
echo " -h/--help -- show help"
|
-n / --no dont portscan
|
||||||
echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)"
|
-w / --wait wait for active connection
|
||||||
echo " -4/--force-ipv4 -- force ipv4 portscanning (also forces portscanning)"
|
-u / --update update the script
|
||||||
echo " -y/--yes -- portscan without asking"
|
-f / --fast disable os check
|
||||||
echo " -n/--no -- dont portscan"
|
-s / --simple simplify output"
|
||||||
echo " -p/--portscan -- same as -y"
|
|
||||||
echo " -w/--wait -- wait for active connection"
|
function check_update {
|
||||||
echo " -u/--update -- update the script to the newest version"
|
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ -z $1 ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "--update" ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "-u" ]];then
|
||||||
echo " -f/ --fast -- disable os check"
|
echo "#############################################"
|
||||||
echo " -s/ --simple -- same as -f"
|
echo -e "\e[4mnote: newer version detected, use -u to update\e[0m"
|
||||||
echo " -ww/ --wait-windows -- same as -w but for windows machines"
|
echo "#############################################"
|
||||||
echo " -ht/ --http -- ping on port 80"
|
echo ""
|
||||||
echo " -wh/ --wait-http -- wait for ping on port 80"
|
fi
|
||||||
exit
|
}
|
||||||
done
|
|
||||||
while [ ! -z "$1" ]; do
|
function run_update {
|
||||||
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then
|
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]];then
|
||||||
echo "Usage: $0 (options) <ip> (y/n)"
|
wget -O $0 --quiet "https://raw.githubusercontent.com/byReqz/conn/main/conn.sh"
|
||||||
echo "Options:"
|
echo "#############################################"
|
||||||
echo " -m/--multi -- test multiple ips / disable portscan"
|
echo -e "\e[4mscript has been updated to the newest version\e[0m"
|
||||||
echo " -h/--help -- show help"
|
echo "#############################################"
|
||||||
echo " -6/--force-ipv6 -- force ipv6 portscanning (also forces portscanning)"
|
exit
|
||||||
echo " -4/--force-ipv4 -- force ipv4 portscanning (also forces portscanning)"
|
elif [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) = $(md5sum $0 | cut -c -32) ]];then
|
||||||
echo " -y/--yes -- portscan without asking"
|
echo "#############################################"
|
||||||
echo " -n/--no -- dont portscan"
|
echo "no newer version found"
|
||||||
echo " -p/--portscan -- same as -y"
|
echo "#############################################"
|
||||||
echo " -w/--wait -- wait for active connection"
|
exit
|
||||||
echo " -u/--update -- update the script to the newest version"
|
fi
|
||||||
echo " -f/ --fast -- disable os check"
|
}
|
||||||
echo " -s/ --simple -- same as -f"
|
|
||||||
echo " -ww/ --wait-windows -- same as -w but for windows machines"
|
function prepare {
|
||||||
echo " -ht/ --http -- ping on port 80"
|
check_update
|
||||||
echo " -wh/ --wait-http -- wait for ping on port 80"
|
get_args "$@"
|
||||||
exit
|
set_argvars $args
|
||||||
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
|
validate $input
|
||||||
echo "multi-ip mode, shorter portscan enabled"
|
}
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
shift
|
function get_args {
|
||||||
fping -e $@
|
input=$(echo " $@")
|
||||||
echo ""
|
args=$(echo "$input" | grep -o -e "-h" -e "--help" -e "-6" -e "--force-ipv6" -e "-4" -e "--force-ipv4" -e "-y" -e "--yes" -e "-n" -e "--no" -e "-w" -e "--wait" -e "-u" -e "--update" -e "-f" -e "--fast" -e "-s" -e "--simple" | xargs)
|
||||||
nping -c1 -p22,222,3389,135 $@ | grep -e "completed"
|
for arg in $args; do
|
||||||
echo "-----------------------------------------------------"
|
input=$(echo "$input" | sed "s/$arg//g")
|
||||||
exit
|
done
|
||||||
elif [[ $1 == "-f" ]] || [[ "$1" == "--fast" ]] || [[ $1 == "-s" ]] || [[ "$1" == "--simple" ]];then
|
|
||||||
echo "$1 used, skipping os check"
|
#quick fix to prevent nslookups interactive mode being triggered by invalid arguments
|
||||||
echo "checking connection status for $2"
|
#some other places in the code have also gotten a leading space to prevent similar issues
|
||||||
echo "-------------------Availability----------------------"
|
input=$(echo "$input" | tr -d "-")
|
||||||
fping -e $2
|
}
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
echo "-------------------Portscan---------------------"
|
function set_argvars {
|
||||||
nmap --reason -Pn $2
|
if [[ $@ =~ -6 ]] || [[ $@ =~ --force-ipv6 ]];then
|
||||||
echo ""
|
only="-6"
|
||||||
fping -c 4 $2
|
fi
|
||||||
echo "------------------------------------------------"
|
if [[ $@ =~ -4 ]] || [[ $@ =~ --force-ipv4 ]];then
|
||||||
exit
|
only="-4"
|
||||||
elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then
|
fi
|
||||||
echo "checking connection status for $2"
|
if [[ $@ =~ -y ]] || [[ $@ =~ --yes ]];then
|
||||||
fping=$(fping -a $2)
|
doportscan=true
|
||||||
p135=$(nping -q1 -c1 -p135 $2)
|
fi
|
||||||
p3389=$(nping -q1 -c1 -p3389 $2)
|
if [[ $@ =~ -n ]] || [[ $@ =~ --no ]];then
|
||||||
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
doportscan=false
|
||||||
echo "-------------------Availability----------------------"
|
fi
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ $@ =~ -s ]] || [[ $@ =~ --simple ]];then
|
||||||
echo "-----------------------------------------------------"
|
simpleoutput=true
|
||||||
elif [[ $fping != "$2" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
if [[ $@ =~ -w ]] || [[ $@ =~ --wait ]];then
|
||||||
echo "$2 is not reachable"
|
waitcheck=true
|
||||||
echo "-----------------------------------------------------"
|
fi
|
||||||
else
|
if [[ $@ =~ -f ]] || [[ $@ =~ --fast ]];then
|
||||||
echo "-------------------Availability----------------------"
|
oscheck=false
|
||||||
fping -e $2
|
fi
|
||||||
rescue=$(nping -q1 -c1 -p22,222 $2)
|
}
|
||||||
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this seems to be a linux machine"
|
function validate {
|
||||||
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
for arg in $@; do
|
||||||
echo "note: this machine seems to be in the rescue system"
|
if ip route show " $arg" 2&> /dev/null;then
|
||||||
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
hosts="$hosts $arg"
|
||||||
echo "note: this machine seems to be booted into windows"
|
elif nslookup "$arg" > /dev/null;then
|
||||||
fi
|
hosts="$hosts $arg"
|
||||||
echo "-----------------------------------------------------"
|
else
|
||||||
fi
|
echo "invalid input: $arg"
|
||||||
echo "-------------------Portscan---------------------"
|
fi
|
||||||
nmap --reason -Pn $2
|
done
|
||||||
echo ""
|
}
|
||||||
fping -c 4 $2
|
|
||||||
echo "------------------------------------------------"
|
function main {
|
||||||
exit
|
if [[ $simpleoutput == true ]] && [[ -n $hosts ]];then
|
||||||
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
|
echo "-------------------Availability----------------------"
|
||||||
fping=$(fping -a $2)
|
fping $only -e $@
|
||||||
p135=$(nping -q1 -c1 -p135 $2)
|
if [[ $oscheck != "false" ]];then
|
||||||
p3389=$(nping -q1 -c1 -p3389 $2)
|
echo ""
|
||||||
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
for host in $@;do
|
||||||
echo "-------------------Availability----------------------"
|
linuxping=$(nping $only -c1 -p22,222 "$host")
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ -n $(echo "$linuxping" | grep -e "Successful connections: 1") ]];then
|
||||||
echo "-----------------------------------------------------"
|
echo "$host seems to be booted into a Linux system"
|
||||||
elif [[ $fping != "$2" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
|
elif [[ -n $(echo "$linuxping" | grep -e "Successful connections: 2") ]];then
|
||||||
echo "-------------------Availability----------------------"
|
echo "$host seems to be booted into the rescue system"
|
||||||
echo "$2 is not reachable"
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
else
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
fping -e $2
|
|
||||||
rescue=$(nping -q1 -c1 -p22,222 $2)
|
|
||||||
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this seems to be a linux machine"
|
|
||||||
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
|
||||||
echo "note: this machine seems to be in the rescue system"
|
|
||||||
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this machine seems to be booted into windows"
|
|
||||||
fi
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
fi
|
|
||||||
exit
|
|
||||||
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
|
|
||||||
echo "-6 used, forcing IPv6 portscanning"
|
|
||||||
if [[ "$2" =~ http ]];then
|
|
||||||
echo "url detected, exiting"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
echo "checking connection status for $2"
|
|
||||||
fping=$(fping -6 -a $2)
|
|
||||||
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
echo "note: this seems to be a windows machine which does respond to ICMP"
|
|
||||||
fping -e -6 $2
|
|
||||||
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
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
fping -6 -e $2
|
|
||||||
rescue=$(nping -6 -q1 -c1 -p22,222 $2)
|
|
||||||
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this seems to be a linux machine"
|
|
||||||
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
|
||||||
echo "note: this machine seems to be in the rescue system"
|
|
||||||
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this machine seems to be booted into windows"
|
|
||||||
fi
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
fi
|
|
||||||
echo "-------------------Portscan---------------------"
|
|
||||||
nmap --reason -Pn -6 $2
|
|
||||||
echo ""
|
|
||||||
fping -6 -c 4 $2
|
|
||||||
echo "------------------------------------------------"
|
|
||||||
exit
|
|
||||||
elif [[ $1 == "-4" ]] || [[ "$1" == "--force-ipv4" ]];then
|
|
||||||
echo "-4 used, forcing IPv4 portscanning"
|
|
||||||
echo "checking connection status for $2"
|
|
||||||
fping=$(fping -4 -a $2)
|
|
||||||
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
echo "note: this seems to be a windows machine which does respond to ICMP"
|
|
||||||
fping -e -4 $2
|
|
||||||
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
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
fping -4 -e $2
|
|
||||||
rescue=$(nping -4 -q1 -c1 -p22,222 $2)
|
|
||||||
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this seems to be a linux machine"
|
|
||||||
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
|
||||||
echo "note: this machine seems to be in the rescue system"
|
|
||||||
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this machine seems to be booted into windows"
|
|
||||||
fi
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
fi
|
|
||||||
echo "-------------------Portscan---------------------"
|
|
||||||
nmap -4 --reason -Pn $2
|
|
||||||
echo ""
|
|
||||||
fping -4 -c 4 $2
|
|
||||||
echo "------------------------------------------------"
|
|
||||||
exit
|
|
||||||
elif [[ $1 == "-u" ]] || [[ "$1" == "--update" ]];then
|
|
||||||
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]];then
|
|
||||||
wget -O $0 --quiet "https://raw.githubusercontent.com/byReqz/conn/main/conn.sh"
|
|
||||||
echo "#############################################"
|
|
||||||
echo -e "\e[4mscript has been updated to the newest version\e[0m"
|
|
||||||
echo "#############################################"
|
|
||||||
exit
|
|
||||||
elif [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) = $(md5sum $0 | cut -c -32) ]];then
|
|
||||||
echo "#############################################"
|
|
||||||
echo "no newer version found"
|
|
||||||
echo "#############################################"
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then
|
winping135=$(nping $only -c1 -p135 "$host")
|
||||||
echo "-w used, waiting for active connection"
|
winping3389=$(nping $only -c1 -p3389 "$host")
|
||||||
echo "checking connection status for $2"
|
if [[ -n $(echo "$winping135" | grep -e "Successful connections: 1") ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
|
||||||
fping=$(fping -a $2)
|
echo "$host seems to be booted into Windows"
|
||||||
p135=$(nping -q1 -c1 -p135 $2)
|
elif [[ -z $(fping $only -a $host) ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
|
||||||
p3389=$(nping -q1 -c1 -p3389 $2)
|
echo "$host seems to be booted into (desktop) Windows"
|
||||||
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
done
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
fi
|
||||||
notify-send "$2 is now reachable" "and seems to be a windows machine" -u normal -t 30000 -a conn
|
echo "-----------------------------------------------------"
|
||||||
echo "-----------------------------------------------------"
|
else
|
||||||
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
for host in $hosts;do
|
||||||
echo "-------------------Availability----------------------"
|
if [[ $waitcheck == true ]];then
|
||||||
echo "note: this seems to be a windows machine which does respond to ICMP"
|
echo "-w used, waiting for active connection"
|
||||||
fping -e $2
|
echo "checking connection status for $host"
|
||||||
notify-send "$2 is now reachable" "and seems to be a windows machine" -u normal -t 30000 -a conn
|
fping=$(fping $only -a $host)
|
||||||
echo "-----------------------------------------------------"
|
if [[ ! $oscheck == false ]];then
|
||||||
else
|
p135=$(nping $only -q1 -c1 -p135 $host)
|
||||||
while [[ "$(fping -m -q -u $2)" == "$2" ]]; do :
|
p3389=$(nping $only -q1 -c1 -p3389 $host)
|
||||||
done
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
if [[ $fping != "$host" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$host" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
fping -e $2
|
echo "-------------------Availability----------------------"
|
||||||
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 "$host is now reachable" "and seems to be a windows machine" -u normal -t 30000 -a conn
|
||||||
echo "note: this seems to be a linux machine"
|
echo "-----------------------------------------------------"
|
||||||
notify-send "$2 is now reachable" "and seems to be in a linux system" -u normal -t 30000 -a conn
|
elif [[ $fping = "$host" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
echo "-------------------Availability----------------------"
|
||||||
echo "note: this machine seems to be in the rescue system"
|
echo "note: this seems to be a windows machine which does respond to ICMP"
|
||||||
notify-send "$2 is now reachable" "and seems to be in the rescue system" -u normal -t 30000 -a conn
|
fping -e $host
|
||||||
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
notify-send "$host is now reachable" "and seems to be a windows machine" -u normal -t 30000 -a conn
|
||||||
echo "note: this machine seems to be booted into windows"
|
echo "-----------------------------------------------------"
|
||||||
notify-send "$2 is now reachable" "and seems to be booted into windows" -u normal -t 30000 -a conn
|
else
|
||||||
else
|
while [[ "$(fping $only -m -q -u $host)" == "$host" ]]; do :
|
||||||
notify-send "$2 is now reachable" -u normal -t 30000 -a conn
|
|
||||||
fi
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
fi
|
|
||||||
echo "portscan? (y/n) (default: y)"
|
|
||||||
read portscan
|
|
||||||
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
|
||||||
echo "-------------------Portscan---------------------"
|
|
||||||
nmap --reason -Pn $2
|
|
||||||
echo ""
|
|
||||||
fping -c 4 $2
|
|
||||||
echo "------------------------------------------------"
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
exit
|
|
||||||
elif [[ "$1" == "-ww" ]] || [[ "$1" == "--wait-windows" ]];then
|
|
||||||
echo "-w used, waiting for active connection"
|
|
||||||
echo "checking connection status for $2"
|
|
||||||
fping=$(fping -a $2)
|
|
||||||
p135=$(nping -q1 -c1 -p135 $2)
|
|
||||||
p3389=$(nping -q1 -c1 -p3389 $2)
|
|
||||||
if [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 0") ]];then
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
echo "note: this seems to be a unix machine which does respond to ICMP"
|
|
||||||
notify-send "$2 is a unix machine" -u normal -t 30000 -a conn
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
echo "note: this seems to be a windows machine which does respond to ICMP"
|
|
||||||
notify-send "$2 is a windows machine" -u normal -t 30000 -a conn
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
else
|
|
||||||
while [[ -z $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]]; do :
|
|
||||||
done
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
rescue=$(nping -q1 -c1 -p22,222 $2)
|
|
||||||
if [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
|
||||||
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 30000 -a conn
|
|
||||||
else
|
|
||||||
echo "$2 is now booted into windows"
|
|
||||||
notify-send "$2 is now booted into windows" -u normal -t 30000 -a conn
|
|
||||||
fi
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
fi
|
|
||||||
echo "portscan? (y/n) (default: y)"
|
|
||||||
read portscan
|
|
||||||
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
|
||||||
echo "-------------------Portscan---------------------"
|
|
||||||
nmap --reason -Pn $2
|
|
||||||
echo ""
|
|
||||||
fping -c 4 $2
|
|
||||||
echo "------------------------------------------------"
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
exit
|
|
||||||
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ ! "$2" =~ [:] ]] && [[ -z "$3" ]];then
|
|
||||||
if [[ "$1" =~ http ]];then
|
|
||||||
echo "url detected, exiting"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
echo "detected IPv6 adress -> using -6"
|
|
||||||
echo "checking connection status for $1"
|
|
||||||
fping=$(fping -6 -a $1)
|
|
||||||
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
|
||||||
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
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
fping -6 -e $1
|
|
||||||
rescue=$(nping -6 -q1 -c1 -p22,222 $1)
|
|
||||||
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this seems to be a linux machine"
|
|
||||||
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
|
||||||
echo "note: this machine seems to be in the rescue system"
|
|
||||||
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
|
||||||
echo "note: this machine seems to be booted into windows"
|
|
||||||
fi
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
fi
|
|
||||||
echo "portscan? (y/n) (default: y)"
|
|
||||||
read portscan
|
|
||||||
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
|
||||||
echo "-------------------Portscan---------------------"
|
|
||||||
nmap --reason -Pn -6 $1
|
|
||||||
echo ""
|
|
||||||
fping -6 -c 4 $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, shorter portscan enabled"
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
fping -e $@
|
|
||||||
echo ""
|
|
||||||
nping -c1 -p22,222,3389,135 $@ | grep -e "completed"
|
|
||||||
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" =~ [-] ]] && [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ ! "$2" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ "$2" =~ [:] ]];then
|
|
||||||
echo "multi-ipv6 input detected, shorter portscan enabled"
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
fping -e -6 $@
|
|
||||||
echo ""
|
|
||||||
nping -6 -c1 -p22,222,3389,135 $@ | grep -e "completed"
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
exit
|
|
||||||
elif [[ "$1" == "-ht" ]] || [[ "$1" == "--http" ]];then
|
|
||||||
echo "checking connection status for $2"
|
|
||||||
fping=$(nping -c1 -p80 $2)
|
|
||||||
if [[ -n $(echo $fping | grep "Successful connections: 1") ]];then
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
echo "$2 is reachable via port 80"
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
else
|
|
||||||
echo "-------------------Availability----------------------"
|
|
||||||
echo "$2 is not reachable via port 80"
|
|
||||||
echo "-----------------------------------------------------"
|
|
||||||
fi
|
|
||||||
echo "portscan? (y/n) (default: y)"
|
|
||||||
read portscan
|
|
||||||
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
|
||||||
echo "-------------------Portscan---------------------"
|
|
||||||
nmap --reason -Pn $2
|
|
||||||
echo ""
|
|
||||||
nping -c4 -p80 $2
|
|
||||||
echo "------------------------------------------------"
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
elif [[ "$1" == "-wh" ]] || [[ "$1" == "--wait-http" ]];then
|
|
||||||
echo "-wh used, waiting for active connection"
|
|
||||||
echo "checking connection status for $2"
|
|
||||||
while [[ -z $(nping -c1 -p80 $2 | grep -e "Successful connections: 1") ]]; do :
|
|
||||||
done
|
done
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
echo "$2 is now reachable via port 80"
|
fping -e $host
|
||||||
notify-send "$2 is now reachable via port 80" -u normal -t 30000 -a conn
|
if [[ ! $oscheck == false ]];then
|
||||||
echo "-----------------------------------------------------"
|
rescue=$(nping $only -q1 -c1 -p22,222 $host)
|
||||||
echo "portscan? (y/n) (default: y)"
|
fi
|
||||||
read portscan
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
echo "note: this seems to be a linux machine"
|
||||||
echo "-------------------Portscan---------------------"
|
notify-send "$host is now reachable" "and seems to be in a linux system" -u normal -t 30000 -a conn
|
||||||
nmap --reason -Pn $2
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
echo ""
|
echo "note: this machine seems to be in the rescue system"
|
||||||
nping -c4 -p80 $2
|
notify-send "$host is now reachable" "and seems to be in the rescue system" -u normal -t 30000 -a conn
|
||||||
echo "------------------------------------------------"
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
exit
|
echo "note: this machine seems to be booted into windows"
|
||||||
else
|
notify-send "$host is now reachable" "and seems to be booted into windows" -u normal -t 30000 -a conn
|
||||||
exit
|
else
|
||||||
fi
|
notify-send "$host is now reachable" -u normal -t 30000 -a conn
|
||||||
exit
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "checking connection status for $1"
|
echo "checking connection status for $host"
|
||||||
fping=$(fping -a $1)
|
fping=$(fping $only -a $host)
|
||||||
p135=$(nping -q1 -c1 -p135 $1)
|
if [[ ! $oscheck == false ]];then
|
||||||
p3389=$(nping -q1 -c1 -p3389 $1)
|
p135=$(nping $only -q1 -c1 -p135 $host)
|
||||||
if [[ $fping != "$1" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$1" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
p3389=$(nping $only -q1 -c1 -p3389 $host)
|
||||||
echo "-------------------Availability----------------------"
|
fi
|
||||||
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
if [[ $fping != "$host" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$host" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
echo "-----------------------------------------------------"
|
echo "-------------------Availability----------------------"
|
||||||
elif [[ $fping != "$1" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$1" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
|
echo "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
echo "-------------------Availability----------------------"
|
echo "-----------------------------------------------------"
|
||||||
echo "$1 is not reachable"
|
elif [[ $fping != "$host" ]] && [[ -z $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$host" ]] && [[ -z $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
echo "-----------------------------------------------------"
|
echo "-------------------Availability----------------------"
|
||||||
else
|
echo "$host is not reachable"
|
||||||
echo "-------------------Availability----------------------"
|
echo "-----------------------------------------------------"
|
||||||
fping -e $1
|
else
|
||||||
rescue=$(nping -q1 -c1 -p22,222 $1)
|
echo "-------------------Availability----------------------"
|
||||||
|
fping $only -e $host
|
||||||
|
if [[ ! $oscheck == false ]];then
|
||||||
|
rescue=$(nping $only -q1 -c1 -p22,222 $host)
|
||||||
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 machine seems to be in the rescue system"
|
echo "note: this machine seems to be in the rescue system"
|
||||||
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
echo "note: this machine seems to be booted into windows"
|
echo "note: this machine seems to be booted into windows"
|
||||||
fi
|
fi
|
||||||
echo "-----------------------------------------------------"
|
fi
|
||||||
fi
|
echo "-----------------------------------------------------"
|
||||||
echo "portscan? (y/n) (default: y)"
|
fi
|
||||||
read portscan
|
fi
|
||||||
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
if [[ ! $doportscan == false ]];then
|
||||||
echo "-------------------Portscan---------------------"
|
if [[ $doportscan == true ]];then
|
||||||
nmap --reason -Pn $1
|
portscan=y
|
||||||
echo ""
|
else
|
||||||
fping -c 4 $1
|
echo "portscan? (y/n) (default: y)"
|
||||||
echo "------------------------------------------------"
|
read portscan
|
||||||
exit
|
fi
|
||||||
else
|
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
||||||
exit
|
echo "-------------------Portscan---------------------"
|
||||||
fi
|
nmap $only --reason -Pn $host
|
||||||
fi
|
echo ""
|
||||||
done
|
fping $only -c 4 $host
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n $1 ]];then
|
||||||
|
prepare "$@"
|
||||||
|
main "$hosts"
|
||||||
|
elif [[ "$1" == "-u" ]];then
|
||||||
|
run_update
|
||||||
|
elif [[ "$1" == "-h" ]];then
|
||||||
|
check_update
|
||||||
|
echo "$show_help"
|
||||||
|
else
|
||||||
|
check_update
|
||||||
|
echo "$show_help"
|
||||||
|
fi
|
||||||
|
457
conn.sh.old
Executable file
457
conn.sh.old
Executable file
@ -0,0 +1,457 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# license: gpl-3
|
||||||
|
|
||||||
|
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ -z $1 ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "--update" ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]] && [[ $1 != "-u" ]];then
|
||||||
|
echo "#############################################"
|
||||||
|
echo -e "\e[4mnote: newer version detected, use -u to update\e[0m"
|
||||||
|
echo "#############################################"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
while [ ! -n "$1" ]; do
|
||||||
|
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 " -4/--force-ipv4 -- force ipv4 portscanning (also forces portscanning)"
|
||||||
|
echo " -y/--yes -- portscan without asking"
|
||||||
|
echo " -n/--no -- dont portscan"
|
||||||
|
echo " -p/--portscan -- same as -y"
|
||||||
|
echo " -w/--wait -- wait for active connection"
|
||||||
|
echo " -u/--update -- update the script to the newest version"
|
||||||
|
echo " -f/ --fast -- disable os check"
|
||||||
|
echo " -s/ --simple -- same as -f"
|
||||||
|
echo " -ww/ --wait-windows -- same as -w but for windows machines"
|
||||||
|
echo " -ht/ --http -- ping on port 80"
|
||||||
|
echo " -wh/ --wait-http -- wait for ping on port 80"
|
||||||
|
exit
|
||||||
|
done
|
||||||
|
while [ ! -z "$1" ]; do
|
||||||
|
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then
|
||||||
|
echo "Usage: $0 (options) <ip> (y/n)"
|
||||||
|
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 " -4/--force-ipv4 -- force ipv4 portscanning (also forces portscanning)"
|
||||||
|
echo " -y/--yes -- portscan without asking"
|
||||||
|
echo " -n/--no -- dont portscan"
|
||||||
|
echo " -p/--portscan -- same as -y"
|
||||||
|
echo " -w/--wait -- wait for active connection"
|
||||||
|
echo " -u/--update -- update the script to the newest version"
|
||||||
|
echo " -f/ --fast -- disable os check"
|
||||||
|
echo " -s/ --simple -- same as -f"
|
||||||
|
echo " -ww/ --wait-windows -- same as -w but for windows machines"
|
||||||
|
echo " -ht/ --http -- ping on port 80"
|
||||||
|
echo " -wh/ --wait-http -- wait for ping on port 80"
|
||||||
|
exit
|
||||||
|
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
|
||||||
|
echo "multi-ip mode, shorter portscan enabled"
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
shift
|
||||||
|
fping -e $@
|
||||||
|
echo ""
|
||||||
|
nping -c1 -p22,222,3389,135 $@ | grep -e "completed"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
exit
|
||||||
|
elif [[ $1 == "-f" ]] || [[ "$1" == "--fast" ]] || [[ $1 == "-s" ]] || [[ "$1" == "--simple" ]];then
|
||||||
|
echo "$1 used, skipping os check"
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -e $2
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn $2
|
||||||
|
echo ""
|
||||||
|
fping -c 4 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
fping=$(fping -a $2)
|
||||||
|
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -e $2
|
||||||
|
rescue=$(nping -q1 -c1 -p22,222 $2)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this seems to be a linux machine"
|
||||||
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
echo "note: this machine seems to be in the rescue system"
|
||||||
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this machine seems to be booted into windows"
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn $2
|
||||||
|
echo ""
|
||||||
|
fping -c 4 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
|
||||||
|
fping=$(fping -a $2)
|
||||||
|
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -e $2
|
||||||
|
rescue=$(nping -q1 -c1 -p22,222 $2)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this seems to be a linux machine"
|
||||||
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
echo "note: this machine seems to be in the rescue system"
|
||||||
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this machine seems to be booted into windows"
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
|
||||||
|
echo "-6 used, forcing IPv6 portscanning"
|
||||||
|
if [[ "$2" =~ http ]];then
|
||||||
|
echo "url detected, exiting"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
fping=$(fping -6 -a $2)
|
||||||
|
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does respond to ICMP"
|
||||||
|
fping -e -6 $2
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -6 -e $2
|
||||||
|
rescue=$(nping -6 -q1 -c1 -p22,222 $2)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this seems to be a linux machine"
|
||||||
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
echo "note: this machine seems to be in the rescue system"
|
||||||
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this machine seems to be booted into windows"
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn -6 $2
|
||||||
|
echo ""
|
||||||
|
fping -6 -c 4 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
elif [[ $1 == "-4" ]] || [[ "$1" == "--force-ipv4" ]];then
|
||||||
|
echo "-4 used, forcing IPv4 portscanning"
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
fping=$(fping -4 -a $2)
|
||||||
|
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does respond to ICMP"
|
||||||
|
fping -e -4 $2
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -4 -e $2
|
||||||
|
rescue=$(nping -4 -q1 -c1 -p22,222 $2)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this seems to be a linux machine"
|
||||||
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
echo "note: this machine seems to be in the rescue system"
|
||||||
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this machine seems to be booted into windows"
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap -4 --reason -Pn $2
|
||||||
|
echo ""
|
||||||
|
fping -4 -c 4 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
elif [[ $1 == "-u" ]] || [[ "$1" == "--update" ]];then
|
||||||
|
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) != $(md5sum $0 | cut -c -32) ]];then
|
||||||
|
wget -O $0 --quiet "https://raw.githubusercontent.com/byReqz/conn/main/conn.sh"
|
||||||
|
echo "#############################################"
|
||||||
|
echo -e "\e[4mscript has been updated to the newest version\e[0m"
|
||||||
|
echo "#############################################"
|
||||||
|
exit
|
||||||
|
elif [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/hash) = $(md5sum $0 | cut -c -32) ]];then
|
||||||
|
echo "#############################################"
|
||||||
|
echo "no newer version found"
|
||||||
|
echo "#############################################"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then
|
||||||
|
echo "-w used, waiting for active connection"
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
fping=$(fping -a $2)
|
||||||
|
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 "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 30000 -a conn
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does respond to ICMP"
|
||||||
|
fping -e $2
|
||||||
|
notify-send "$2 is now reachable" "and seems to be a windows machine" -u normal -t 30000 -a conn
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
|
while [[ "$(fping -m -q -u $2)" == "$2" ]]; do :
|
||||||
|
done
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -e $2
|
||||||
|
rescue=$(nping -q1 -c1 -p22,222 $2)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
|
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 30000 -a conn
|
||||||
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
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 30000 -a conn
|
||||||
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this machine seems to be booted into windows"
|
||||||
|
notify-send "$2 is now reachable" "and seems to be booted into windows" -u normal -t 30000 -a conn
|
||||||
|
else
|
||||||
|
notify-send "$2 is now reachable" -u normal -t 30000 -a conn
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "portscan? (y/n) (default: y)"
|
||||||
|
read portscan
|
||||||
|
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn $2
|
||||||
|
echo ""
|
||||||
|
fping -c 4 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
elif [[ "$1" == "-ww" ]] || [[ "$1" == "--wait-windows" ]];then
|
||||||
|
echo "-w used, waiting for active connection"
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
fping=$(fping -a $2)
|
||||||
|
p135=$(nping -q1 -c1 -p135 $2)
|
||||||
|
p3389=$(nping -q1 -c1 -p3389 $2)
|
||||||
|
if [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 0") ]];then
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a unix machine which does respond to ICMP"
|
||||||
|
notify-send "$2 is a unix machine" -u normal -t 30000 -a conn
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
elif [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "note: this seems to be a windows machine which does respond to ICMP"
|
||||||
|
notify-send "$2 is a windows machine" -u normal -t 30000 -a conn
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
|
while [[ -z $(nping -q1 -c1 -p135 $2 | grep "Successful connections: 1") ]]; do :
|
||||||
|
done
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
rescue=$(nping -q1 -c1 -p22,222 $2)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
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 30000 -a conn
|
||||||
|
else
|
||||||
|
echo "$2 is now booted into windows"
|
||||||
|
notify-send "$2 is now booted into windows" -u normal -t 30000 -a conn
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "portscan? (y/n) (default: y)"
|
||||||
|
read portscan
|
||||||
|
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn $2
|
||||||
|
echo ""
|
||||||
|
fping -c 4 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ ! "$2" =~ [:] ]] && [[ -z "$3" ]];then
|
||||||
|
if [[ "$1" =~ http ]];then
|
||||||
|
echo "url detected, exiting"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "detected IPv6 adress -> using -6"
|
||||||
|
echo "checking connection status for $1"
|
||||||
|
fping=$(fping -6 -a $1)
|
||||||
|
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -6 -e $1
|
||||||
|
rescue=$(nping -6 -q1 -c1 -p22,222 $1)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this seems to be a linux machine"
|
||||||
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
echo "note: this machine seems to be in the rescue system"
|
||||||
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this machine seems to be booted into windows"
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "portscan? (y/n) (default: y)"
|
||||||
|
read portscan
|
||||||
|
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn -6 $1
|
||||||
|
echo ""
|
||||||
|
fping -6 -c 4 $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, shorter portscan enabled"
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -e $@
|
||||||
|
echo ""
|
||||||
|
nping -c1 -p22,222,3389,135 $@ | grep -e "completed"
|
||||||
|
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" =~ [-] ]] && [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ ! "$2" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ "$2" =~ [:] ]];then
|
||||||
|
echo "multi-ipv6 input detected, shorter portscan enabled"
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -e -6 $@
|
||||||
|
echo ""
|
||||||
|
nping -6 -c1 -p22,222,3389,135 $@ | grep -e "completed"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
exit
|
||||||
|
elif [[ "$1" == "-ht" ]] || [[ "$1" == "--http" ]];then
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
fping=$(nping -c1 -p80 $2)
|
||||||
|
if [[ -n $(echo $fping | grep "Successful connections: 1") ]];then
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "$2 is reachable via port 80"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
else
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "$2 is not reachable via port 80"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "portscan? (y/n) (default: y)"
|
||||||
|
read portscan
|
||||||
|
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn $2
|
||||||
|
echo ""
|
||||||
|
nping -c4 -p80 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
elif [[ "$1" == "-wh" ]] || [[ "$1" == "--wait-http" ]];then
|
||||||
|
echo "-wh used, waiting for active connection"
|
||||||
|
echo "checking connection status for $2"
|
||||||
|
while [[ -z $(nping -c1 -p80 $2 | grep -e "Successful connections: 1") ]]; do :
|
||||||
|
done
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
echo "$2 is now reachable via port 80"
|
||||||
|
notify-send "$2 is now reachable via port 80" -u normal -t 30000 -a conn
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo "portscan? (y/n) (default: y)"
|
||||||
|
read portscan
|
||||||
|
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn $2
|
||||||
|
echo ""
|
||||||
|
nping -c4 -p80 $2
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
echo "checking connection status for $1"
|
||||||
|
fping=$(fping -a $1)
|
||||||
|
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 "note: this seems to be a windows machine which does not respond to ICMP"
|
||||||
|
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
|
||||||
|
echo "-------------------Availability----------------------"
|
||||||
|
fping -e $1
|
||||||
|
rescue=$(nping -q1 -c1 -p22,222 $1)
|
||||||
|
if [[ -n $(echo $rescue | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this seems to be a linux machine"
|
||||||
|
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
|
||||||
|
echo "note: this machine seems to be in the rescue system"
|
||||||
|
elif [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then
|
||||||
|
echo "note: this machine seems to be booted into windows"
|
||||||
|
fi
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
fi
|
||||||
|
echo "portscan? (y/n) (default: y)"
|
||||||
|
read portscan
|
||||||
|
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
|
||||||
|
echo "-------------------Portscan---------------------"
|
||||||
|
nmap --reason -Pn $1
|
||||||
|
echo ""
|
||||||
|
fping -c 4 $1
|
||||||
|
echo "------------------------------------------------"
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user