From 0e54eb8c855631ba7011df2ef0d0ac72a4c04590 Mon Sep 17 00:00:00 2001 From: Giulio Date: Sat, 19 Sep 2020 18:31:38 +0200 Subject: [PATCH] update_key generation now in cfgbin; update.sh auth changed --- keygen/keygen.c | 10 ++++++++++ update/update.sh | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/keygen/keygen.c b/keygen/keygen.c index d1f6646..40d840e 100644 --- a/keygen/keygen.c +++ b/keygen/keygen.c @@ -4,6 +4,7 @@ #include #include #include +#include typedef union uwb @@ -175,6 +176,15 @@ int gen_serial() } } +int gen_update_key() +{ + if (fopen("/etc/update_key", "r") == NULL) + { + system("/usr/bin/hexdump -n 32 -e '4/4 \"%08X\"' /dev/urandom > /etc/update_key"); + } + chmod("/etc/update_key", 0600); +} + int gen_ssid() { char *serial; diff --git a/update/update.sh b/update/update.sh index 44ca8a0..93db8f7 100755 --- a/update/update.sh +++ b/update/update.sh @@ -1,12 +1,12 @@ #!/bin/sh -if [[ -z $clearpassword ]]; then - /bin/echo "Usage: sudo clearpassword= -E update.sh" +if [[ -z $key ]]; then + /bin/echo "Usage: sudo key= -E update.sh" exit 1 fi -password=`/bin/cat /etc/txtpwd` -auth=`/bin/echo -n $clearpassword | /usr/bin/sha512sum | /usr/bin/cut -d' ' -f 1` +password=`/bin/cat /etc/update_key | /usr/bin/sha512sum | /usr/bin/cut -d' ' -f 1` +auth=`/bin/echo -n $key | /usr/bin/sha512sum | /usr/bin/cut -d' ' -f 1` if [[ "$auth" != "$password" ]]; then /bin/echo "Wrong password"