<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Algorithmic Base64 Discovery Tool</title>
<style>
body { font-family: Arial; background: #f4f4f4; padding: 20px; }
#container { background: white; padding: 20px; border-radius: 8px;
max-width: 700px; margin: auto; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
input, button { padding: 10px; font-size: 16px; width: 100%; margin-top: 10px; }
pre { background: #222; color: #0f0; padding: 15px; border-radius: 6px; overflow-x: auto; }
</style>
</head>
<body>
<div id="container">
<h2>Algorithmic Base64 Discovery Tool</h2>
<p>This tool discovers the password algorithmically using adaptive search.</p>
<label>Base64 Token:</label>
<input id="token" placeholder="Enter Base64 token">
<label>Known Username:</label>
<input id="username" placeholder="student">
<button onclick="discover()">Start Algorithmic Discovery</button>
<h3>Output:</h3>
<pre id="output"></pre>
</div>
<script src="discover.js"></script>
</body>
</html>
// MARKOV MODEL FOR PASSWORD DISCOVERY
// Build a Markov chain from a training set of passwords
function buildMarkovModel(trainingSet) {
const model = {};
for (let pass of trainingSet) {
for (let i = 0; i < pass.length - 1; i++) {
const curr = pass[i];
const next = pass[i + 1];
if (!model[curr]) model[curr] = {};
if (!model[curr][next]) model[curr][next] = 0;
model[curr][next] += 1;
}
}
return model;
}
// Generate next-character probabilities
function nextCharProbabilities(model, char) {
const transitions = model[char];
if (!transitions) return null;
const total = Object.values(transitions).reduce((a, b) => a + b, 0);
return Object.fromEntries(
Object.entries(transitions).map(([next, count]) => [
next,
count / total
])
);
}
// Generate candidate passwords using the Markov chain
function generateMarkovPasswords(model, length, alphabet) {
const candidates = [];
function dfs(prefix) {
if (prefix.length === length) {
candidates.push(prefix);
return;
}
const last = prefix[prefix.length - 1];
const probs = nextCharProbabilities(model, last);
if (probs) {
// Sort by probability (descending)
const sorted = Object.entries(probs)
.sort((a, b) => b[1] - a[1])
.map(([char]) => char);
for (let char of sorted) dfs(prefix + char);
} else {
// fallback: try all alphabet characters
for (let char of alphabet) dfs(prefix + char);
}
}
// Start with each alphabet character
for (let char of alphabet) dfs(char);
return candidates;
}
function discover() {
const token = document.getElementById("token").value.trim();
const username = document.getElementById("username").value.trim();
const output = document.getElementById("output");
output.textContent = "Analyzing token...\n";
// Decode Base64
let decoded;
try {
decoded = atob(token);
} catch {
output.textContent += "Invalid Base64 token.";
return;
}
output.textContent += `Decoded structure: ${decoded}\n`;
const parts = decoded.split(":");
const passLength = parts[1].length;
output.textContent += `Password length inferred: ${passLength}\n`;
const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
// TRAINING SET (students can expand this!)
const trainingSet = [
"abc123", "aaa111", "pass99", "test12", "qwerty", "hello1",
"student", "admin1", "root42", "guest00"
];
output.textContent += "Building Markov model...\n";
const model = buildMarkovModel(trainingSet);
output.textContent += "Generating candidate passwords using Markov chain...\n";
const candidates = generateMarkovPasswords(model, passLength, alphabet);
output.textContent += `Generated ${candidates.length} candidates.\n`;
let attempts = 0;
function encode(pass) {
return btoa(`${username}:${pass}`);
}
for (let pass of candidates) {
attempts++;
if (encode(pass) === token) {
output.textContent += `FOUND via Markov model: ${pass}\nAttempts: ${attempts}`;
return;
}
}
output.textContent += `No match found after ${attempts} attempts.`;
}







No comments:
Post a Comment