1
0
Files
2026-04-18 10:16:05 +02:00

122 lines
3.5 KiB
Bash

#!/bin/sh
scriptcommand=genpass
runcommand=getpassword
batchdate="26.10.2021"
programtitle1="**** Zyxel VMG8823/8825"
programtitle2="**** Calculate admin/supervisor/wifi password by serial number"
programtitle3="**** Script by maximux/bovirus v. $batchdate"
# mask for check first part of serial nuimber
serialstartok1="172"
serialstartok2="182"
serialstartok3="190"
serialstartok4="192"
# mask for check midlle part of serial nuimber
serialmiddleok1="H"
serialmiddleok2="S"
serialmiddleok3="V"
serialmiddleok4="Y"
# default value for the operation
debug=0
exec=1
error=0
echo ""
echo "$programtitle1"
echo "$programtitle2"
echo "$programtitle3"
echo ""
if [ $# -eq 0 ]; then
error=1 # no modem serial number provided
else
export SERIAL=$1
SERIAL=$(echo "$SERIAL" | tr '[:lower:]' '[:upper:]')
seriallenght=${#SERIAL}
serialsubstring1=$(echo $SERIAL | cut -c1-1) # extract first part of modem serial
serialsubstring2=$(echo $SERIAL | cut -c2-4) # extract secndo part of modem serial
serialsubstring3=$(echo $SERIAL | cut -c5-5) # extract third part of modem serial
serialsubstring4=$(echo $SERIAL | cut -c6-13) # extract fourth part of modem serial
#----------------------------------------------- check serial lenght of 13 charcaters
if [ $seriallenght -ne 13 ]; then
if [ $error -eq 0 ]; then
error=2
fi
fi
#----------------------------------------------- check that first character is S
if [ "$serialsubstring1" != "S" ]; then
if [ $error -eq 0 ]; then
error=3
fi
fi
#----------------------------------------------- check che 2nd part is all numeric
if ! [ "$(echo $serialsubstring2 | grep -E "^[0-9]{1,}$")" ]; then
if [ $error -eq 0 ]; then
error=4
fi
fi
#----------------------------------------------- check che 3rd part is a letter
if ! [ "$(echo $serialsubstring3 | grep -E "^[A-Z]{1,}$")" ]; then
if [ $error -eq 0 ]; then
error=5
fi
fi
#----------------------------------------------- check that 4th part is all numeric
if ! [ "$(echo $serialsubstring4 | grep -E "^[0-9]{1,}$")" ]; then
if [ $error -eq 0 ]; then
error=6
fi
fi
fi
if [ $error -ne 0 ]; then
if [ $error -ne 1 ]; then
echo "-----------------------------------------"
echo " Modem serial number = "$SERIAL
echo "-----------------------------------------"
echo ""
fi
echo "error = $error"
echo ""
echo "error 1 = no serial number provided"
echo "error 2 = serial number lenght is not 13 characters"
echo "error 3 = character n. 1 of serial number is not 'S'"
echo "error 4 = characters n. 2-3-4 of serial number are not numbers"
echo "error 5 = character n. 5 of serial number is not a letter"
echo "error 6 = characters from 6 to 13 of serial number are not numbers"
echo ""
echo "-----------------------------------------"
echo ""
echo "command syntax:"
echo ""
echo " genpass ModemSerialNumber"
echo ""
echo "ModemSerialNumber is a 13 character string"
echo ""
echo "Example: genpass S123V12345678"
else
echo "-----------------------------------------"
echo " Modem serial number = "$SERIAL
echo "-----------------------------------------"
if [ $exec -eq 1 ]; then
export LD_LIBRARY_PATH=/opt/zyxel/lib:/opt/zyxel/lib/private:/opt/zyxel/lib/public:/opt/zyxel/usr/lib
export LD_PRELOAD=/opt/genpass/libhook.so
/opt/genpass/$runcommand
fi
fi
echo ""
echo ""