From e30613b74f8c94550bcc9f22a2b4d622661e9275 Mon Sep 17 00:00:00 2001 From: Jordan Geoghegan Date: Sat, 11 Jan 2020 08:22:09 +0000 Subject: [PATCH] Improve random string generation --- INSTALL/ubuntu-easyinstall.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/INSTALL/ubuntu-easyinstall.sh b/INSTALL/ubuntu-easyinstall.sh index 35552ed5..799bdf3d 100644 --- a/INSTALL/ubuntu-easyinstall.sh +++ b/INSTALL/ubuntu-easyinstall.sh @@ -118,16 +118,16 @@ if [ "$mysqlagreeData" = "y" ]; then read mysqlDefaultData if [ "$mysqlDefaultData" = "y" ]; then escapeReplaceQuote='\\"' - groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1) - userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1) - userEmail=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"@"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)".com" - userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1) - userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}') + groupKey=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,7)}') + userID=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,6)}') + userEmail=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,6)}')"@"$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,6)}')".com" + userPasswordPlain=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,7)}') + userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}') userDetails='{"days":"10"}' userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g') echo $userDetailsNew apiIP='0.0.0.0' - apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) + apiKey=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,32)}') apiDetails='{"auth_socket":"1","get_monitors":"1","control_monitors":"1","get_logs":"1","watch_stream":"1","watch_snapshot":"1","watch_videos":"1","delete_videos":"1"}' apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g') rm sql/default_user.sql || true