Initial Commit from Harris

This commit is contained in:
Aaron Johnson 2020-09-27 06:49:30 -05:00
commit b247afe638
4 changed files with 233 additions and 0 deletions

78
add.php Normal file
View File

@ -0,0 +1,78 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Password Fetch tool</title>
<style type="text/css">
body{
padding: 32px;
}
</style>
</head>
<body style="width: 500px; margin: auto; font-family: Verdana, Geneva, sans-serif; font-size: 14px;">
<br /><br />
<div align="center" style="width: 500px">
<div style="border: 1px solid #000000; text-align: center; background: #486b92; font-size: 20px; color: #ffffff;">
<strong>AJServer password retrieval</strong>
</div>
<div style="border: 1px solid #000000; text-align: left; padding: 8px;">
<?php
$displayForm = true;
if($_POST['adminPassword'] != ''){
$newPassword = str_replace("'", '', trim($_POST['newPassword']));
$adminPassword = md5(trim($_POST['adminPassword']));
$dbConnection = pg_connect("host=localhost port=5432 dbname=mypasswd user=mypasswd password=passwdT00l");
$myLookup = pg_query($dbConnection, "SELECT id from password_delivery where id = 0 and key='".pg_escape_string($adminPassword)."';");
if(pg_num_rows($myLookup)){
$displayForm = false;
$myLookup = pg_query($dbConnection, "BEGIN;");
$myLookup = pg_query($dbConnection, "INSERT INTO password_delivery (key, password)
VALUES(md5('foobarfoo' || now()), '".pg_escape_string($newPassword)."');");
$myLookup = pg_query($dbConnection, "SELECT key
FROM password_delivery
WHERE id = currval('password_delivery_id_seq');");
$myKey = pg_fetch_result($myLookup, 0, 0);
$myLookup = pg_query($dbConnection, "COMMIT");
print '<p>Password insert succeeded. Here\'s the URL to fetch it:</p>';
print '<p><a href="'.dirname($_SERVER['PHP_SELF']).'?key='.$myKey.'">link</a></p>';
}
else{
print '<p>Nope, not here: '.$adminPassword.'</p>';
}
}
if($displayForm){
?>
<form method="post" action="add.php">
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td>Admin Password:</td><td><input type="password" name="adminPassword" value="" /></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
}
?>
</div>
</div>
<br /><br />
</body>
</html>

1
changeAdminPass.txt Normal file
View File

@ -0,0 +1 @@
update password_delivery set key = md5('your new password') where id = 0;

79
index.php Normal file
View File

@ -0,0 +1,79 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Password Fetch tool</title>
<style type="text/css">
body{
padding: 32px;
}
</style>
</head>
<body style="width: 500px; margin: auto; font-family: Verdana, Geneva, sans-serif; font-size: 14px;">
<br /><br />
<div align="center" style="width: 500px">
<div style="border: 1px solid #000000; text-align: center; background: #486b92; font-size: 20px; color: #ffffff;">
<strong>AJServer password retrieval</strong>
</div>
<div style="border: 1px solid #000000; text-align: left; padding: 8px;">
<?php
$MyKey = preg_replace('/[^a-f0-9]/', '', trim($_GET['key']));
$DBConnection = pg_connect("host=localhost port=5432 dbname=mypasswd user=mypasswd password=passwdT00l");
if(($MyKey != '') and (strlen($MyKey) == 32)){
$MyLookup = pg_query($DBConnection, "SELECT password, retrieved_ip, extract('epoch' from retrieved_time)::integer
FROM password_delivery
WHERE key = '".pg_escape_string($MyKey)."'");
if(pg_num_rows($MyLookup)){
$MyIP = pg_fetch_result($MyLookup,0,1);
if($MyIP != ''){
$MyTime = date('l, F j Y G:i:s', pg_fetch_result($MyLookup, 0, 2));
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 = pg_fetch_result($MyLookup,0,0);
$MyIP = $_SERVER['REMOTE_ADDR'];
$MyLookup = pg_query($DBConnection, "UPDATE password_delivery
SET retrieved_ip = '".pg_escape_string($MyIP)."',
retrieved_time = 'now()',
password = ''
WHERE key = '".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{
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
}
}
else{
print '<p><strong>Error:</strong> You need to supply a valid key.</p>';
}
?>
</div>
</div>
<br /><br />
</body>
</html>

75
style.css Normal file
View File

@ -0,0 +1,75 @@
/* Base element styles
----------------------------------------------------------------- */
body, div {
font-size: 11px;
font-family: verdana, geneva, sans-serif;
color: #000000;
background: #ffffff;
text-align: center;
padding: 0px 0px 0px 0px;
border: 0px solid #000000;
margin: 0px 0px 0px 0px;
line-height: 1.4;
}
/* Centers contents horizontally in browser window */
#page,
div #page, #signinpage {
height: 100%;
display: block;
float: none;
clear: both;
padding: 0px 14px 14px 14px;
border: 0px solid #999999;
margin: 0px 0px 0px 0px;
margin-right: auto;
margin-left: auto;
background: #ffffff;
color: #ffffff;
text-align: left;
}
#signinpage {
text-align: center;
}
#page{
width: 781px;
}
div {
text-align: left;
}
/* Headings */
/* Links on the front of the Reporter should be h2 but were done a p a.head */
h1, h1.firsthead, .firsthead,
h2, h2.nolinehead, .nolinehead, span.head, div.head, p.head, .longhead,
h3, .subhead,
h4, h5, h6,
p a.head {
display: block;
float: none;
clear: both;
color: #483D8B;
background: transparent;
font-family: verdana, geneva, sans-serif;
font-size: 18px;
font-weight: bold;
text-align: left;
line-height: 1;
padding: 3px 0px 0px 0px;
border: 0px solid #000000;
margin: 5px 0px 10px 0px;
}
h2, span.head, div.head, p.head, .longhead,
h2.nolinehead, .nolinehead,
p a.head {
font-size: 14px;
border-top: 1px solid #FF8C00;
margin: 5px 0px 5px 0px;
}