Skip to content

Commit

Permalink
Synchronization between js and php on login password checking with ti…
Browse files Browse the repository at this point in the history
…ghter control
  • Loading branch information
ketetefid committed Apr 2, 2018
1 parent 3315674 commit 0637ec8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions ActionPage.php
@@ -1,13 +1,12 @@
<?php <?php
session_start(); session_start();
if (isset($_POST['uname']) and isset($_POST['psw'])) { if (isset($_POST['uname']) and isset($_POST['psw'])) {
if( strpos($_POST['uname'],'/') === false && strpos($_POST['uname'],';') === false && $user=$_POST['uname'];
strpos($_POST['psw'],'/') === false && strpos($_POST['psw'],';') === false ) { $pass=$_POST['psw'];
if (preg_match('/^[a-z0-9]*$/',$user) && preg_match('/^[a-zA-Z0-9*!@#^_]*$/',$pass)) {

This comment has been minimized.

Copy link
@duraki

duraki Jun 11, 2018

This can be bypassed again. See $IFS$9, x20 etc.

// Check if the post request comes from the login page // Check if the post request comes from the login page
if (isset($_POST['auth2']) and hash_equals($_POST['auth2'],hash_hmac('sha256', '/ActionPage.php', $_SESSION['auth_token']))) { if (isset($_POST['auth2']) and hash_equals($_POST['auth2'],hash_hmac('sha256', '/ActionPage.php', $_SESSION['auth_token']))) {
$siausr = trim(shell_exec('source /boot/parameters.txt; echo $SIAUSR')); $siausr = trim(shell_exec('source /boot/parameters.txt; echo $SIAUSR'));
$user=$_POST['uname'];
$pass=$_POST['psw'];
exec("sudo bin/checker $user $pass", $output, $exitcode); exec("sudo bin/checker $user $pass", $output, $exitcode);
if ( $exitcode === 0 and strcmp($siausr,$user) === 0 ) { if ( $exitcode === 0 and strcmp($siausr,$user) === 0 ) {
session_regenerate_id(true); session_regenerate_id(true);
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -161,7 +161,7 @@ <h1>Welcome to SiaBerryOS</h1>
function formChecker() { function formChecker() {
var usr = document.forms["mainForm"]["uname"].value; var usr = document.forms["mainForm"]["uname"].value;
var pss = document.forms["mainForm"]["psw"].value; var pss = document.forms["mainForm"]["psw"].value;
if ( !/^[a-z0-9]*$/.test(usr) || !/^[a-zA-Z0-9*!@#$%]*$/.test(pss)) { if ( !/^[a-z0-9]*$/.test(usr) || !/^[a-zA-Z0-9*!@#^_]*$/.test(pss)) {

This comment has been minimized.

Copy link
@duraki

duraki Jun 11, 2018

Seriously, a front-end validation?

document.getElementById('auth2').value = 'failed'; document.getElementById('auth2').value = 'failed';
} }
} }
Expand Down

0 comments on commit 0637ec8

Please sign in to comment.