Add raw key generation and rework help display
This commit is contained in:
parent
05fbe26959
commit
cfb2da563e
@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
#### Slouží pro automatičtější přidávání zařízení na IOTT síť
|
#### Slouží pro automatičtější přidávání zařízení na IOTT síť
|
||||||
|
|
||||||
## Použití
|
## Usage
|
||||||
|
|
||||||
iottadd.sh < -l | -r > < id > < pass >
|
iottadd.sh < -l | -r > < id > < pass >
|
||||||
- -l for usage on local machine
|
- -l for usage on local machine
|
||||||
- -r for usage on server (remote)
|
- -r for usage on server (remote)
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
- python library `passlib`
|
||||||
|
37
iottadd.sh
37
iottadd.sh
@ -1,9 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
GREEN="\033[1;32m"
|
GREEN="\033[1;32m"
|
||||||
RED="\033[1;31m"
|
RED="\033[1;31m"
|
||||||
PURPLE="\033[1;35m"
|
PURPLE="\033[0;35m"
|
||||||
BLUE="\033[1;34m"
|
BLUE="\033[1;34m"
|
||||||
RESET="\033[0m"
|
RESET="\033[0m"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo -e $GREEN"Usage: iottadd.sh < -l | -r > < id > < pass >
|
||||||
|
|
||||||
|
-l for usage on local machine
|
||||||
|
-r for usage on server (remote)"$RESET
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z $3 ]; then
|
||||||
|
echo -e $RED"Not enough arguments!\n"$RESET
|
||||||
|
usage
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
if [[ $1 == "-l" ]]; then
|
if [[ $1 == "-l" ]]; then
|
||||||
# Used on local machine
|
# Used on local machine
|
||||||
echo -e $RED"Not implemented"$RESET
|
echo -e $RED"Not implemented"$RESET
|
||||||
@ -12,20 +31,26 @@ elif [[ $1 == "-r" ]]; then
|
|||||||
# Used on server
|
# Used on server
|
||||||
echo -en $GREEN"Running with: ID="$BLUE$2$GREEN" and PASS="$BLUE$3"\nIs that ok? ["$GREEN"Y"$BLUE"/"$RED"n"$BLUE"]"$PURPLE
|
echo -en $GREEN"Running with: ID="$BLUE$2$GREEN" and PASS="$BLUE$3"\nIs that ok? ["$GREEN"Y"$BLUE"/"$RED"n"$BLUE"]"$PURPLE
|
||||||
read -p " " confirmation
|
read -p " " confirmation
|
||||||
|
printf $RESET
|
||||||
|
|
||||||
if [[ $confirmation == "n" ]]; then
|
if [[ $confirmation == "n" ]]; then
|
||||||
exit 666
|
exit 666
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -w ./rawkey-generator.py ]; then
|
||||||
|
echo -e $RED"You don't have rawkey-generator.py in the same folder or don't have execute permitions"$CLEAR
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
elif [[ $1 == "-h" ]]; then
|
RAWKEY=$(python ./rawkey-generator.py $3 "Sincoolka IoTT")
|
||||||
echo "iottadd.sh < -l | -r > < id > < pass >
|
|
||||||
|
|
||||||
-l for usage on local machine
|
echo -e $GREEN"Generated raw key: "$BLUE$RAWKEY$CLEAR
|
||||||
-r for usage on server (remote)"
|
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
else
|
else
|
||||||
echo -e $RED"Expected \"-l\" or \"-r\""$RESET
|
usage
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
14
rawkey-generator.py
Normal file
14
rawkey-generator.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from passlib.utils import pbkdf2
|
||||||
|
import binascii, sys
|
||||||
|
|
||||||
|
arguments_counter = len(sys.argv) - 1
|
||||||
|
|
||||||
|
if arguments_counter != 2:
|
||||||
|
raise TypeError("The function takes exactly 2 arguments (%d passed)" % arguments_counter)
|
||||||
|
|
||||||
|
password = sys.argv[1]
|
||||||
|
ssid = sys.argv[2]
|
||||||
|
|
||||||
|
var = pbkdf2.pbkdf2(str.encode(password), str.encode(ssid), 4096, 32)
|
||||||
|
|
||||||
|
print(binascii.hexlify(var).decode("utf-8"))
|
Loading…
Reference in New Issue
Block a user