Skip to content

Commit

Permalink
Added password protection to DDWRT-BWMON to activate password protect…
Browse files Browse the repository at this point in the history
…ion use the script set-password.sh
  • Loading branch information
vortex-5 committed Nov 7, 2019
1 parent 6643f4e commit 05fc416
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 146 deletions.
1 change: 1 addition & 0 deletions bwmon/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ chmod +x "$SCRIPT_DIR/bwmon-running.sh"
chmod +x "$SCRIPT_DIR/bwmon.sh"
chmod +x "$SCRIPT_DIR/lighttpd-running.sh"
chmod +x "$SCRIPT_DIR/keep-alive.sh"
chmod +x "$SCRIPT_DIR/set-password.sh"
chmod +x "$SCRIPT_DIR/www/bwreader.cgi"
chmod +x "$SCRIPT_DIR/www/bwreset.cgi"

Expand Down
25 changes: 25 additions & 0 deletions bwmon/set-password.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
SCRIPT_DIR=$(dirname ${0})
SCRIPT_DIR=$(cd ${SCRIPT_DIR} && pwd)

# Create folder that the password file lives in
if [ ! -d $SCRIPT_DIR/data ]
then
mkdir $SCRIPT_DIR/data
fi

echo 'Please type your password below or leave blank and press enter for no password (default).'

read password
if [ "$password" = "" ]
then
echo "Password has been cleared."
printf "window.serverPasswordHash='';\n" > $SCRIPT_DIR/data/password.js
else
SHA256HASH_RAW=$(printf "$password" | openssl dgst -sha256)
SHA256HASH=${SHA256HASH_RAW:9}
printf "window.serverPasswordHash='$SHA256HASH';\n" > $SCRIPT_DIR/data/password.js
echo 'Your selected password has been set.'
fi

echo 'Please restart the server for your changes to take effect.'
8 changes: 8 additions & 0 deletions bwmon/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ fi
if [ "$($SCRIPT_DIR/lighttpd-running.sh)" = "true" ]; then
mkdir -p -- "/jffs/www/"
cp -R $SCRIPT_DIR/www/* /jffs/www/
if [ -f $SCRIPT_DIR/data/password.js ]
then
cp $SCRIPT_DIR/data/password.js /jffs/www/password.js
fi
else
cp -R $SCRIPT_DIR/www/* /tmp/www/
if [ -f $SCRIPT_DIR/data/password.js ]
then
cp $SCRIPT_DIR/data/password.js /tmp/www/password.js
fi
ln -s /tmp/dnsmasq.conf /tmp/www/dnsmasq-conf.js
ln -s /tmp/dnsmasq.leases /tmp/www/dnsmasq-leases.js
fi
Expand Down
1 change: 1 addition & 0 deletions bwmon/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rm mac-names.js
rm ui-bootstrap-tpls.min.js
rm dnsmasq-conf.js
rm dnsmasq-leases.js
rm password.js
rm bwreader.cgi
rm bwreset.cgi
# End Cleanup WebGUI
Expand Down
35 changes: 35 additions & 0 deletions bwmon/www/bwmon.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,42 @@

.arrow-down {
transform: rotate(-90deg);
}


.login-frame {
display: flex;
flex-direction: column;
align-items: center;
}

.login-frame .title {
font-size: xx-large;
}

.login-frame input {
border: 1px solid #414558;
padding: 10px 20px;
margin: 10px;
}

.login-frame > input {
width: 300px;
}

.login-frame button {
padding: 10px 20px;
border-radius: 2px;
background-color: white;
border: 1px solid black;
}

.login-frame button:hover {
background-color: #414558;
}

.login-frame .error {
color: red;
}

/* Button group responsive for mobile layout */
Expand Down
Loading

0 comments on commit 05fc416

Please sign in to comment.