mirror of
https://github.com/byReqz/conn.git
synced 2024-11-22 00:53:14 +00:00
cleanup code and enable updater for merge
This commit is contained in:
parent
bce9576c2d
commit
190a85326c
62
conn.sh
62
conn.sh
@ -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,16 +55,7 @@ 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 "-")
|
input=$(echo "$input" | tr -d "-")
|
||||||
}
|
}
|
||||||
@ -122,22 +100,24 @@ function main {
|
|||||||
if [[ $simpleoutput == true ]] && [[ -n $hosts ]];then
|
if [[ $simpleoutput == true ]] && [[ -n $hosts ]];then
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping $only -e $@
|
fping $only -e $@
|
||||||
echo ""
|
if [[ $oscheck != "false" ]];then
|
||||||
for host in $@;do
|
echo ""
|
||||||
linuxping=$(nping $only -c1 -p22,222 "$host")
|
for host in $@;do
|
||||||
if [[ -n $(echo "$linuxping" | grep -e "Successful connections: 1") ]];then
|
linuxping=$(nping $only -c1 -p22,222 "$host")
|
||||||
echo "$host seems to be booted into a Linux system"
|
if [[ -n $(echo "$linuxping" | grep -e "Successful connections: 1") ]];then
|
||||||
elif [[ -n $(echo "$linuxping" | grep -e "Successful connections: 2") ]];then
|
echo "$host seems to be booted into a Linux system"
|
||||||
echo "$host seems to be booted into the rescue system"
|
elif [[ -n $(echo "$linuxping" | grep -e "Successful connections: 2") ]];then
|
||||||
fi
|
echo "$host seems to be booted into the rescue system"
|
||||||
winping135=$(nping $only -c1 -p135 "$host")
|
fi
|
||||||
winping3389=$(nping $only -c1 -p3389 "$host")
|
winping135=$(nping $only -c1 -p135 "$host")
|
||||||
if [[ -n $(echo "$winping135" | grep -e "Successful connections: 1") ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
|
winping3389=$(nping $only -c1 -p3389 "$host")
|
||||||
echo "$host seems to be booted into Windows"
|
if [[ -n $(echo "$winping135" | grep -e "Successful connections: 1") ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
|
||||||
elif [[ -z $(fping $only -a $host) ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
|
echo "$host seems to be booted into Windows"
|
||||||
echo "$host seems to be booted into (desktop) Windows"
|
elif [[ -z $(fping $only -a $host) ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
|
||||||
fi
|
echo "$host seems to be booted into (desktop) Windows"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
else
|
else
|
||||||
for host in $hosts;do
|
for host in $hosts;do
|
||||||
@ -244,6 +224,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
|
||||||
|
Loading…
Reference in New Issue
Block a user