1
0
mirror of https://github.com/byReqz/conn.git synced 2025-07-01 10:30:48 +00:00

Compare commits

..

12 Commits

Author SHA1 Message Date
faf77df3f6 updated hash after commit 2022-04-02 23:42:28 +00:00
4f62ddc933 fixup last commit 2022-04-03 01:41:56 +02:00
198d8beb91 updated hash after commit 2021-12-06 16:21:39 +00:00
f4b83b6896 remove hash 2021-12-06 17:21:14 +01:00
6e40823b90 quick fix for v6 adresses being rejected 2021-12-06 17:20:32 +01:00
44b684e721 add notion about old version 2021-12-05 12:47:00 +00:00
2d0c64ba2b Update README.md 2021-12-05 12:45:05 +00:00
21fd765ede Merge pull request #1 from byReqz/rewrite
Merge rewrite into main
2021-12-05 12:38:58 +00:00
d06b4c3ca0 updated hash after commit 2021-12-05 12:35:27 +00:00
190a85326c cleanup code and enable updater for merge 2021-12-05 13:34:44 +01:00
bce9576c2d optimize validate function 2021-12-04 00:17:18 +01:00
e68d8d52b2 make simplified output prettier 2021-11-30 13:35:43 +01:00
3 changed files with 70 additions and 67 deletions

View File

@ -1,32 +1,29 @@
# conn # conn
__the script is actively being rewritten on this branch and might not be on a usable state right now__
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>
@ -46,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
Reason: 998 conn-refused
PORT STATE SERVICE REASON PORT STATE SERVICE REASON
21/tcp open ftp syn-ack
22/tcp open ssh syn-ack 22/tcp open ssh syn-ack
631/tcp open ipp syn-ack 80/tcp open http syn-ack
Nmap done: 1 IP address (1 host up) scanned in 3.23 seconds 81/tcp closed hosts2-ns conn-refused
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
------------------------------------------------ ------------------------------------------------
``` ```

63
conn.sh
View File

@ -17,19 +17,6 @@ arguments:
-f / --fast disable os check -f / --fast disable os check
-s / --simple simplify output" -s / --simple simplify output"
show_notfound="[error] argument not found
available arguments:
-h / --help show help page (this)
-6 / --force-ipv6 force ipv6 portscanning (also forces portscanning)
-4 / --force-ipv4 force ipv4 portscanning (also forces portscanning)
-y / --yes portscan without asking
-n / --no dont portscan
-w / --wait wait for active connection
-u / --update update the script
-f / --fast disable os check
-s / --simple simplify output"
function check_update { function check_update {
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 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 "#############################################"
@ -55,7 +42,7 @@ function run_update {
} }
function prepare { function prepare {
#check_update check_update
get_args "$@" get_args "$@"
set_argvars $args set_argvars $args
validate $input validate $input
@ -68,18 +55,16 @@ function get_args {
input=$(echo "$input" | sed "s/$arg//g") input=$(echo "$input" | sed "s/$arg//g")
done done
# needs work #quick fix to prevent nslookups interactive mode being triggered by invalid arguments
# argcheck=$(echo $input | grep -o -e " -* " | xargs)
# echo $argcheck
# if [[ -n "$argcheck" ]];then
# for arg in $argcheck; do
# echo "the given argument \""$arg"\" is not known"
# done
# fi
#quick fix to prevent nslookups interactive mode being triggered by wrong arguments
#some other places in the code have also gotten a leading space to prevent similar issues #some other places in the code have also gotten a leading space to prevent similar issues
input=$(echo "$input" | tr -d "-") for v in $input; do
if [[ ! $(echo $v | cut -c1) == "-" ]];then
newinput="$newinput $v"
else
newinput="$newinput $(echo $v | cut -c 2-)"
fi
done
input="$newinput"
} }
function set_argvars { function set_argvars {
@ -108,9 +93,12 @@ function set_argvars {
function validate { function validate {
for arg in $@; do for arg in $@; do
if $(ip route show " $arg" 2&> /dev/null);then if [[ "$arg" =~ : ]];then
only="-6" # enable ipv6, this needs a more complex function to avoid treating every argument as v6
fi
if ip route show "$arg" 2&> /dev/null;then
hosts="$hosts $arg" hosts="$hosts $arg"
elif $(nslookup "$arg" > /dev/null);then elif nslookup "$arg" > /dev/null;then
hosts="$hosts $arg" hosts="$hosts $arg"
else else
echo "invalid input: $arg" echo "invalid input: $arg"
@ -122,10 +110,23 @@ function main {
if [[ $simpleoutput == true ]] && [[ -n $hosts ]];then if [[ $simpleoutput == true ]] && [[ -n $hosts ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping $only -e $@ fping $only -e $@
quickport=$(nping $only -c1 -p22,222,3389,135 $@ | grep -e "completed") if [[ $oscheck != "false" ]];then
if [[ -n $quickport ]];then
echo "" echo ""
echo "$quickport" for host in $@;do
linuxping=$(nping $only -c1 -p22,222 "$host")
if [[ -n $(echo "$linuxping" | grep -e "Successful connections: 1") ]];then
echo "$host seems to be booted into a Linux system"
elif [[ -n $(echo "$linuxping" | grep -e "Successful connections: 2") ]];then
echo "$host seems to be booted into the rescue system"
fi
winping135=$(nping $only -c1 -p135 "$host")
winping3389=$(nping $only -c1 -p3389 "$host")
if [[ -n $(echo "$winping135" | grep -e "Successful connections: 1") ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
echo "$host seems to be booted into Windows"
elif [[ -z $(fping $only -a $host) ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
echo "$host seems to be booted into (desktop) Windows"
fi
done
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
else else
@ -233,6 +234,6 @@ elif [[ "$1" == "-h" ]];then
check_update check_update
echo "$show_help" echo "$show_help"
else else
#check_update check_update
echo "$show_help" echo "$show_help"
fi fi

2
hash
View File

@ -1 +1 @@
5b070b9e7adbdc0b30d6feeae8db6d24 03ef6d9fd9c11b849ada616caf66bf22