Display Password entry from index if key not supplied
This commit is contained in:
parent
ed9eed7a36
commit
d9522084f9
159
index.php
159
index.php
|
|
@ -13,85 +13,124 @@
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<div align="center" style="width: 500px">
|
<div align="center" style="width: 500px">
|
||||||
<div style="border: 1px solid #000000; text-align: center; background: #486b92; font-size: 20px; color: #ffffff;">
|
<div style="border: 1px solid #000000; text-align: center; background: #486b92; font-size: 20px; color: #ffffff;">
|
||||||
<strong>AJServer password retrieval</strong>
|
<strong>One Time Password Retrieval Tool</strong>
|
||||||
</div>
|
</div>
|
||||||
<div style="border: 1px solid #000000; text-align: left; padding: 8px;">
|
<div style="border: 1px solid #000000; text-align: left; padding: 8px;">
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key']));
|
|
||||||
|
|
||||||
//$DBConnection = pg_connect("host=localhost port=5432 dbname=mypasswd user=mypasswd password=passwdT00l");
|
|
||||||
try {
|
try {
|
||||||
$pdo = new PDO(
|
$pdo = new PDO(
|
||||||
'mysql:host=localhost;dbname=pwtool;charset=utf8',
|
'mysql:host=localhost;dbname=pwtool;charset=utf8',
|
||||||
'pwtool',
|
'pwtool',
|
||||||
'BaVYtU9YqMyrp4qi',
|
'BaVYtU9YqMyrp4qi',
|
||||||
[PDO::ATTR_EMULATE_PREPARES => false,
|
[PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
|
||||||
);
|
);
|
||||||
} catch (PDOException $failure) {
|
} catch (PDOException $failure) {
|
||||||
echo "Connection failed: " . $failure->getMessage();
|
echo "Connection failed: " . $failure->getMessage();
|
||||||
};
|
};
|
||||||
|
require 'CaptchasDotNet.php';
|
||||||
|
|
||||||
if(($MyKey != '') and (strlen($MyKey) == 32) || (strlen($MyKey) == 64)) {
|
$captchas = new CaptchasDotNet ('demo', 'secret',
|
||||||
|
'/tmp/captchasnet-random-strings','3600',
|
||||||
|
'abcdefghkmnopqrstuvwxyz','6',
|
||||||
|
'240','80','000088');
|
||||||
|
|
||||||
$MyLookup = $pdo->prepare("SELECT password, retrieved_ip, retireved_time FROM pwtool.mypasswd WHERE code = '$MyKey'");
|
if(isset($_GET['key']))
|
||||||
$MyLookup->execute();
|
{ //Key set in URL
|
||||||
/* $MyLookup = pg_query($DBConnection, "SELECT password, retrieved_ip, extract('epoch' from retrieved_time)::integer
|
$MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key']));
|
||||||
FROM mypasswd.password_delivery
|
|
||||||
WHERE code = '".pg_escape_string($MyKey)."'");
|
|
||||||
*/
|
|
||||||
$count = $MyLookup->rowCount();
|
|
||||||
|
|
||||||
if($count == 1){
|
if(($MyKey != '') and (strlen($MyKey) == 32) || (strlen($MyKey) == 64)) {
|
||||||
|
|
||||||
$myRow = $MyLookup->fetch(PDO::FETCH_OBJ);
|
$MyLookup = $pdo->prepare("SELECT password, retrieved_ip, retireved_time FROM pwtool.mypasswd WHERE code = '$MyKey'");
|
||||||
$MyIP = $myRow->retrieved_ip;
|
$MyLookup->execute();
|
||||||
|
$count = $MyLookup->rowCount();
|
||||||
|
|
||||||
if($MyIP != ''){
|
if($count == 1){
|
||||||
|
|
||||||
//$MyTime = date('l, F j Y G:i:s', $myRow->retireved_time);
|
$myRow = $MyLookup->fetch(PDO::FETCH_OBJ);
|
||||||
$MyTime = $myRow->retireved_time;
|
$MyIP = $myRow->retrieved_ip;
|
||||||
|
|
||||||
print '<p><strong>Error:</strong> This key was valid for one-time '
|
if($MyIP != ''){
|
||||||
.'use and is no longer valid.</p><p>It was already delivered to IP address '
|
|
||||||
.'<strong>'.$MyIP.'</strong> on <strong>'.$MyTime.'</strong>. Please contact '
|
$MyTime = $myRow->retireved_time;
|
||||||
.'support immediately to have your password reset if you feel your key '
|
|
||||||
.'might have been intercepted.</p>';
|
print '<p><strong>Error:</strong> This key was valid for one-time '
|
||||||
|
.'use and is no longer valid.</p><p>It was already delivered to IP address '
|
||||||
|
.'<strong>'.$MyIP.'</strong> on <strong>'.$MyTime.'</strong>. Please contact '
|
||||||
|
.'support immediately to have your password reset if you feel your key '
|
||||||
|
.'might have been intercepted.</p>';
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$MyPassword = $myRow->password;
|
||||||
|
$MyIP = $_SERVER['REMOTE_ADDR'];
|
||||||
|
$myUpdate = $pdo->prepare("UPDATE pwtool.mypasswd SET retrieved_ip = '$MyIP',retireved_time = now(),password = ''
|
||||||
|
WHERE code = '$MyKey'");
|
||||||
|
$myUpdate->execute();
|
||||||
|
|
||||||
|
print '<p>Your password is:</p><p style="font-size: 18px; text-align: center;">';
|
||||||
|
|
||||||
|
if(strlen($MyPassword) > 20){
|
||||||
|
print '<pre>'.$MyPassword.'</pre></p>';
|
||||||
|
} else {
|
||||||
|
print '<strong>'.$MyPassword.'</strong></p>';
|
||||||
|
}
|
||||||
|
print '<p>Do not hit reload on your browser. This URL is one-time use and will not show your passsword again.<p>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
|
||||||
//$MyPassword = pg_fetch_result($MyLookup,0,0);
|
|
||||||
$MyPassword = $myRow->password;
|
|
||||||
$MyIP = $_SERVER['REMOTE_ADDR'];
|
|
||||||
$myUpdate = $pdo->prepare("UPDATE pwtool.mypasswd SET retrieved_ip = '$MyIP',retireved_time = now(),password = ''
|
|
||||||
WHERE code = '$MyKey'");
|
|
||||||
$myUpdate->execute();
|
|
||||||
/*$MyLookup = pg_query($DBConnection, "UPDATE mypasswd.password_delivery
|
|
||||||
SET retrieved_ip = '".pg_escape_string($MyIP)."',
|
|
||||||
retrieved_time = 'now()',
|
|
||||||
password = ''
|
|
||||||
WHERE code = '".pg_escape_string($MyKey)."'");*/
|
|
||||||
|
|
||||||
print '<p>Your password is:</p><p style="font-size: 18px; text-align: center;">';
|
|
||||||
|
|
||||||
if(strlen($MyPassword) > 20){
|
|
||||||
|
|
||||||
print '<pre>'.$MyPassword.'</pre></p>';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print '<strong>'.$MyPassword.'</strong></p>';
|
|
||||||
}
|
|
||||||
print '<p>Do not hit reload on your browser. This URL is one-time use and will not show your passsword again.<p>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
|
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
{ //Display New password entry form
|
||||||
|
?>
|
||||||
|
<form method="post" action="add.php">
|
||||||
|
<table border="0" cellspacing="2" cellpadding="2">
|
||||||
|
<?php /*<tr>
|
||||||
|
<td>Admin Password:</td><td><input type="password" name="adminPassword" value="" /></td>
|
||||||
|
</tr> */ ?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="hidden" name="random" value="<?= $captchas->random () ?>" />
|
||||||
|
<?php //Your message:</td><td><input name="message" value="Hello World" size="60" /> ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?= $captchas->image () ?> </br><a href="javascript:captchas_image_reload('captchas.net')">Reload Image</a>
|
||||||
|
<?php /*<br> <a href="<?= $captchas->audio_url () ?>">Phonetic spelling (mp3)</a>
|
||||||
|
<br> <a href="<?= $captchas->audio_url () ?>&language=de">Buchstabieren (mp3)</a>
|
||||||
|
<br> <a href="<?= $captchas->audio_url () ?>&language=it">Compitare (mp3)</a>
|
||||||
|
<br> <a href="<?= $captchas->audio_url () ?>&language=nl">Spellen (mp3)</a>
|
||||||
|
<br> <a href="<?= $captchas->audio_url () ?>&language=fr">Epeler (mp3)</a> */ ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
The CAPTCHA:
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input name="password" size="6" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>New Password:</td><td><input type="text" name="newPassword" value="" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue