From 495a94d7717dac4d969393e8a504ed16d88317e8 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 28 Apr 2020 16:21:52 +0200 Subject: redirect output --- httpdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/index.php b/httpdocs/index.php index a697be3..108bf9c 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -1,6 +1,6 @@ &1', 'r'); if ($f === false) { print 'Cannot access gpio'; die(); -- cgit v1.2.3-54-g00ecf From 5313fd8d398b451e81f6e77ce87d23c3253a22f5 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 28 Apr 2020 22:24:40 +0200 Subject: httpdocs/index.php: chain hash to slow brute force down --- httpdocs/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpdocs/index.php b/httpdocs/index.php index 108bf9c..e8a97ad 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -29,7 +29,9 @@ function push_it() { } $saved_hash = trim(fgets($f)); fclose($f); - $entered_hash = hash('sha512', $_POST['password']); + $entered_hash = $_POST['password']; + for ($i=0; $i<1000; $i++) + $entered_hash = hash('sha512', $entered_hash . $i . $_POST['password']); if ($saved_hash != $entered_hash) { print 'Wrong password: ' . $entered_hash . '
' . "\n"; return; -- cgit v1.2.3-54-g00ecf From a68dc7bb5c46840cca3fae0679db9f3291ae8f0f Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 28 Apr 2020 22:24:40 +0200 Subject: httpdocs/index.php: chain hash to slow brute force down --- httpdocs/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpdocs/index.php b/httpdocs/index.php index a697be3..eb21166 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -29,7 +29,9 @@ function push_it() { } $saved_hash = trim(fgets($f)); fclose($f); - $entered_hash = hash('sha512', $_POST['password']); + $entered_hash = $_POST['password']; + for ($i=0; $i<1000; $i++) + $entered_hash = hash('sha512', $entered_hash . $i . $_POST['password']); if ($saved_hash != $entered_hash) { print 'Wrong password: ' . $entered_hash . '
' . "\n"; return; -- cgit v1.2.3-54-g00ecf From 5336cffa25ff5fededc58f237734a0603c0bac57 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 28 Apr 2020 22:36:32 +0200 Subject: linebreak new --- httpdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/index.php b/httpdocs/index.php index eb21166..18f1f91 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -9,7 +9,7 @@ $l = trim(fgets($f)); pclose($f); if ($l == '') { - print 'Cannot read gpio - is it installed?'; + print 'Cannot read gpio - is it installed?' . "\n"; die(); } -- cgit v1.2.3-54-g00ecf From f1494672d8a1bfd009de9193913b04a3d494b138 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 28 Apr 2020 22:37:52 +0200 Subject: Revert "adopt to different pins on fenster-lo" This reverts commit 3c8223357b5c93d2edd8bad9a8a3f3465b8fa86c. --- configure-gpio.service | 20 ++++---------------- httpdocs/index.php | 10 +++++----- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/configure-gpio.service b/configure-gpio.service index 39fe311..9feb7be 100644 --- a/configure-gpio.service +++ b/configure-gpio.service @@ -4,22 +4,10 @@ Description=configure the GPIO pins [Service] Type=oneshot RemainAfterExit=yes - -# power led -ExecStart=/usr/bin/gpio mode 7 in -ExecStart=/usr/bin/gpio mode 7 up - -# hdd led -ExecStart=/usr/bin/gpio mode 15 in -ExecStart=/usr/bin/gpio mode 15 up - -# power switch -ExecStart=/usr/bin/gpio mode 9 out -ExecStart=/usr/bin/gpio write 9 0 - -# reset switch -ExecStart=/usr/bin/gpio mode 8 out -ExecStart=/usr/bin/gpio write 8 0 +ExecStart=/usr/bin/gpio mode 27 in +ExecStart=/usr/bin/gpio mode 27 up +ExecStart=/usr/bin/gpio mode 28 out +ExecStart=/usr/bin/gpio write 28 0 [Install] WantedBy=multi-user.target diff --git a/httpdocs/index.php b/httpdocs/index.php index 18f1f91..3b72876 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -1,6 +1,6 @@ 0) && ($duration < 300)) { print 'pushing for ' . ($duration * 0.1) . ' seconds ...
' . "\n"; - shell_exec('/usr/bin/gpio write 9 1'); + shell_exec('/usr/bin/gpio write 28 1'); flush(); usleep(100000 * $duration); - shell_exec('/usr/bin/gpio write 9 0'); + shell_exec('/usr/bin/gpio write 28 0'); print '... done
' . "\n"; } } print '' . "\n"; print '' . "\n"; -print 'fenster lights-out' . "\n"; +print 'fileserver lights-out' . "\n"; if (array_key_exists('password', $_POST)) print '' . "\n"; print '' . "\n"; print '' . "\n"; -print 'Fenster is currently '; +print 'Fileserver is currently '; if ($l == '1') print 'off'; else -- cgit v1.2.3-54-g00ecf From 2420dfa09d20ad47a5d6593114d667694eee602d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 1 May 2020 12:11:41 +0200 Subject: change to pins which are not used during bootup --- httpdocs/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpdocs/index.php b/httpdocs/index.php index e8a97ad..e586dd0 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -1,6 +1,6 @@ &1', 'r'); +$f = popen('/usr/bin/gpio read 4 2>&1', 'r'); if ($f === false) { print 'Cannot access gpio'; die(); @@ -45,10 +45,10 @@ function push_it() { if (($duration > 0) && ($duration < 300)) { print 'pushing for ' . ($duration * 0.1) . ' seconds ...
' . "\n"; - shell_exec('/usr/bin/gpio write 9 1'); + shell_exec('/usr/bin/gpio write 3 1'); flush(); usleep(100000 * $duration); - shell_exec('/usr/bin/gpio write 9 0'); + shell_exec('/usr/bin/gpio write 3 0'); print '... done
' . "\n"; } } -- cgit v1.2.3-54-g00ecf From af72ca428887ca75ceb99912e90cbc76b8b8ceb6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 1 May 2020 12:12:22 +0200 Subject: change to pins which are not used during bootup --- configure-gpio.service | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/configure-gpio.service b/configure-gpio.service index 39fe311..e638274 100644 --- a/configure-gpio.service +++ b/configure-gpio.service @@ -6,20 +6,20 @@ Type=oneshot RemainAfterExit=yes # power led -ExecStart=/usr/bin/gpio mode 7 in -ExecStart=/usr/bin/gpio mode 7 up +ExecStart=/usr/bin/gpio mode 4 in +ExecStart=/usr/bin/gpio mode 4 up # hdd led -ExecStart=/usr/bin/gpio mode 15 in -ExecStart=/usr/bin/gpio mode 15 up +ExecStart=/usr/bin/gpio mode 5 in +ExecStart=/usr/bin/gpio mode 5 up # power switch -ExecStart=/usr/bin/gpio mode 9 out -ExecStart=/usr/bin/gpio write 9 0 +ExecStart=/usr/bin/gpio mode 3 out +ExecStart=/usr/bin/gpio write 3 0 # reset switch -ExecStart=/usr/bin/gpio mode 8 out -ExecStart=/usr/bin/gpio write 8 0 +ExecStart=/usr/bin/gpio mode 2 out +ExecStart=/usr/bin/gpio write 2 0 [Install] WantedBy=multi-user.target -- cgit v1.2.3-54-g00ecf From c763f45f5544424f299707e33d0f1e3893ba77a9 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 30 Jan 2021 17:02:59 +0100 Subject: httpdocs/index.php: add missing line breaks --- httpdocs/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpdocs/index.php b/httpdocs/index.php index e586dd0..b2b9bda 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -2,14 +2,14 @@ $f = popen('/usr/bin/gpio read 4 2>&1', 'r'); if ($f === false) { - print 'Cannot access gpio'; + print 'Cannot access gpio' . "\n"; die(); } $l = trim(fgets($f)); pclose($f); if ($l == '') { - print 'Cannot read gpio - is it installed?'; + print 'Cannot read gpio - is it installed?' . "\n"; die(); } -- cgit v1.2.3-54-g00ecf From f936b79013ae53fe2620dcad140a751f01904713 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 30 Jan 2021 17:21:24 +0100 Subject: httpdocs/index.php: add missing line breaks --- httpdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpdocs/index.php b/httpdocs/index.php index 3b72876..43dd967 100644 --- a/httpdocs/index.php +++ b/httpdocs/index.php @@ -2,7 +2,7 @@ $f = popen('/usr/bin/gpio read 27', 'r'); if ($f === false) { - print 'Cannot access gpio'; + print 'Cannot access gpio' . "\n"; die(); } $l = trim(fgets($f)); -- cgit v1.2.3-54-g00ecf From 0ba9cc4e7fa875d5a37180c2dde13eae82f99ac5 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 30 Jan 2021 21:16:34 +0100 Subject: removed everything --- configure-gpio.service | 13 --------- httpdocs/index.php | 78 -------------------------------------------------- 2 files changed, 91 deletions(-) delete mode 100644 configure-gpio.service delete mode 100644 httpdocs/index.php diff --git a/configure-gpio.service b/configure-gpio.service deleted file mode 100644 index 9feb7be..0000000 --- a/configure-gpio.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=configure the GPIO pins - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/bin/gpio mode 27 in -ExecStart=/usr/bin/gpio mode 27 up -ExecStart=/usr/bin/gpio mode 28 out -ExecStart=/usr/bin/gpio write 28 0 - -[Install] -WantedBy=multi-user.target diff --git a/httpdocs/index.php b/httpdocs/index.php deleted file mode 100644 index 43dd967..0000000 --- a/httpdocs/index.php +++ /dev/null @@ -1,78 +0,0 @@ -Cannot read password file
' . "\n"; - return; - } - $saved_hash = trim(fgets($f)); - fclose($f); - $entered_hash = $_POST['password']; - for ($i=0; $i<1000; $i++) - $entered_hash = hash('sha512', $entered_hash . $i . $_POST['password']); - if ($saved_hash != $entered_hash) { - print 'Wrong password: ' . $entered_hash . '
' . "\n"; - return; - } - foreach ($_POST as $key => $dummy) - if (preg_match('/^push_([0-9]+)$/', $key, $duration)) - break; - if (count($duration) != 2) - return; - $duration = $duration[1]; - if (($duration > 0) - && ($duration < 300)) { - print 'pushing for ' . ($duration * 0.1) . ' seconds ...
' . "\n"; - shell_exec('/usr/bin/gpio write 28 1'); - flush(); - usleep(100000 * $duration); - shell_exec('/usr/bin/gpio write 28 0'); - print '... done
' . "\n"; - } -} - -print '' . "\n"; -print '' . "\n"; -print 'fileserver lights-out' . "\n"; -if (array_key_exists('password', $_POST)) - print '' . "\n"; -print '' . "\n"; -print '' . "\n"; -print 'Fileserver is currently '; -if ($l == '1') - print 'off'; -else - print 'on'; -print '
' . "\n"; -if ($https) { - push_it(); - print '
' . "\n"; - print 'Passwort:
' . "\n"; - print '
' . "\n"; - print '
' . "\n"; - print '
' . "\n"; -} -print '' . "\n"; -print '' . "\n"; -- cgit v1.2.3-54-g00ecf From cd242ce7161a99ad2e24e84353de308cd404601d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 30 Jan 2021 21:16:46 +0100 Subject: removed everything --- configure-gpio.service | 25 ---------------- httpdocs/index.php | 78 -------------------------------------------------- 2 files changed, 103 deletions(-) delete mode 100644 configure-gpio.service delete mode 100644 httpdocs/index.php diff --git a/configure-gpio.service b/configure-gpio.service deleted file mode 100644 index e638274..0000000 --- a/configure-gpio.service +++ /dev/null @@ -1,25 +0,0 @@ -[Unit] -Description=configure the GPIO pins - -[Service] -Type=oneshot -RemainAfterExit=yes - -# power led -ExecStart=/usr/bin/gpio mode 4 in -ExecStart=/usr/bin/gpio mode 4 up - -# hdd led -ExecStart=/usr/bin/gpio mode 5 in -ExecStart=/usr/bin/gpio mode 5 up - -# power switch -ExecStart=/usr/bin/gpio mode 3 out -ExecStart=/usr/bin/gpio write 3 0 - -# reset switch -ExecStart=/usr/bin/gpio mode 2 out -ExecStart=/usr/bin/gpio write 2 0 - -[Install] -WantedBy=multi-user.target diff --git a/httpdocs/index.php b/httpdocs/index.php deleted file mode 100644 index b2b9bda..0000000 --- a/httpdocs/index.php +++ /dev/null @@ -1,78 +0,0 @@ -&1', 'r'); -if ($f === false) { - print 'Cannot access gpio' . "\n"; - die(); -} -$l = trim(fgets($f)); -pclose($f); - -if ($l == '') { - print 'Cannot read gpio - is it installed?' . "\n"; - die(); -} - -if (array_key_exists('HTTPS', $_SERVER) -&& ($_SERVER['HTTPS'] == 'on')) - $https = true; -else - $https = false; - -function push_it() { - if (!array_key_exists('password', $_POST)) - return; - $f = fopen('../password', 'r'); - if ($f === false) { - print 'Cannot read password file
' . "\n"; - return; - } - $saved_hash = trim(fgets($f)); - fclose($f); - $entered_hash = $_POST['password']; - for ($i=0; $i<1000; $i++) - $entered_hash = hash('sha512', $entered_hash . $i . $_POST['password']); - if ($saved_hash != $entered_hash) { - print 'Wrong password: ' . $entered_hash . '
' . "\n"; - return; - } - foreach ($_POST as $key => $dummy) - if (preg_match('/^push_([0-9]+)$/', $key, $duration)) - break; - if (count($duration) != 2) - return; - $duration = $duration[1]; - if (($duration > 0) - && ($duration < 300)) { - print 'pushing for ' . ($duration * 0.1) . ' seconds ...
' . "\n"; - shell_exec('/usr/bin/gpio write 3 1'); - flush(); - usleep(100000 * $duration); - shell_exec('/usr/bin/gpio write 3 0'); - print '... done
' . "\n"; - } -} - -print '' . "\n"; -print '' . "\n"; -print 'fenster lights-out' . "\n"; -if (array_key_exists('password', $_POST)) - print '' . "\n"; -print '' . "\n"; -print '' . "\n"; -print 'Fenster is currently '; -if ($l == '1') - print 'off'; -else - print 'on'; -print '
' . "\n"; -if ($https) { - push_it(); - print '
' . "\n"; - print 'Passwort:
' . "\n"; - print '
' . "\n"; - print '
' . "\n"; - print '
' . "\n"; -} -print '' . "\n"; -print '' . "\n"; -- cgit v1.2.3-54-g00ecf